From nobody Thu Nov 02 22:02: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 4SLyXG5SPYz4yT1r; Thu, 2 Nov 2023 22:02: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 4SLyXG52bJz4YGs; Thu, 2 Nov 2023 22:02:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698962526; 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=zUAWEzg+dQZJ3Jf40BxEYI7Qc4T3aN8bJR8oL/+3nRM=; b=tfOeqAhMgyvkmdN/u/iDiF7Tpk8DdizTfZP5UJR6QPoxHposnKkkhN8ChJzv1ElBOUwM8x 32HJnZxF9eikVduwBrfTIilduVCgYN/oM1SlfFAiJ5MN9A9RuNDny3FKQCYGTE4m/JiZgZ N87gLVGDLlkVL5HQXEO9z6Ywel240f71fM1EBZ/oTqAwXF7QjuDLim7xtJ6o2LqJWDUjWK NDaOGbJcs2EQIiIYT7kmMig9kfV5qa4WgHUC2T/nWH2U9JTbX2wIT1V8nviOImrYWJ5ZXe Q4WscHd5FGzDK5mHaOiaXlGrF+d5I58eJ84savGnEhyfRmW6RqFiV/lIUPZx0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698962526; 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=zUAWEzg+dQZJ3Jf40BxEYI7Qc4T3aN8bJR8oL/+3nRM=; b=x2MuXh8PCqnBSrZQRTqp5MRzl4gA6anJrKj7DKCEu3ur0baQUpgF86Yda95bkV0UTwateV uX3iqSmFElV17Eyiy0Y4QeVn3hOUAMIQaJSMyW6GSHzN6qdSuCzdID42/rDANONHCqM6y8 xzmlC1qT/s/ZAqqZ2R191/m1I6yuQStF6VWSuJ4sULkNaeztmvGar8HMW5Y/omniWlNp/2 /HQB541iSRLLsCwKgw56xuNAWI9Fit3TfoJEea6G/FGVrddIwCVKaJsfaxLXqT3ahXE3oN wVP2yU8sLITSJ8sEgEk/bYTjazcQfzvo2WCMIsfPwbBgpn2PtzFYRUhAPBspKA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698962526; a=rsa-sha256; cv=none; b=i2/UcFtRtIUmUmhJiLNMMVquQkoqIehcOCGNZ2jLUCXcY0VoXJkd+7YQIWLxY5p8D22rrS zW6eQ/gXFqO8YqnSApVR2f+3v8dRr4Ut/BB71GbDJG5sOHyAN8O9avYAeYexfIlv36QFzO XHpTIdMgthcttuO07Fd87/yDSoyAA1kM201MUZeeZMAFfySx5w8zXdk9FvT9T10S+tgXzN cfFogBWAFm10DuaIcAJ5oe4nrfsadn3cHqSi1AX2p85nlBM9JQ9w5ZjCc4tf/ABFiaHS7Z 4T0hEftfYtOF6kAjf3p/5sWAcbGkNJWCyVKFcpQdL29Qumonu29YhPWBkchu4w== 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 4SLyXG45XkzmGr; Thu, 2 Nov 2023 22:02: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 3A2M26g4077370; Thu, 2 Nov 2023 22:02:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A2M26YA077367; Thu, 2 Nov 2023 22:02:06 GMT (envelope-from git) Date: Thu, 2 Nov 2023 22:02:06 GMT Message-Id: <202311022202.3A2M26YA077367@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: d9e28d5d40c9 - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: d9e28d5d40c9888f996e895d4bde51b49e7b0946 Auto-Submitted: auto-generated The branch stable/14 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=d9e28d5d40c9888f996e895d4bde51b49e7b0946 commit d9e28d5d40c9888f996e895d4bde51b49e7b0946 Author: Rick Macklem AuthorDate: 2023-10-19 19:35:35 +0000 Commit: Rick Macklem CommitDate: 2023-11-02 22:00: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 7d3ebc683d16..3daee65ab83a 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -3000,12 +3000,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 c73840277022..da57ebde7a52 100644 --- a/sys/fs/nfsserver/nfs_nfsdstate.c +++ b/sys/fs/nfsserver/nfs_nfsdstate.c @@ -2568,6 +2568,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 @@ -2578,8 +2582,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) || @@ -2830,6 +2834,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 @@ -2840,8 +2848,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) ||