From nobody Mon Dec 27 00:47:18 2021 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 1A1AA190EA8B; Mon, 27 Dec 2021 00:47:19 +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 4JMfBt62nmz54kp; Mon, 27 Dec 2021 00:47:18 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 B03CE14C86; Mon, 27 Dec 2021 00:47:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BR0lISM056851; Mon, 27 Dec 2021 00:47:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BR0lIHo056850; Mon, 27 Dec 2021 00:47:18 GMT (envelope-from git) Date: Mon, 27 Dec 2021 00:47:18 GMT Message-Id: <202112270047.1BR0lIHo056850@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 0fa074b53e7c - main - nfscommon: Add arguments for support of the dacl attribute 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/main X-Git-Reftype: branch X-Git-Commit: 0fa074b53e7c22157dcb41aaa25a33abc8118f26 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640566038; 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=91PrzlLAiTJSilleBFqo4pWljSUVzVRzI1VVCcDlevo=; b=JT7APdFF3LwLDggU2Rnj+2tsjlQQYbZVRpPsm95AgbBoGggU1EvMjkOf9AF2HvRCBH1fYB IsM2526UsfKtszjA0p3rO9NlWLxeUqowYEBce5+NlEZ9cBxx8XghbJjloilT5NnJhqA+h3 h4Pnqe98dSXEN1HHg+fGG5zVktdMvOPlgkaHHNGZpy/a9BvFd7ZZTt99g7dfXVBhdj0b9W W/rdDitEQBfPU4CaQ239c4nW4eGfKctSzC4ZQoYxKadSDGHbd06C4SxSYUoKiw08BJazNg Q+buwFBaHNpfgt45nY0oYZW6Gam2J0Ykylfnhl0usF8W2GTQkbgs7o1BtpjuyQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640566038; a=rsa-sha256; cv=none; b=iWRcBsdW3oCV6nFLpROuDMYrmL0UbXRp/ybwQidSkLwLrjYRttEyMXbND/j59hZuuD2coE l0PZd0Pa5fhaDqbdO2rET2xWcOPr/Xevtbu2q5lHXw4ltp7XgsOkIqE/pAjY8+P2P5dabd IUEykruTNNOAsByTuo48v9PgqSrYjaFTvgJobf9Gom//mdU/EBV1PvKvmFuXTXUZdUIaV2 E602w3FFmvzvQsIZxbHLb0baW6s6Mu80LB8l/jJqpXc4g4eepyE6DiDyVi1k7bgOOnYpKB VZEcy/XulCjIew9IWSBWc+xQ7NEL/zpgsSG5OPFIENV1PRtof8dSHny+NbcWKQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=0fa074b53e7c22157dcb41aaa25a33abc8118f26 commit 0fa074b53e7c22157dcb41aaa25a33abc8118f26 Author: Rick Macklem AuthorDate: 2021-12-27 00:37:02 +0000 Commit: Rick Macklem CommitDate: 2021-12-27 00:43:46 +0000 nfscommon: Add arguments for support of the dacl attribute NFSv4.1/4.2 has an alternative to the acl attribute, called dacl, that includes support for the ACL_ENTRY_INHERITED flag, called NFSV4ACE_INHERITED in NFSv4. This patch adds a dacl argument to nfsrv_buildacl(), nfsrv_dissectacl() and nfsrv_dissectace(), so that they will handle NFSV4ACE_INHERITED when dacl == true. Since these functions are always called with dacl == false for this patch, semantics should not have changed. A future patch will add support for dacl. MFC after: 2 weeks --- sys/fs/nfs/nfs_commonacl.c | 16 +++++++++++----- sys/fs/nfs/nfs_commonsubs.c | 25 +++++++++++++------------ sys/fs/nfs/nfs_var.h | 6 +++--- sys/fs/nfs/nfsproto.h | 1 + sys/fs/nfsclient/nfs_clrpcops.c | 16 ++++++++-------- sys/fs/nfsserver/nfs_nfsdport.c | 4 ++-- 6 files changed, 38 insertions(+), 30 deletions(-) diff --git a/sys/fs/nfs/nfs_commonacl.c b/sys/fs/nfs/nfs_commonacl.c index 19492675e731..e3583b273db8 100644 --- a/sys/fs/nfs/nfs_commonacl.c +++ b/sys/fs/nfs/nfs_commonacl.c @@ -42,7 +42,7 @@ static int nfsrv_acemasktoperm(u_int32_t acetype, u_int32_t mask, int owner, */ int nfsrv_dissectace(struct nfsrv_descript *nd, struct acl_entry *acep, - int *aceerrp, int *acesizep, NFSPROC_T *p) + bool dacl, int *aceerrp, int *acesizep, NFSPROC_T *p) { u_int32_t *tl; int len, gotid = 0, owner = 0, error = 0, aceerr = 0; @@ -147,6 +147,10 @@ nfsrv_dissectace(struct nfsrv_descript *nd, struct acl_entry *acep, flag &= ~NFSV4ACE_FAILEDACCESS; acep->ae_flags |= ACL_ENTRY_FAILED_ACCESS; } + if (dacl && (flag & NFSV4ACE_INHERITED)) { + flag &= ~NFSV4ACE_INHERITED; + acep->ae_flags |= ACL_ENTRY_INHERITED; + } /* * Set ae_entry_type. */ @@ -278,14 +282,14 @@ out: /* local functions */ static int nfsrv_buildace(struct nfsrv_descript *, u_char *, int, - enum vtype, int, int, struct acl_entry *); + enum vtype, int, int, bool, struct acl_entry *); /* * This function builds an NFS ace. */ static int nfsrv_buildace(struct nfsrv_descript *nd, u_char *name, int namelen, - enum vtype type, int group, int owner, struct acl_entry *ace) + enum vtype type, int group, int owner, bool dacl, struct acl_entry *ace) { u_int32_t *tl, aceflag = 0x0, acemask = 0x0, acetype; int full_len; @@ -321,6 +325,8 @@ nfsrv_buildace(struct nfsrv_descript *nd, u_char *name, int namelen, aceflag |= NFSV4ACE_SUCCESSFULACCESS; if (ace->ae_flags & ACL_ENTRY_FAILED_ACCESS) aceflag |= NFSV4ACE_FAILEDACCESS; + if (dacl && (ace->ae_flags & ACL_ENTRY_INHERITED)) + aceflag |= NFSV4ACE_INHERITED; if (group) aceflag |= NFSV4ACE_IDENTIFIERGROUP; *tl++ = txdr_unsigned(aceflag); @@ -394,7 +400,7 @@ nfsrv_buildace(struct nfsrv_descript *nd, u_char *name, int namelen, */ int nfsrv_buildacl(struct nfsrv_descript *nd, NFSACL_T *aclp, enum vtype type, - NFSPROC_T *p) + bool dacl, NFSPROC_T *p) { int i, entrycnt = 0, retlen; u_int32_t *entrycntp; @@ -442,7 +448,7 @@ nfsrv_buildacl(struct nfsrv_descript *nd, NFSACL_T *aclp, enum vtype type, continue; } retlen += nfsrv_buildace(nd, name, namelen, type, isgroup, - isowner, &aclp->acl_entry[i]); + isowner, dacl, &aclp->acl_entry[i]); entrycnt++; if (malloced) free(name, M_NFSSTRING); diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c index e61327075a87..d2124d1f3c0a 100644 --- a/sys/fs/nfs/nfs_commonsubs.c +++ b/sys/fs/nfs/nfs_commonsubs.c @@ -1091,8 +1091,8 @@ nfsmout: * If the aclp == NULL or won't fit in an acl, just discard the acl info. */ int -nfsrv_dissectacl(struct nfsrv_descript *nd, NFSACL_T *aclp, int *aclerrp, - int *aclsizep, __unused NFSPROC_T *p) +nfsrv_dissectacl(struct nfsrv_descript *nd, NFSACL_T *aclp, bool dacl, + int *aclerrp, int *aclsizep, __unused NFSPROC_T *p) { u_int32_t *tl; int i, aclsize; @@ -1123,7 +1123,7 @@ nfsrv_dissectacl(struct nfsrv_descript *nd, NFSACL_T *aclp, int *aclerrp, for (i = 0; i < acecnt; i++) { if (aclp && !aceerr) error = nfsrv_dissectace(nd, &aclp->acl_entry[i], - &aceerr, &acesize, p); + dacl, &aceerr, &acesize, p); else error = nfsrv_skipace(nd, &acesize); if (error) @@ -1488,8 +1488,8 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp, NFSACL_T *naclp; naclp = acl_alloc(M_WAITOK); - error = nfsrv_dissectacl(nd, naclp, &aceerr, - &cnt, p); + error = nfsrv_dissectacl(nd, naclp, false, + &aceerr, &cnt, p); if (error) { acl_free(naclp); goto nfsmout; @@ -1499,8 +1499,8 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp, *retcmpp = NFSERR_NOTSAME; acl_free(naclp); } else { - error = nfsrv_dissectacl(nd, NULL, &aceerr, - &cnt, p); + error = nfsrv_dissectacl(nd, NULL, false, + &aceerr, &cnt, p); if (error) goto nfsmout; *retcmpp = NFSERR_ATTRNOTSUPP; @@ -1508,11 +1508,11 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp, } } else { if (vp != NULL && aclp != NULL) - error = nfsrv_dissectacl(nd, aclp, &aceerr, - &cnt, p); + error = nfsrv_dissectacl(nd, aclp, false, + &aceerr, &cnt, p); else - error = nfsrv_dissectacl(nd, NULL, &aceerr, - &cnt, p); + error = nfsrv_dissectacl(nd, NULL, false, + &aceerr, &cnt, p); if (error) goto nfsmout; } @@ -2691,7 +2691,8 @@ nfsv4_fillattr(struct nfsrv_descript *nd, struct mount *mp, vnode_t vp, * Recommended Attributes. (Only the supported ones.) */ case NFSATTRBIT_ACL: - retnum += nfsrv_buildacl(nd, aclp, vnode_vtype(vp), p); + retnum += nfsrv_buildacl(nd, aclp, vnode_vtype(vp), + false, p); break; case NFSATTRBIT_ACLSUPPORT: NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index 8fbf72345167..b2a44e6e16f2 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -331,7 +331,7 @@ int nfsm_advance(struct nfsrv_descript *, int, int); void *nfsm_dissct(struct nfsrv_descript *, int, int); void newnfs_copycred(struct nfscred *, struct ucred *); void newnfs_copyincred(struct ucred *, struct nfscred *); -int nfsrv_dissectacl(struct nfsrv_descript *, NFSACL_T *, int *, +int nfsrv_dissectacl(struct nfsrv_descript *, NFSACL_T *, bool, int *, int *, NFSPROC_T *); int nfsrv_getattrbits(struct nfsrv_descript *, nfsattrbit_t *, int *, int *); @@ -436,9 +436,9 @@ int nfs_supportsnfsv4acls(vnode_t); /* nfs_commonacl.c */ int nfsrv_dissectace(struct nfsrv_descript *, struct acl_entry *, - int *, int *, NFSPROC_T *); + bool, int *, int *, NFSPROC_T *); int nfsrv_buildacl(struct nfsrv_descript *, NFSACL_T *, enum vtype, - NFSPROC_T *); + bool, NFSPROC_T *); int nfsrv_compareacl(NFSACL_T *, NFSACL_T *); /* nfs_clrpcops.c */ diff --git a/sys/fs/nfs/nfsproto.h b/sys/fs/nfs/nfsproto.h index 968cc6a41cc3..b1b624e824c2 100644 --- a/sys/fs/nfs/nfsproto.h +++ b/sys/fs/nfs/nfsproto.h @@ -508,6 +508,7 @@ #define NFSV4ACE_SUCCESSFULACCESS 0x00000010 #define NFSV4ACE_FAILEDACCESS 0x00000020 #define NFSV4ACE_IDENTIFIERGROUP 0x00000040 +#define NFSV4ACE_INHERITED 0x00000080 #define NFSV4ACE_READDATA 0x00000001 #define NFSV4ACE_LISTDIRECTORY 0x00000001 diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index e7558b85a46f..8886ccc8429e 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -621,8 +621,8 @@ nfsrpc_openrpc(struct nfsmount *nmp, vnode_t vp, u_int8_t *nfhp, int fhlen, } if (ret) ndp->nfsdl_flags |= NFSCLDL_RECALL; - error = nfsrv_dissectace(nd, &ndp->nfsdl_ace, &ret, - &acesize, p); + error = nfsrv_dissectace(nd, &ndp->nfsdl_ace, false, + &ret, &acesize, p); if (error) goto nfsmout; } else if (deleg != NFSV4OPEN_DELEGATENONE) { @@ -2567,8 +2567,8 @@ nfsrpc_createv4(vnode_t dvp, char *name, int namelen, struct vattr *vap, } if (ret) dp->nfsdl_flags |= NFSCLDL_RECALL; - error = nfsrv_dissectace(nd, &dp->nfsdl_ace, &ret, - &acesize, p); + error = nfsrv_dissectace(nd, &dp->nfsdl_ace, false, + &ret, &acesize, p); if (error) goto nfsmout; } else if (deleg != NFSV4OPEN_DELEGATENONE) { @@ -8005,8 +8005,8 @@ nfsrpc_openlayoutrpc(struct nfsmount *nmp, vnode_t vp, u_int8_t *nfhp, ndp->nfsdl_flags = NFSCLDL_READ; if (ret != 0) ndp->nfsdl_flags |= NFSCLDL_RECALL; - error = nfsrv_dissectace(nd, &ndp->nfsdl_ace, &ret, - &acesize, p); + error = nfsrv_dissectace(nd, &ndp->nfsdl_ace, false, + &ret, &acesize, p); if (error != 0) goto nfsmout; } else if (deleg != NFSV4OPEN_DELEGATENONE) { @@ -8216,8 +8216,8 @@ nfsrpc_createlayout(vnode_t dvp, char *name, int namelen, struct vattr *vap, } if (ret != 0) dp->nfsdl_flags |= NFSCLDL_RECALL; - error = nfsrv_dissectace(nd, &dp->nfsdl_ace, &ret, - &acesize, p); + error = nfsrv_dissectace(nd, &dp->nfsdl_ace, false, + &ret, &acesize, p); if (error != 0) goto nfsmout; } else if (deleg != NFSV4OPEN_DELEGATENONE) { diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index 943523d2da14..50d679397f7b 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -2991,8 +2991,8 @@ nfsv4_sattr(struct nfsrv_descript *nd, vnode_t vp, struct nfsvattr *nvap, attrsum += NFSX_HYPER; break; case NFSATTRBIT_ACL: - error = nfsrv_dissectacl(nd, aclp, &aceerr, &aclsize, - p); + error = nfsrv_dissectacl(nd, aclp, false, &aceerr, + &aclsize, p); if (error) goto nfsmout; if (aceerr && !nd->nd_repstat)