From nobody Wed May 01 01:17:48 2024 X-Original-To: dev-commits-src-branches@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 4VTfM073Jzz5Hnv2; Wed, 1 May 2024 01:17:48 +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 4VTfM06Qr2z4tHd; Wed, 1 May 2024 01:17:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714526268; 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=61tWxn2dBTIon9Dz3vI9BgjI24QUQPMFNfgNb3zt9CU=; b=RbU6jVwTVyuNk5Y1n2LHJZ+vsuglx/xtAjwSmZphrBUYV/8RuhuhxDl9EaQbKWQpzI1uFN ySnTuD0LGTU0bHWR486LF8czuCxe1kCoUKbcL1KoDCrAKE1bn/pTWnVASMoVX7pRi+t3Oa O0X//7oAxbxscnKBF6pu7+RmBzojjJKyn+YIG7dfRk7mRSadih/BEsVdMjNlsMSuLNXz9D r0dicau9lxxHnCFHLAwyAtgYQZaErKvbbd/hHMjPtS1bae7pjutAhTWnw0R1qObVMrRFwk OHdQ6DNNxI8yicrSYfNbBs348oD82A0Jl+5FVHiHtHsWXopbC22Ey2EncVVa5Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714526268; a=rsa-sha256; cv=none; b=StuZKoJBQQw7LkfhWhG5QOh1OGi0xaSsoQq42g99MxMn5isZXf9KlLU/2rNMPp1A6XBVX/ EdXgIQtfg6Bn3sTFo4AfaAL8Gj/r2gcGiq15VN4nO6ISnAYmcPlpMmq5t19/HMTDCeveAl tEPnibit3TDQewnrS1t2dZoCDh5jeBaOb3nHcqoSG+yyY6M6JuVwwEyq8fiwqt8DZH9qrR Nv7z35pezr5lfKfVmuJ4kV4Geuq6FMAqKWe1obCImyNP0gfZWGwgFQKdSH62qpAuyLSheh ZmD15mbzKwKfYTjzz1mXNLK3Awqbb0TB/c1x9BDEd75oOK/aSyBZRJ44BYWVWw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714526268; 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=61tWxn2dBTIon9Dz3vI9BgjI24QUQPMFNfgNb3zt9CU=; b=jKAIR8295MbDd7YtC2ZRc4kiNRkDjCBXqJU1KoMbj/r8m2KcHIj9ED/6CJrRr94ocsLl0y ak6AOp6tQb+Wm25BtK3EF7is3Q8VbIsigzNjDpV0Y0f9JCK99QLFKjWrtjoXR/h+2Ag2Qz x6DyTzqwWA8ny+ZDhONrnsvFDKVFWMfgvMvacZPm7QY32dRyAni4FJ4hqTIhA/yj2isnh9 YspUEAyuWwiAsdGpzs90InePlpupwZIuvemqW9dMc72hYX/lOwDSfN06od1XOzNrF78H7A ug+m+4XhMTP0bZGVmaBe6Rf11Fe2i/PTC4/JR0F75ZjSiug+2Yjy3J5z+MJEkw== 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 4VTfM05kr2zy6y; Wed, 1 May 2024 01:17:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 4411HmnJ004132; Wed, 1 May 2024 01:17:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4411HmMj004129; Wed, 1 May 2024 01:17:48 GMT (envelope-from git) Date: Wed, 1 May 2024 01:17:48 GMT Message-Id: <202405010117.4411HmMj004129@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 19b6aa047e77 - stable/13 - nfscl: Do not use nfso_own for delayed nfsrpc_doclose() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 19b6aa047e77757de58811f02c564e8dff3679b6 Auto-Submitted: auto-generated The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=19b6aa047e77757de58811f02c564e8dff3679b6 commit 19b6aa047e77757de58811f02c564e8dff3679b6 Author: Rick Macklem AuthorDate: 2024-04-26 03:58:21 +0000 Commit: Rick Macklem CommitDate: 2024-05-01 01:16:33 +0000 nfscl: Do not use nfso_own for delayed nfsrpc_doclose() When an initial attempt to close an NFSv4 lock returns NFSERR_DELAY, the open structure is put on a list for delayed closing. When this is done, the nfso_own field is set to NULL, so it cannot be used by nfsrpc_doclose(). Without this patch, the NFSv4 client can crash when a NFSv4 server replies NFSERR_DELAY to a Close operation. Fortunately, most extant NFSv4 servers do not do this. This patch avoids the crash for any that do return NFSERR_DELAY for Close. Found during a IETF bakeathon testing event this week. (cherry picked from commit 6251027c4252edb3b8f8fc359a40e610349e9af3) --- sys/fs/nfsclient/nfs_clrpcops.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index 899d81efcf7c..475034768e04 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -799,6 +799,7 @@ nfsrpc_doclose(struct nfsmount *nmp, struct nfsclopen *op, NFSPROC_T *p, u_int64_t off = 0, len = 0; u_int32_t type = NFSV4LOCKT_READ; int error, do_unlock, trycnt; + bool own_not_null; tcred = newnfs_getcred(); newnfs_copycred(&op->nfso_cred, tcred); @@ -865,22 +866,29 @@ nfsrpc_doclose(struct nfsmount *nmp, struct nfsclopen *op, NFSPROC_T *p, * There could be other Opens for different files on the same * OpenOwner, so locking is required. */ - NFSLOCKCLSTATE(); - nfscl_lockexcl(&op->nfso_own->nfsow_rwlock, NFSCLSTATEMUTEXPTR); - NFSUNLOCKCLSTATE(); + own_not_null = false; + if (op->nfso_own != NULL) { + own_not_null = true; + NFSLOCKCLSTATE(); + nfscl_lockexcl(&op->nfso_own->nfsow_rwlock, NFSCLSTATEMUTEXPTR); + NFSUNLOCKCLSTATE(); + } do { error = nfscl_tryclose(op, tcred, nmp, p, loop_on_delayed); if (error == NFSERR_GRACE) (void) nfs_catnap(PZERO, error, "nfs_close"); } while (error == NFSERR_GRACE); - NFSLOCKCLSTATE(); - nfscl_lockunlock(&op->nfso_own->nfsow_rwlock); + if (own_not_null) { + NFSLOCKCLSTATE(); + nfscl_lockunlock(&op->nfso_own->nfsow_rwlock); + } LIST_FOREACH_SAFE(lp, &op->nfso_lock, nfsl_list, nlp) nfscl_freelockowner(lp, 0); if (freeop && error != NFSERR_DELAY) nfscl_freeopen(op, 0, true); - NFSUNLOCKCLSTATE(); + if (own_not_null) + NFSUNLOCKCLSTATE(); NFSFREECRED(tcred); return (error); }