From nobody Thu Nov 2 23:45:40 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 4SM0qn1Mgwz4yrvt; Thu, 2 Nov 2023 23:45:41 +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 4SM0qn0rBFz3KZV; Thu, 2 Nov 2023 23:45:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698968741; 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=M8PsR/UoMlX8AQxA70jLvzCsgxLT5T0Mhjv0tB2/GP0=; b=GFw/ENf6nc6HfO3KNr2CXoZxVnpMWRJZ+XOCUGmroX18xtXqh9FsgnymwZK5FdPa/PWy4j C27JsyegscTmn1FEf2fl45vayLR5Q/I8WGbvqCzy3Dc1+4Vwr5DygJPr0j8i+eVl79Hypz VOFEPiI/GLGicskSgGg3WtuHfrU4uY4AivluEFdUZOsFGpCtnk0vx+nuXGQGAoS7jsKcB6 hU2e9k8aCw2aTmexqldI3P2zH3bAvqG76YtFKdbeF1cyZWA4Ejheax+rfa2IH8CvWjP0tb NhUH4LC1SuiRumVJgcuzakj9S0yu7NBnT7UskTn1W+DgVfHnGgTZLaAk784P0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698968741; 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=M8PsR/UoMlX8AQxA70jLvzCsgxLT5T0Mhjv0tB2/GP0=; b=KimE9c5zAOqJP7hjs5UMpuguMklO9LCL4AAXV4g4i2DiYPjQZPc80f2di8KvEu+aflg4hK t1pNV0MKdnWlaq8BuXeRs21p0pqFJxi+KnMBl8Ic0n5q2aYntsW93oVOEKThQBGinFP+uq KEWdp+t1ib75WlJJawixu7HNPBtrDw1Dsdplrfo2qg3FZ6qOYqHRCSd6frBLWXBsfFtVv/ HtP/bcNQuThwE+Se5TQ4AA5hYimMtkAgGOXyBCfsU4SAJGfoQFh93lP4H9qas0c0MpSZQO hdKH4mxdYFvW1ExjhFwrwD2caeD6rfU9qD6iSwRt2deCX415pfEnwxVEjYEQrA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698968741; a=rsa-sha256; cv=none; b=eIlRFpyU2f0sC3e3x8CfBD6b1dyH/zPyAiIgBOBbPQzgA23Y+N7EmBGRl1gjAz732uhels 1wB/fBq9phpI4WCTg7aY17yA8ELdAGIkSRLe1Xjo1DahCxzSse3lmzWzebJUS0qsQtCI9K QQKfI8zUsZgHIExphjNcW/y4+Z2UoPlF+hrRitVBMWI60NAFxWqepS4HfZnqrd7WSEThGe UaT5PahHYNQDGQr/6arRnXqLUZJabbMLB+at9V7abI+7L6VsciB1QsYV2OS2NlG3KCX+l4 aFq+GzLMBDkVK9jWm7ABSM/YNwqDR4Iw477/gQWloxsRksCyDj6em0IsCxj+Og== 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 4SM0qm72BBzqPF; Thu, 2 Nov 2023 23:45:40 +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 3A2NjepZ045654; Thu, 2 Nov 2023 23:45:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A2NjedQ045651; Thu, 2 Nov 2023 23:45:40 GMT (envelope-from git) Date: Thu, 2 Nov 2023 23:45:40 GMT Message-Id: <202311022345.3A2NjedQ045651@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: f383f4ad30a6 - stable/12 - 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/12 X-Git-Reftype: branch X-Git-Commit: f383f4ad30a61fd0cd5104bb5c730aff139b993d Auto-Submitted: auto-generated The branch stable/12 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=f383f4ad30a61fd0cd5104bb5c730aff139b993d commit f383f4ad30a61fd0cd5104bb5c730aff139b993d Author: Rick Macklem AuthorDate: 2023-10-19 19:35:35 +0000 Commit: Rick Macklem CommitDate: 2023-11-02 23:44:27 +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 e283e8611944..e5eced9c8a69 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -2913,12 +2913,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 cb4597ec1575..f5f498f61b6b 100644 --- a/sys/fs/nfsserver/nfs_nfsdstate.c +++ b/sys/fs/nfsserver/nfs_nfsdstate.c @@ -2529,6 +2529,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 @@ -2539,8 +2543,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) || @@ -2791,6 +2795,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 @@ -2801,8 +2809,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) ||