From linimon@lonesome.com  Mon Mar 12 00:36:42 2012
Return-Path: <linimon@lonesome.com>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 471B61065674;
	Mon, 12 Mar 2012 00:36:42 +0000 (UTC)
	(envelope-from linimon@lonesome.com)
Received: from mail.soaustin.net (pancho.soaustin.net [76.74.250.40])
	by mx1.freebsd.org (Postfix) with ESMTP id 24CEC8FC14;
	Mon, 12 Mar 2012 00:36:41 +0000 (UTC)
Received: by mail.soaustin.net (Postfix, from userid 502)
	id B6131561EC; Sun, 11 Mar 2012 19:36:41 -0500 (CDT)
Message-Id: <20120312003641.GA7675@lonesome.com>
Date: Sun, 11 Mar 2012 19:36:41 -0500
From: Mark Linimon <linimon@lonesome.com>
To: bug-followup@FreeBSD.org
Cc: freebsd-fs@FreeBSD.org
Subject: [luis.garces@gmail.com: kern/164445: [zfs][patch] WAS: lseek(2)
 always returns ENXIO with SEEK_DATA/SEEK_HOLE on 9.0 64bit ZFS]

>Number:         165953
>Category:       kern
>Synopsis:       Re: kern/164445: [zfs][patch] WAS: lseek(2)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 12 00:40:05 UTC 2012
>Closed-Date:    Mon Mar 12 00:54:28 UTC 2012
>Last-Modified:  Mon Mar 12 00:54:28 UTC 2012
>Originator:     
>Release:        
>Organization:
>Environment:
>Description:
 ----- Forwarded message from Luis Garces-Erice <luis.garces@gmail.com> -----
 
 Date: Wed, 7 Mar 2012 20:53:35 +0100
 From: Luis Garces-Erice <luis.garces@gmail.com>
 To: freebsd-bugs@freebsd.org
 Subject: kern/164445: [zfs][patch] WAS: lseek(2) always returns ENXIO with
 	SEEK_DATA/SEEK_HOLE on 9.0 64bit ZFS
 
 Hi all
 
 after digging a bit more into this
 (http://www.freebsd.org/cgi/query-pr.cgi?pr=164445), I've found the
 problem to be in ZFS or below. The patch attached addresses the
 symptom, but the problem remains.
 
 When invoking SEEK_DATA/SEEK_HOLE on a file on ZFS in FreeBSD 9.0 64
 bit, the functions ddi_copyin and ddi_copyout in zfs_ioctl() do not
 copy the offset passed from the application to the ioctl. The offset
 is passed correctly to zfs_ioctl(), though, but those functions copy
 garbage into the offset used by zfs_holey(). The corrupted offset is
 often bigger than the file, and thus the ioctl returns ENXIO.
 
 The patch does the copy of the offset passed from the application
 correctly, and allows lseek(2) with SEEK_DATA/SEEK_HOLE to be used on
 ZFS, but it is not a solution. I couldn't see a problem in the
 assembler of the copyin and copyout functions in
 sys/amd64/amd64/support.S, but I might be wrong, I'm no assembler
 expert.
 
 
 -- 
 Luis
 ****
 
 diff -w -u -r sys.orig/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
 --- sys.orig/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	2012-01-03 04:27:03.000000000 +0100
 +++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	2012-03-06 11:26:27.000000000 +0100
 @@ -296,6 +296,8 @@
  		if (ddi_copyin((void *)data, &off, sizeof (off), flag))
  			return (EFAULT);
  
 +		// ddi_copyin did not copy the offset
 +		off = (offset_t)*((offset_t *)data);
  		zp = VTOZ(vp);
  		zfsvfs = zp->z_zfsvfs;
  		ZFS_ENTER(zfsvfs);
 @@ -308,6 +310,8 @@
  			return (error);
  		if (ddi_copyout(&off, (void *)data, sizeof (off), flag))
  			return (EFAULT);
 +		// ddi_copyout did not copy the offset
 +		*((offset_t *)data)=off;
  		return (0);
  	}
  	return (ENOTTY);
 
 ----- End forwarded message -----
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Mon Mar 12 00:53:23 UTC 2012 
State-Changed-Why:  
Misfiled followup to kernel/164445; content migrated. 


Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon Mar 12 00:53:23 UTC 2012 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=165953 
>Unformatted:
  always returns ENXIO with SEEK_DATA/SEEK_HOLE on 9.0 64bit ZFS]
