From nobody Fri Apr 26 04:00:01 2024 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 4VQfBT5Qmrz5HlfV; Fri, 26 Apr 2024 04:00:01 +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 4VQfBT4rrKz4h83; Fri, 26 Apr 2024 04:00:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714104001; 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=rMyXfft9exwbpaMxWDTEp7EZjCVYtmx3EfiCryrMHMI=; b=oF5gv7v4DOHMITDwE0r6BAZ+gv2PanGInlTAkjHX5WYSXgPRI5qZXcKJ14rNuHpeoT+osQ 0WDHH1/MZBh8ulHqX20jkVjuMq6C91I7P2vhp3iK6UtpMuVqeQ1i1Vvv9jySII4H7c86rr pfIepgU5PbWinA0m/7E2TCc7zox9ZnAlWxcN47Z+G4okXm8P283YFnkRJ2WrXruXMUsjlC vOXvTGv7uMyf5KFzlj8UhBemvj/BNs/muZymhbzN7HS7xmil1OEJwEZL0PeoSfC1M86O4l bSuTXJs+3ETu/BUH5H5BzQhGhcIcU1satB6ca3NP/DGFtucVSZhy/WeKWSzLSQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714104001; a=rsa-sha256; cv=none; b=R1lZPVxrd5cD6NtD2MF9MvO2tSPG03PoIhf59ZxC1NWAMGROVbdzDhdYTLWW4W9MvX7Jos KkMXIdVrA6PKUv3ewahRApHSm3oS+564OL5j6CXorOYwJ9R6uomnTgIHDfnwraNhYvQ42f ht+J21HgSPsc6NgGNW88ZVRbcZAHh6PCDD5+29Age7SRFWiHb5J0eIUPRvm1BeFPbF/O5p pLpB9gZejzWoQlp5BIdEJyOEHSdoTeeoBxLXMkMoJ2cKu7ceB1WDbx1iYA0qsGYYrdhJXH eqwD30Vvx+wdPqImBGaOQTTpsfEbY4Qr4kZgQk4mkjHM/n/LdsBcsgdAQevp/g== 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=1714104001; 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=rMyXfft9exwbpaMxWDTEp7EZjCVYtmx3EfiCryrMHMI=; b=rXtIR0YnXO1YZidBHaIbyn8GMHPr1ZKusYhkVtLDdQydEjrDgZXeMrBP+Xg8siD09+hHoc Tnsk4zlehpMP5CnQdogdv40Shmy940UQOq3/+uHAvABlp5cy24DJGKfRrWoSiJOYSkg0Z7 POtgLhTnaKS7CVtJQrzjgQeRYrad+K/YF+fiy2iM9wPYEB0EPTaWpjexDkJkPYoNzCeZqt 89/z9DZ5tQ48qWmA+LlfQbdM4kkebZdT3/lM6HYt1EP3HdTq8H3VPl+ysLUwT9w194Ukqw J+LCOOabM5KSVsOdFfDZ3csA2sEfbDMR2jmWh+tIKlXDiXy//sufbIrlO09mYg== 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 4VQfBT4QFLzRvZ; Fri, 26 Apr 2024 04:00:01 +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 43Q401Jb081435; Fri, 26 Apr 2024 04:00:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43Q401HZ081425; Fri, 26 Apr 2024 04:00:01 GMT (envelope-from git) Date: Fri, 26 Apr 2024 04:00:01 GMT Message-Id: <202404260400.43Q401HZ081425@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: 6251027c4252 - main - nfscl: Do not use nfso_own for delayed nfsrpc_doclose() 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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: 6251027c4252edb3b8f8fc359a40e610349e9af3 Auto-Submitted: auto-generated The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=6251027c4252edb3b8f8fc359a40e610349e9af3 commit 6251027c4252edb3b8f8fc359a40e610349e9af3 Author: Rick Macklem AuthorDate: 2024-04-26 03:58:21 +0000 Commit: Rick Macklem CommitDate: 2024-04-26 03:58:21 +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. MFC after: 5 days --- 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 75bb5236cb65..8c5532268287 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -826,6 +826,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); @@ -892,22 +893,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); }