From nobody@FreeBSD.org  Fri Dec 27 16:13:44 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id 69F27C07
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 27 Dec 2013 16:13:44 +0000 (UTC)
Received: from oldred.freebsd.org (oldred.freebsd.org [IPv6:2001:1900:2254:206a::50:4])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 560DC1AA4
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 27 Dec 2013 16:13:44 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id rBRGDgOL068946
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 27 Dec 2013 16:13:42 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id rBRGDgN8068938;
	Fri, 27 Dec 2013 16:13:42 GMT
	(envelope-from nobody)
Message-Id: <201312271613.rBRGDgN8068938@oldred.freebsd.org>
Date: Fri, 27 Dec 2013 16:13:42 GMT
From: Greg Becker <beckerg@netapp.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Kernel page fault in jailed() via vn_stat() when using uio_td from nfsrv_read()
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         185232
>Category:       kern
>Synopsis:       [nfs] [patch] Kernel page fault in jailed() via vn_stat() when using uio_td from nfsrv_read()
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    rmacklem
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 27 16:20:00 UTC 2013
>Closed-Date:    Fri May 09 00:38:25 UTC 2014
>Last-Modified:  Fri May 09 00:38:25 UTC 2014
>Originator:     Greg Becker
>Release:        9.2
>Organization:
NetApp
>Environment:
FreeBSD perf-filer-1.stl.netapp.com 9.2-STABLE FreeBSD 9.2-STABLE #69 r259677M: Fri Dec 27 06:15:18 CST 2013     beckerg@perf-filer-1.stl.netapp.com:/usr/obj/usr/src/sys/PERFFILER1  amd64
>Description:
I'm using a custom nullfs that calls vn_stat() from my null_read() function.  The problem is, nfsrv_read() doesn't set uio_td, so my null_read() function gets whatever was on the caller's stack.
>How-To-Repeat:

>Fix:
Either don't use uio_td when being called from nfssrv_read(), or set uio_td to NULL in nfssrv_read().


Patch attached with submission follows:

Index: sys/nfsserver/nfs_serv.c
===================================================================
--- sys/nfsserver/nfs_serv.c	(revision 259677)
+++ sys/nfsserver/nfs_serv.c	(working copy)
@@ -965,6 +965,7 @@
 		uiop->uio_resid = len;
 		uiop->uio_rw = UIO_READ;
 		uiop->uio_segflg = UIO_SYSSPACE;
+		uiop->uio_td = NULL;
 		nh = nfsrv_sequential_heuristic(uiop, vp);
 		ioflag |= nh->nh_seqcount << IO_SEQSHIFT;
 		error = VOP_READ(vp, uiop, IO_NODELOCKED | ioflag, cred);


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-fs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Apr 20 21:57:05 UTC 2014 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=185232 
Responsible-Changed-From-To: freebsd-fs->rmacklem 
Responsible-Changed-By: rmacklem 
Responsible-Changed-When: Sun Apr 20 23:03:30 UTC 2014 
Responsible-Changed-Why:  

I'll take this one. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=185232 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/185232: commit references a PR
Date: Thu, 24 Apr 2014 20:48:03 +0000 (UTC)

 Author: rmacklem
 Date: Thu Apr 24 20:47:58 2014
 New Revision: 264888
 URL: http://svnweb.freebsd.org/changeset/base/264888
 
 Log:
   The PR reported that the old NFS server did not set uio_td == NULL
   for the VOP_READ() call. This patch fixes both the old and new
   server for this case.
   
   PR:		185232
   Submitted by:	PR had patch for old server
   Reviewed by:	kib
   MFC after:	2 weeks
 
 Modified:
   head/sys/fs/nfsserver/nfs_nfsdport.c
   head/sys/nfsserver/nfs_serv.c
 
 Modified: head/sys/fs/nfsserver/nfs_nfsdport.c
 ==============================================================================
 --- head/sys/fs/nfsserver/nfs_nfsdport.c	Thu Apr 24 17:23:16 2014	(r264887)
 +++ head/sys/fs/nfsserver/nfs_nfsdport.c	Thu Apr 24 20:47:58 2014	(r264888)
 @@ -673,6 +673,7 @@ nfsvno_read(struct vnode *vp, off_t off,
  	uiop->uio_resid = len;
  	uiop->uio_rw = UIO_READ;
  	uiop->uio_segflg = UIO_SYSSPACE;
 +	uiop->uio_td = NULL;
  	nh = nfsrv_sequential_heuristic(uiop, vp);
  	ioflag |= nh->nh_seqcount << IO_SEQSHIFT;
  	error = VOP_READ(vp, uiop, IO_NODELOCKED | ioflag, cred);
 
 Modified: head/sys/nfsserver/nfs_serv.c
 ==============================================================================
 --- head/sys/nfsserver/nfs_serv.c	Thu Apr 24 17:23:16 2014	(r264887)
 +++ head/sys/nfsserver/nfs_serv.c	Thu Apr 24 20:47:58 2014	(r264888)
 @@ -911,6 +911,7 @@ nfsrv_read(struct nfsrv_descript *nfsd, 
  		uiop->uio_resid = len;
  		uiop->uio_rw = UIO_READ;
  		uiop->uio_segflg = UIO_SYSSPACE;
 +		uiop->uio_td = NULL;
  		nh = nfsrv_sequential_heuristic(uiop, vp);
  		ioflag |= nh->nh_seqcount << IO_SEQSHIFT;
  		error = VOP_READ(vp, uiop, IO_NODELOCKED | ioflag, cred);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: rmacklem 
State-Changed-When: Fri May 9 00:37:31 UTC 2014 
State-Changed-Why:  

The patch (r264888) has been MFC'd to stable/9 and stable/10. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=185232 
>Unformatted:
