From owner-svn-src-all@FreeBSD.ORG Sun Jul 13 00:19:40 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0B2F6433; Sun, 13 Jul 2014 00:19:40 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D248D20EA; Sun, 13 Jul 2014 00:19:39 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s6D0JdG4011076; Sun, 13 Jul 2014 00:19:39 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s6D0JdbU011075; Sun, 13 Jul 2014 00:19:39 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201407130019.s6D0JdbU011075@svn.freebsd.org> From: Rick Macklem Date: Sun, 13 Jul 2014 00:19:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r268580 - stable/10/sys/fs/nfsclient X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Jul 2014 00:19:40 -0000 Author: rmacklem Date: Sun Jul 13 00:19:39 2014 New Revision: 268580 URL: http://svnweb.freebsd.org/changeset/base/268580 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/10/sys/fs/nfsclient/nfs_clstate.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/fs/nfsclient/nfs_clstate.c ============================================================================== --- stable/10/sys/fs/nfsclient/nfs_clstate.c Sat Jul 12 23:27:38 2014 (r268579) +++ stable/10/sys/fs/nfsclient/nfs_clstate.c Sun Jul 13 00:19:39 2014 (r268580) @@ -281,6 +281,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. */ @@ -295,23 +312,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); }