From nobody Wed Feb 08 21:09:46 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PBt164G6zz3pKg1; Wed, 8 Feb 2023 21:09:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PBt163p2nz3m2w; Wed, 8 Feb 2023 21:09:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675890586; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=17/M1rqL1Jw9szwot+51+Z9eCqP8IjaGvw5SSLRfvks=; b=IV3QPi2ZWg00Ff4e+/569z9fasCjv2nEQZNF9WAN5+ykUPVkzEWqay3kpD6C/ImLAk57XB zsT7pTYMeVe6piJz8YdBVGNe6ynXCxcHYs7KCNL4Etb0QyP1unJtq1bP3IL17CJmFtvmlG kQIKY2pt2uOZ9ikIrd/oG+BXHmLA6x9XNctrACTWBw18EyE5yYwv61CZBMp6JhMSDpmIeW 6tUuGX98K+nRzj59qatuR+3Nb3lIyYYF4hGemdwODb3rvoCDrFkCBycs1fFeevvqjvhoHs /KucwigwPH0kzIMBLicNewhFM4CbZh7L0jGw1skd6thlKAbnfzf4s5RMz7id7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675890586; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=17/M1rqL1Jw9szwot+51+Z9eCqP8IjaGvw5SSLRfvks=; b=Y77lcTRHtTDa20gqWGpI11IjxdHAfRGo0ECsY3azdR9RbTXwbNS6qWMzfSokLipcBDY0Kh T7YZQDOI4BPjJdvQMaZccrbW3LdfIloKxBN9ddyr4/eof3up53+qxd8YN+hbusR4Sia/pi zW8r0loxEC2AtaxfnqTkS5qFDRxzfmyIvMEFtt2oMpX/01OD5WAYnNF9rkeD7ADeHKw2jT 5T5Y93cNxpgpkxY6aN8rYvXlIoGNTDIc/FbKmp0fIzN2Do0/P+jnwfSqEuz/ROD/y1I561 c0VrLjOLZh0ZQV3K1xv4W+JsZRHLkHffgyRqlPpjB73M7OIJh6DsL1/CZqSKAw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675890586; a=rsa-sha256; cv=none; b=nFqFy3hQmbBHldRTSbUEApCLgodYjEGWa6PUf3klY2GEIVK2vjQIu30FGua7jKLkp4TslK aivGMXk+Z/re3jZzJF2ZSoDi79daRhvRPYaD+riMIlSYmUqCVDCGYeJaqLJJkK7I82SHua ugn4iTspVS2O9NHOrFAaHzG76C3Mjx3OOGxNjHBbO03M2beRgM3H5Y0lkR6yWjtRfoK2hG Fdnir0cd1Yssa6B1zYeTqpIxCysEat0XoV6mPVOlA+O5s711w5dZxOaggoXyn+sxbnxOfB hh3WdUGBEIWP4CsKmqCXwY47yVaTJ8uYHapnUYdJtiwZjK2D0YxYxAB7W3we4w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PBt162s6lz1BM7; Wed, 8 Feb 2023 21:09:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 318L9ktb068729; Wed, 8 Feb 2023 21:09:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 318L9kxj068728; Wed, 8 Feb 2023 21:09:46 GMT (envelope-from git) Date: Wed, 8 Feb 2023 21:09:46 GMT Message-Id: <202302082109.318L9kxj068728@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: ded5f2954e1a - main - nfsd: Fix handling of the error case for nfsvno_open List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ded5f2954e1a1bb7748646888938af767ee6257a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=ded5f2954e1a1bb7748646888938af767ee6257a commit ded5f2954e1a1bb7748646888938af767ee6257a Author: Rick Macklem AuthorDate: 2023-02-08 21:06:07 +0000 Commit: Rick Macklem CommitDate: 2023-02-08 21:08:51 +0000 nfsd: Fix handling of the error case for nfsvno_open Using done_namei instead of ni_startdir did not fix the crashes reported in the PR. Upon looking more closely at the code, the only case where the code near the end of nfsvno_open() needs to be executed is when nfsvno_namei() has succeeded, but a subsequent error was detected. This patch uses done_namei to indicate this case. Also, nfsvno_relpathbuf() should only be called for this case and not whenever nfsvno_open() is called with nd_repstat != 0. A bug was introduced here when the HASBUF flag was deleted. Reviewed by: mjg PR: 268971 Tested by: ish@amail.plala.or.jp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D38430 --- sys/fs/nfsserver/nfs_nfsdport.c | 22 +++++++++++++--------- sys/fs/nfsserver/nfs_nfsdserv.c | 10 +++++----- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index d02653823857..7305ae6a84fe 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -1916,16 +1916,20 @@ nfsvno_open(struct nfsrv_descript *nd, struct nameidata *ndp, stateidp, stp, vp, nd, p, nd->nd_repstat); } } - } else { + } else if (done_namei) { + /* + * done_namei is set when nfsvno_namei() has completed + * successfully, but a subsequent error was set in + * nd_repstat. As such, cleanup of the nfsvno_namei() + * results is required. + */ nfsvno_relpathbuf(ndp); - if (done_namei && create == NFSV4OPEN_CREATE) { - if (ndp->ni_dvp == ndp->ni_vp) - vrele(ndp->ni_dvp); - else - vput(ndp->ni_dvp); - if (ndp->ni_vp) - vput(ndp->ni_vp); - } + if (ndp->ni_dvp == ndp->ni_vp) + vrele(ndp->ni_dvp); + else + vput(ndp->ni_dvp); + if (ndp->ni_vp) + vput(ndp->ni_vp); } *vpp = vp; diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c index 0433e9cda656..569ddc9141bb 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -3043,7 +3043,6 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, if (!nd->nd_repstat) { nd->nd_repstat = nfsvno_namei(nd, &named, dp, 0, exp, &dirp); - done_namei = true; } else { vrele(dp); nfsvno_relpathbuf(&named); @@ -3051,7 +3050,7 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, if (create == NFSV4OPEN_CREATE) { switch (how) { case NFSCREATE_UNCHECKED: - if (done_namei && named.ni_vp != NULL) { + if (nd->nd_repstat == 0 && named.ni_vp != NULL) { /* * Clear the setable attribute bits, except * for Size, if it is being truncated. @@ -3063,13 +3062,14 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, } break; case NFSCREATE_GUARDED: - if (done_namei && named.ni_vp != NULL && - nd->nd_repstat == 0) + if (nd->nd_repstat == 0 && named.ni_vp != NULL) { nd->nd_repstat = EEXIST; + done_namei = true; + } break; case NFSCREATE_EXCLUSIVE: exclusive_flag = 1; - if (done_namei && named.ni_vp == NULL) + if (nd->nd_repstat == 0 && named.ni_vp == NULL) nva.na_mode = 0; break; case NFSCREATE_EXCLUSIVE41: