From nobody Mon May 13 04:50:57 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 4Vd6WQ0j1Xz5KChN; Mon, 13 May 2024 04:50:58 +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 4Vd6WP5B18z4H4m; Mon, 13 May 2024 04:50:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715575857; 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=5C9a7fkDK/jdd6PR2vGUGPW+vo8n4zEJiMt0B2JUuUo=; b=OiqEMgSnnU4+SmRTQvzHLcOMnaI86tLq+2Cn3niuBAZQpP1xtM5PSznYxkPit0v405fkQO j7nQ1nCXngF3zeg8OdWjjt1cQiJJi1AZDwxax8fi9b9Fb14lYbSrwrN90rv7oEbtGYiSkx rd9bjuxdnOQrYfsSthdIt1p8rbmdjXWYF/oV3fPc/K0d4mo3HmgzHFAuBWnZ9pN93MtBmj torguJNLRNxhPUR1J96YdG6J16gcjJc3gFX01rJEsxma37Cbw6BUZTFBG5T9GoGRkAgL+N TE2K/BgE7zO2RUcRLUiihUP5kg/yUFYRqjE5N3Y582IVBbgswLatlg29VV1cHg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715575857; a=rsa-sha256; cv=none; b=Gt9XCo+7fDUXwZnCkGBafwpuw9L0iPQZzSvCbHroVEpK3fTZf8Mp5zG25eIXSSX+CTO63V qOON3z5f0NlSIQqeoUU3FDiKYwYjM/nncmb3tjn0eEitOkXy0DWmVauAWeFjddqO41mL1t dPAqHYlbCD+VW4TL4ABpH1YRe7/EYUq7C34QL4HvjsFO9eaTn8oHhkGMRez2AtvTFYxiPf vesMw3pyHRvcMtfsco3d4RFNN7aeihw8ADN/vHaLBYyJTLY7pSrkjMSfdiSNnIC2tK1JUz 29Vc3UCijfleOHddpK3X314g3h3rEc1zFwWj2TjiOqqnGYWZ5koui1EoMz9WIA== 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=1715575857; 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=5C9a7fkDK/jdd6PR2vGUGPW+vo8n4zEJiMt0B2JUuUo=; b=r8Am1NozyA5FMXkVRM+7BCHnT0EgghWM+NCVtJErsMc6+YoLIMtuMXXlVqZ1Us4qiy6yoq Qk1LwTplEO19aVJ/fcAnA/MhjApIfQ4kVFWFczD6BvZNI7Vc/myH+8ZvGEL2e3LBSR8YeK hkW3BJz4o5qGaXqU73FKHU7n5dvL+QEmmclcd4XlIWi6Se3fSsWEoa9Uh2wHtRjGXBVBjc 2KtZxaGvcItMkmQe4CaodsLCLEqQPnDnPbXHeQR4/CkOJZNj7RyrppO2gF5mQEsWd7Qrme YYyq4yePe7b4oWkHrnRHQPFLnXQFDYYFbrhwueUYn4xcOpP7HKPezE6NoU7mGQ== 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 4Vd6WP4pCWzZTR; Mon, 13 May 2024 04:50:57 +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 44D4ovlI026274; Mon, 13 May 2024 04:50:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44D4ov5g026271; Mon, 13 May 2024 04:50:57 GMT (envelope-from git) Date: Mon, 13 May 2024 04:50:57 GMT Message-Id: <202405130450.44D4ov5g026271@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: 2c65656b29fb - releng/14.1 - nfsd: Fix Link conformance with RFC8881 for delegations 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/releng/14.1 X-Git-Reftype: branch X-Git-Commit: 2c65656b29fb803edeeda931c6771c7c22c9efac Auto-Submitted: auto-generated The branch releng/14.1 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=2c65656b29fb803edeeda931c6771c7c22c9efac commit 2c65656b29fb803edeeda931c6771c7c22c9efac Author: Rick Macklem AuthorDate: 2024-05-04 21:30:07 +0000 Commit: Rick Macklem CommitDate: 2024-05-13 04:49:04 +0000 nfsd: Fix Link conformance with RFC8881 for delegations RFC8881 specifies that, when a Link operation occurs on an NFSv4, that file delegations issued to other clients must be recalled. Discovered during a recent discussion on nfsv4@ietf.org. Although I have not observed a problem caused by not doing the required delegation recall, it is definitely required by the RFC, so this patch makes the server do the recall. Tested during a recent NFSv4 IETF Bakeathon event. Approved by: re (cperciva) (cherry picked from commit 3f65000b6b1460a7a23cd83014bb41a68d1a8a19) (cherry picked from commit 3c414a8c2fb37ca37de454aaa145e7bcaefcaa05) --- sys/fs/nfs/nfs_var.h | 2 +- sys/fs/nfsserver/nfs_nfsdport.c | 12 +++++++----- sys/fs/nfsserver/nfs_nfsdserv.c | 11 +++++++++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index 578fb3ce1340..950e0c097457 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -713,7 +713,7 @@ int nfsvno_rmdirsub(struct nameidata *, int, struct ucred *, NFSPROC_T *, struct nfsexstuff *); int nfsvno_rename(struct nameidata *, struct nameidata *, u_int32_t, u_int32_t, struct ucred *, NFSPROC_T *); -int nfsvno_link(struct nameidata *, vnode_t, struct ucred *, +int nfsvno_link(struct nameidata *, vnode_t, nfsquad_t, struct ucred *, NFSPROC_T *, struct nfsexstuff *); int nfsvno_fsync(vnode_t, u_int64_t, int, struct ucred *, NFSPROC_T *); int nfsvno_statfs(vnode_t, struct statfs *); diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index f8c2ddfd2a59..f4679309657b 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -1656,8 +1656,8 @@ out1: * Link vnode op. */ int -nfsvno_link(struct nameidata *ndp, struct vnode *vp, struct ucred *cred, - struct thread *p, struct nfsexstuff *exp) +nfsvno_link(struct nameidata *ndp, struct vnode *vp, nfsquad_t clientid, + struct ucred *cred, struct thread *p, struct nfsexstuff *exp) { struct vnode *xp; int error = 0; @@ -1672,9 +1672,11 @@ nfsvno_link(struct nameidata *ndp, struct vnode *vp, struct ucred *cred, } if (!error) { NFSVOPLOCK(vp, LK_EXCLUSIVE | LK_RETRY); - if (!VN_IS_DOOMED(vp)) - error = VOP_LINK(ndp->ni_dvp, vp, &ndp->ni_cnd); - else + if (!VN_IS_DOOMED(vp)) { + error = nfsrv_checkremove(vp, 0, NULL, clientid, p); + if (error == 0) + error = VOP_LINK(ndp->ni_dvp, vp, &ndp->ni_cnd); + } else error = EPERM; if (ndp->ni_dvp == vp) { vrele(ndp->ni_dvp); diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c index 8141ee6cbdb6..0c8bda6dc6a6 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -1797,6 +1797,7 @@ nfsrvd_link(struct nfsrv_descript *nd, int isdgram, char *bufp; u_long *hashp; struct thread *p = curthread; + nfsquad_t clientid; if (nd->nd_repstat) { nfsrv_postopattr(nd, getret, &at); @@ -1858,8 +1859,14 @@ nfsrvd_link(struct nfsrv_descript *nd, int isdgram, NULL); } } - if (!nd->nd_repstat) - nd->nd_repstat = nfsvno_link(&named, vp, nd->nd_cred, p, exp); + if (!nd->nd_repstat) { + clientid.qval = 0; + if ((nd->nd_flag & (ND_IMPLIEDCLID | ND_NFSV41)) == + (ND_IMPLIEDCLID | ND_NFSV41)) + clientid.qval = nd->nd_clientid.qval; + nd->nd_repstat = nfsvno_link(&named, vp, clientid, nd->nd_cred, + p, exp); + } if (nd->nd_flag & ND_NFSV3) getret = nfsvno_getattr(vp, &at, nd, p, 0, NULL); if (dirp) {