From nobody Sat May 11 01:10:39 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 4Vbnk7632gz5Kmrf; Sat, 11 May 2024 01:10:39 +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 4Vbnk74jsbz52Td; Sat, 11 May 2024 01:10:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715389839; 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=5t55/PRXAr/8zihj5HFdpyEMU+SomQOgyW1+Xq7Ihgk=; b=VteHO5lgH0U35yQPcbL2keFDZyQyGii+H6PcJtU7bqmQU5LX98QqX0wTVY9Oi2G5gzDNFv lujTmDyURDlo2/YlTn8toyXrramoH06XwHSmFa2Dfz0de16B9f+vGvp+1Hrqh6dRwW3/MD xNb13r8axwie3evoyLfCrwaIs8Tp6MYzOw7p1raJt59bkEf1GyQdztI8xzByY/Y3HDRpFy 5243iDy0yZ9JGAskuaXmZOVlznquyWYAszNkrQL0kxG42oWXKu4F24OqWza5/4/mgwZy+a S5deeKyMVTUv8VwB27ju2eY6Y4apcS1ZoMwTiEdomdIGwK9KoYhE87HFir5YMQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715389839; a=rsa-sha256; cv=none; b=hvZskQ24t0rAuwyOH9UkHrt4GCvhHOd7WuZP9yhBzEoEGuo1IHI48rndUtjtZzCm8240pp 3uzGWGT7dS1DSxG7saJ+1o040RPtT3tQQObxf0uXnoS8Sp5L+vtehWBeNqhLlazmdhHUwY JXyiDvHm1FXTOPOzouVOsJ/f3sDytuooCD2+o3WkjJ+nUoVKJa4qyhw/Yjgd683dhd+Otq i+jzxA5RMVV1WIjXrKQzF4qSj24jLoabhvgpJ+qJ4WaRQmoy4LUKG/wRad1rT9az0Z5VxS vYN9qSOkZH2f/imkiMtqNvoh9ThcfxZnyFRmIAoWhg/rMS3YkRW9GrG0la5oTQ== 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=1715389839; 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=5t55/PRXAr/8zihj5HFdpyEMU+SomQOgyW1+Xq7Ihgk=; b=XyuFa2dAHsEe6kxxhLi4jr4sSwF0IvpwyMf/W6OFoH5sm8pXhcc3LB9E31xzPDYF309CWt Tw7e4jysHmhD8SQ+TA10lo4650uGMvr25E0Eq9IyAI+lg1v5U4CSr5Z1oyl87AmqcbFAGK PzkIDlYuvX1ycF2WtCJXMWi8l/N/PKr6Xq4xUPuoY8mL2GtAhODyUfRGSZbuFcZcIGiFEM 8vJowLFCujC/mwmMDmiNA1/sPuNKQzskXDUaOngLBIpEN4nTcB6gE4VLnzrpw1LXlvDF+S HUUgWAaza33eQZrChZtaFGvynsdIqBRRSCJLxYlrQNh2Hegc9qSX5ZTXCrH8Eg== 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 4Vbnk74KF0z10w8; Sat, 11 May 2024 01:10:39 +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 44B1Ad76080066; Sat, 11 May 2024 01:10:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44B1AdEr080063; Sat, 11 May 2024 01:10:39 GMT (envelope-from git) Date: Sat, 11 May 2024 01:10:39 GMT Message-Id: <202405110110.44B1AdEr080063@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: 85e63d952d5d - stable/13 - nfsd: Fix Link conformance with RFC8881 for delegations 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 85e63d952d5daf929c24874a3b309e1b2e04bebf Auto-Submitted: auto-generated The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=85e63d952d5daf929c24874a3b309e1b2e04bebf commit 85e63d952d5daf929c24874a3b309e1b2e04bebf Author: Rick Macklem AuthorDate: 2024-05-04 21:30:07 +0000 Commit: Rick Macklem CommitDate: 2024-05-11 01:09:21 +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. (cherry picked from commit 3f65000b6b1460a7a23cd83014bb41a68d1a8a19) --- 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 8cdc08fba433..083a974516b0 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -707,7 +707,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 ebc560836205..46be3e051056 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -1675,8 +1675,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; @@ -1691,9 +1691,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 437f4b1c685d..ccaeb4153253 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -1799,6 +1799,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); @@ -1861,8 +1862,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) {