From nobody Thu Nov 2 23:35:06 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 4SM0bZ4Bfkz4yq7v; Thu, 2 Nov 2023 23:35:06 +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 4SM0bZ3LHxz3HXd; Thu, 2 Nov 2023 23:35:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698968106; 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=AJM+L4u0o3HoT1K+eCjD/SyzbFQtitR7bsAShIBHBDE=; b=r5oftC0t7Q3AKNSsUbu5EJdT7drco6XxzwETxSyVru87AZy0lnMhvRQ+jXtAGvurBMTq7Z YOvbvUkA7LPYW69zPeqlAHXCabKVC/w38vc4YHmNI4ClOSxHBT+zLBSJPoxWo2GeK/HI4U KiPi1CVM6dJD4KpbIa6anjuAdu1gD2pM5jwC1hX0dSlYd6o9h+MNfKfrRtCsyEmJo6Oqx9 bNwdFwgUy10Fh7EwOr0wJd4YbjP+qjY4cjHhpeyXX+xSgLPs2ooaxDsXA/knaaJIM4Jyj1 7LNpv2ut7GbaXWCi2td6xUb48BbP+YLRPJc6W27RIcbE+iNOPk0gHuy0J3Zb8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698968106; 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=AJM+L4u0o3HoT1K+eCjD/SyzbFQtitR7bsAShIBHBDE=; b=UCKsI1LXquyK3FD32CUOQ092Qer+nS9c+YfkG5IxwRN3NeurPh82UqRuH5F0bBMxHI+L87 fzhwMWMsDSh6TfI3Tke7TmAdLGCXKd6pVwmj+uOCUJigCzatNqwRV36ZulPEFHslFlRf2Q LUn97QzCO9VNTnUqmTE+hraJsIOIODD4EQaZ27lEF2CocQJJgDIDLB/zW2mbaNX+84Z95e zmiJ5K+Ph9rN3wJ6vhvTYLGOixaj0XWdZXQgVvR2zVmVQYl9Fci5Mtpm6ZHbmHwqqlQ+77 BLv2NQMb68WfKkl5uxqCYZ7jpHlJbSvJTIHeSnjtRa2ORPDpRMw29QOFPiTMSg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698968106; a=rsa-sha256; cv=none; b=lzvexcNY2N2zbQbkafyUFDdUZqdW5Gy6etb89BRV0AagLeciRWA3lA9DHEg6RzZlt1yl/+ IdNaskLgOtAyikDYZAmOd97/Q3Gqk7pNv1jWnDBosVxZGtP44OajiVV+pYDn8+qX0FG8c0 X7pbWRj6RyePdXhQZAOq6tdaydhOh1CIBvzG+leWT0hduhI7j/yk9gbY4Uel5l3YK0S1jN 1YGYINgYq9Y3qblB/OMzMO9iFz27slDLWI3epzd/T0MKbinusfl/rg7qCX6e1WWMmHcFj/ yaz30gsQVacItg65nlt+CNwGqDY6d+N8EWIrHhvS3ZoZcCngzQJ0k0ksQhmk2w== 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 4SM0bZ2Q0WzpXj; Thu, 2 Nov 2023 23:35:06 +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 3A2NZ6Ts028778; Thu, 2 Nov 2023 23:35:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A2NZ6j1028775; Thu, 2 Nov 2023 23:35:06 GMT (envelope-from git) Date: Thu, 2 Nov 2023 23:35:06 GMT Message-Id: <202311022335.3A2NZ6j1028775@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: f33609bc7799 - stable/13 - nfsd: Fix NFSv4.1/4.2 Claim_Deleg_Cur_FH 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/stable/13 X-Git-Reftype: branch X-Git-Commit: f33609bc7799bd1ebefa2f7cad02be646bcf21e9 Auto-Submitted: auto-generated The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=f33609bc7799bd1ebefa2f7cad02be646bcf21e9 commit f33609bc7799bd1ebefa2f7cad02be646bcf21e9 Author: Rick Macklem AuthorDate: 2023-10-19 19:35:35 +0000 Commit: Rick Macklem CommitDate: 2023-11-02 23:33:48 +0000 nfsd: Fix NFSv4.1/4.2 Claim_Deleg_Cur_FH When I implemented a test patch using Open Claim_Deleg_Cur_FH I discovered that the NFSv4.1/4.2 server was broken for this Open option. Fortunately it is never used by the FreeBSD client and never used by other clients unless delegations are enabled. (The FreeBSD NFSv4 server does not have delegations enabled by default.) Claim_Deleg_Cur_FH was broken because the code mistakenly assumed a stateID argument, which is not the case. This patch fixes the bug by changing the XDR parser to not expect a stateID and to fill most of the stateID in from the clientID. The clientID is the first two elements of the "other" array for the stateID and is sufficient to identify which client the delegation is issued to. Since there is only one delegation issued to a client per file, this is sufficient to locate the correct delegation. If you are running non-FreeBSD NFSv4.1/4.2 mounts against the FreeBSD server, you need this patch if you have delegations enabled. PR: 274574 (cherry picked from commit f300335d9aebf2e99862bf783978bd44ede23550) --- sys/fs/nfsserver/nfs_nfsdserv.c | 10 ++++++++-- sys/fs/nfsserver/nfs_nfsdstate.c | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c index 24d290c4cf5d..7020053be330 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -3003,12 +3003,18 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, */ NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); claim = fxdr_unsigned(int, *tl); - if (claim == NFSV4OPEN_CLAIMDELEGATECUR || claim == - NFSV4OPEN_CLAIMDELEGATECURFH) { + if (claim == NFSV4OPEN_CLAIMDELEGATECUR) { NFSM_DISSECT(tl, u_int32_t *, NFSX_STATEID); stateid.seqid = fxdr_unsigned(u_int32_t, *tl++); NFSBCOPY((caddr_t)tl,(caddr_t)stateid.other,NFSX_STATEIDOTHER); stp->ls_flags |= NFSLCK_DELEGCUR; + } else if (claim == NFSV4OPEN_CLAIMDELEGATECURFH) { + /* Fill in most of the stateid from the clientid. */ + stateid.seqid = 0; + stateid.other[0] = clientid.lval[0]; + stateid.other[1] = clientid.lval[1]; + stateid.other[2] = 0; + stp->ls_flags |= NFSLCK_DELEGCUR; } else if (claim == NFSV4OPEN_CLAIMDELEGATEPREV || claim == NFSV4OPEN_CLAIMDELEGATEPREVFH) { stp->ls_flags |= NFSLCK_DELEGPREV; diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c index 06d0b79f10d5..f54459947f44 100644 --- a/sys/fs/nfsserver/nfs_nfsdstate.c +++ b/sys/fs/nfsserver/nfs_nfsdstate.c @@ -2555,6 +2555,10 @@ tryagain: /* * For Delegate_Cur, search for the matching Delegation, * which indicates no conflict. + * For NFSv4.1/4.2 Claim_Deleg_Cur_FH only provides + * the clientid, which is the first two "other" elements + * for the stateid. This should be sufficient, since there + * is only one delegation per client and file. * An old delegation should have been recovered by the * client doing a Claim_DELEGATE_Prev, so I won't let * it match and return NFSERR_EXPIRED. Should I let it @@ -2565,8 +2569,8 @@ tryagain: (((nd->nd_flag & ND_NFSV41) != 0 && stateidp->seqid == 0) || stateidp->seqid == stp->ls_stateid.seqid) && - !NFSBCMP(stateidp->other, stp->ls_stateid.other, - NFSX_STATEIDOTHER)) + stateidp->other[0] == stp->ls_stateid.other[0] && + stateidp->other[1] == stp->ls_stateid.other[1]) break; } if (stp == LIST_END(&lfp->lf_deleg) || @@ -2817,6 +2821,10 @@ tryagain: /* * For Delegate_Cur, search for the matching Delegation, * which indicates no conflict. + * For NFSv4.1/4.2 Claim_Deleg_Cur_FH only provides + * the clientid, which is the first two "other" elements + * for the stateid. This should be sufficient, since there + * is only one delegation per client and file. * An old delegation should have been recovered by the * client doing a Claim_DELEGATE_Prev, so I won't let * it match and return NFSERR_EXPIRED. Should I let it @@ -2827,8 +2835,8 @@ tryagain: (((nd->nd_flag & ND_NFSV41) != 0 && stateidp->seqid == 0) || stateidp->seqid == stp->ls_stateid.seqid) && - !NFSBCMP(stateidp->other, stp->ls_stateid.other, - NFSX_STATEIDOTHER)) + stateidp->other[0] == stp->ls_stateid.other[0] && + stateidp->other[1] == stp->ls_stateid.other[1]) break; } if (stp == LIST_END(&lfp->lf_deleg) ||