Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Sep 2010 02:30:56 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r213191 - stable/8/sys/fs/nfsserver
Message-ID:  <201009270230.o8R2UupC009894@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Mon Sep 27 02:30:56 2010
New Revision: 213191
URL: http://svn.freebsd.org/changeset/base/213191

Log:
  MFC: r212443
  This patch applies one of the two fixes suggested by
  zack.kirsch at isilon.com for a race between nfsrv_freeopen()
  and nfsrv_getlockfile() in the experimental NFS server that
  he found during testing. Although nfsrv_freeopen() holds a
  sleep lock on the lock file structure when called with
  cansleep != 0, nfsrv_getlockfile() could still search the
  list, once it acquired the NFSLOCKSTATE() mutex. I believe
  that acquiring the mutex in nfsrv_freeopen() fixes the race.

Modified:
  stable/8/sys/fs/nfsserver/nfs_nfsdstate.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- stable/8/sys/fs/nfsserver/nfs_nfsdstate.c	Mon Sep 27 02:09:25 2010	(r213190)
+++ stable/8/sys/fs/nfsserver/nfs_nfsdstate.c	Mon Sep 27 02:30:56 2010	(r213191)
@@ -1085,8 +1085,11 @@ nfsrv_freeopen(struct nfsstate *stp, vno
 	 * associated with the open.
 	 * If there are locks associated with the open, the
 	 * nfslockfile structure can be freed via nfsrv_freelockowner().
-	 * (That is why the call must be here instead of after the loop.)
+	 * Acquire the state mutex to avoid races with calls to
+	 * nfsrv_getlockfile().
 	 */
+	if (cansleep != 0)
+		NFSLOCKSTATE();
 	if (lfp != NULL && LIST_EMPTY(&lfp->lf_open) &&
 	    LIST_EMPTY(&lfp->lf_deleg) && LIST_EMPTY(&lfp->lf_lock) &&
 	    LIST_EMPTY(&lfp->lf_locallock) && LIST_EMPTY(&lfp->lf_rollback) &&
@@ -1096,6 +1099,8 @@ nfsrv_freeopen(struct nfsstate *stp, vno
 		ret = 1;
 	} else
 		ret = 0;
+	if (cansleep != 0)
+		NFSUNLOCKSTATE();
 	FREE((caddr_t)stp, M_NFSDSTATE);
 	newnfsstats.srvopens--;
 	nfsrv_openpluslock--;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201009270230.o8R2UupC009894>