svn commit: r268579 - stable/9/sys/fs/nfsclient

Rick Macklem rmacklem at FreeBSD.org
Sat Jul 12 23:27:39 UTC 2014


Author: rmacklem
Date: Sat Jul 12 23:27:38 2014
New Revision: 268579
URL: http://svnweb.freebsd.org/changeset/base/268579

Log:
  MFC: r268008
  There might be a potential race condition for the NFSv4 client
  when a newly created file has another open done on it that
  update the open mode. This patch moves the code that updates
  the open mode up into the block where the mutex is held to
  ensure this cannot happen. No bug caused by this potential
  race has been observed, but this fix is a safety belt to ensure
  it cannot happen.

Modified:
  stable/9/sys/fs/nfsclient/nfs_clstate.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/fs/   (props changed)

Modified: stable/9/sys/fs/nfsclient/nfs_clstate.c
==============================================================================
--- stable/9/sys/fs/nfsclient/nfs_clstate.c	Sat Jul 12 22:56:41 2014	(r268578)
+++ stable/9/sys/fs/nfsclient/nfs_clstate.c	Sat Jul 12 23:27:38 2014	(r268579)
@@ -261,6 +261,23 @@ nfscl_open(vnode_t vp, u_int8_t *nfhp, i
 	    newonep);
 
 	/*
+	 * Now, check the mode on the open and return the appropriate
+	 * value.
+	 */
+	if (retp != NULL) {
+		if (nfhp != NULL && dp != NULL && nop == NULL)
+			/* new local open on delegation */
+			*retp = NFSCLOPEN_SETCRED;
+		else
+			*retp = NFSCLOPEN_OK;
+	}
+	if (op != NULL && (amode & ~(op->nfso_mode))) {
+		op->nfso_mode |= amode;
+		if (retp != NULL && dp == NULL)
+			*retp = NFSCLOPEN_DOOPEN;
+	}
+
+	/*
 	 * Serialize modifications to the open owner for multiple threads
 	 * within the same process using a read/write sleep lock.
 	 */
@@ -275,23 +292,6 @@ nfscl_open(vnode_t vp, u_int8_t *nfhp, i
 		*owpp = owp;
 	if (opp != NULL)
 		*opp = op;
-	if (retp != NULL) {
-		if (nfhp != NULL && dp != NULL && nop == NULL)
-			/* new local open on delegation */
-			*retp = NFSCLOPEN_SETCRED;
-		else
-			*retp = NFSCLOPEN_OK;
-	}
-
-	/*
-	 * Now, check the mode on the open and return the appropriate
-	 * value.
-	 */
-	if (op != NULL && (amode & ~(op->nfso_mode))) {
-		op->nfso_mode |= amode;
-		if (retp != NULL && dp == NULL)
-			*retp = NFSCLOPEN_DOOPEN;
-	}
 	return (0);
 }
 


More information about the svn-src-all mailing list