From owner-freebsd-bugs@FreeBSD.ORG Mon Jul 9 17:00:09 2007 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 91A6316A46B for ; Mon, 9 Jul 2007 17:00:09 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id 7009F13C4BE for ; Mon, 9 Jul 2007 17:00:09 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l69H09I9080510 for ; Mon, 9 Jul 2007 17:00:09 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l69H09U4080509; Mon, 9 Jul 2007 17:00:09 GMT (envelope-from gnats) Resent-Date: Mon, 9 Jul 2007 17:00:09 GMT Resent-Message-Id: <200707091700.l69H09U4080509@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Rick Macklem Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8FFAA16A46D for ; Mon, 9 Jul 2007 16:52:01 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [69.147.83.33]) by mx1.freebsd.org (Postfix) with ESMTP id 6A26013C48C for ; Mon, 9 Jul 2007 16:52:01 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l69Gq1BO053495 for ; Mon, 9 Jul 2007 16:52:01 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id l69Gq1EI053494; Mon, 9 Jul 2007 16:52:01 GMT (envelope-from nobody) Message-Id: <200707091652.l69Gq1EI053494@www.freebsd.org> Date: Mon, 9 Jul 2007 16:52:01 GMT From: Rick Macklem To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.0 Cc: Subject: kern/114451: NFS server possible crash X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jul 2007 17:00:09 -0000 >Number: 114451 >Category: kern >Synopsis: NFS server possible crash >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Jul 09 17:00:08 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Rick Macklem >Release: FreeBSD-CURRENT May snapshot >Organization: Univ of Guelph >Environment: FreeBSD nfsv4-laptop.cis.uoguelph.ca 7.0-CURRENT-200705 i386 >Description: Looking at the code, it is pretty obvious that sys/nfsserver/nfs_serv.c would crash in readdirplus if VFS_VGET() returns an error other than EOPNOTSUPP. See the "patch" file. >How-To-Repeat: Probably doesn't occur in practice, since VFS_VGET() would not normally return such an error. >Fix: See patch file. NB, I haven't actually tested this. Patch attached with submission follows: When working on my server port, I spotted the following in FreeBSD-CURRENT (May 2007 snapshot) in sys/nfsserver/nfs_serv.c (lines 3596-3612) /* * Probe one of the directory entries to see if the filesystem * supports VGET. */ if (VFS_VGET(vp->v_mount, dp->d_fileno, LK_EXCLUSIVE, &nvp) == EOPNOTSUPP) { error = NFSERR_NOTSUPP; vrele(vp); vp = NULL; free((caddr_t)cookies, M_TEMP); free((caddr_t)rbuf, M_TEMP); nfsm_reply(NFSX_V3POSTOPATTR); nfsm_srvpostop_attr(getret, &at); error = 0; goto nfsmout; } vput(nvp); *** nvp not set when VFS_VGET() returns an error other than EOPNOTSUPP. If you look at the above, it's pretty obvious that, if VFS_VGET() returns an error other than EOPNOTSUPP, then it vputs crap. Maybe should be something like (haven't actually tested this): /* * Probe one of the directory entries to see if the filesystem * supports VGET. */ error = VFS_VGET(vp->v_mount, dp->d_fileno, LK_EXCLUSIVE, &nvp); if (error == EOPNOTSUPP) { error = NFSERR_NOTSUPP; vrele(vp); vp = NULL; free((caddr_t)cookies, M_TEMP); free((caddr_t)rbuf, M_TEMP); nfsm_reply(NFSX_V3POSTOPATTR); nfsm_srvpostop_attr(getret, &at); error = 0; goto nfsmout; } if (error) error = 0; else vput(nvp); >Release-Note: >Audit-Trail: >Unformatted: