From: Chuck Lever <cel@kernel.org>
To: NeilBrown <neil@brown.name>, Jeff Layton <jlayton@kernel.org>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <dai.ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Cc: <linux-nfs@vger.kernel.org>
Subject: [PATCH v1 1/2] NFSD: Map NFS_ACLv2 entry IDs through the request's user namespace
Date: Tue, 27 Oct 2026 09:51:57 -0400 [thread overview]
Message-ID: <20261027135158.164034-2-cel@kernel.org> (raw)
In-Reply-To: <20261027135158.164034-1-cel@kernel.org>
The NFS_ACLv2 GETACL encoder and SETACL decoder translate each ACL
entry's ID with init_user_ns, while the fattr in the same reply goes
through nfsd_user_namespace(). When the transport's credential comes
from a non-initial user namespace, GETACL reports host-global IDs
beside namespace-relative ownership attributes, and SETACL installs
named entries for whichever host-global principals share the wire
IDs. The fs/nfs_common/nfsacl.c helpers these codecs replaced had
the same mismatch.
Translate every entry ID in the request's user namespace. On encode,
use the munged variants so an ID with no mapping in that namespace is
reported as overflowuid, as nfsd_stat_to_fattr() already does. On
decode, an ID with no mapping fails the existing uid_valid() and
gid_valid() checks, and the decoder reports the ACL as invalid.
Signed-off-by: Chuck Lever <cel@kernel.org>
---
fs/nfsd/nfs2acl.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c
index b846624dfe82..8b6e3d717217 100644
--- a/fs/nfsd/nfs2acl.c
+++ b/fs/nfsd/nfs2acl.c
@@ -510,6 +510,7 @@ bool nfs_acl2_secattr_encode(struct xdrgen_aggregate_cursor *c,
struct aclent *out)
{
struct svc_rqst *rqstp = c->ctx;
+ struct user_namespace *userns = nfsd_user_namespace(rqstp);
struct GETACL2res_wrapper *resp = rqstp->rq_resp;
bool dfacl = c->member_id == NFS_ACL2_SECATTR_DFACLENT;
struct posix_acl *acl = dfacl ? resp->acl_default : resp->acl_access;
@@ -536,16 +537,16 @@ bool nfs_acl2_secattr_encode(struct xdrgen_aggregate_cursor *c,
out->type = tag | typeflag;
switch (tag) {
case ACL_USER_OBJ:
- out->id = from_kuid(&init_user_ns, resp->stat.uid);
+ out->id = from_kuid_munged(userns, resp->stat.uid);
break;
case ACL_GROUP_OBJ:
- out->id = from_kgid(&init_user_ns, resp->stat.gid);
+ out->id = from_kgid_munged(userns, resp->stat.gid);
break;
case ACL_USER:
- out->id = from_kuid(&init_user_ns, entry->e_uid);
+ out->id = from_kuid_munged(userns, entry->e_uid);
break;
case ACL_GROUP:
- out->id = from_kgid(&init_user_ns, entry->e_gid);
+ out->id = from_kgid_munged(userns, entry->e_gid);
break;
default:
/*
@@ -632,6 +633,7 @@ bool nfs_acl2_secattr_decode(struct xdrgen_aggregate_cursor *c,
const struct aclent *in)
{
struct svc_rqst *rqstp = c->ctx;
+ struct user_namespace *userns = nfsd_user_namespace(rqstp);
struct SETACL2args_wrapper *argp = rqstp->rq_argp;
bool dfacl = c->member_id == NFS_ACL2_SECATTR_DFACLENT;
struct posix_acl *acl = dfacl ? argp->acl_default : argp->acl_access;
@@ -651,14 +653,14 @@ bool nfs_acl2_secattr_decode(struct xdrgen_aggregate_cursor *c,
switch (in->type & ~NA_ACL_DEFAULT) {
case ACL_USER:
/* An id with no kernel mapping makes the ACL invalid. */
- entry->e_uid = make_kuid(&init_user_ns, in->id);
+ entry->e_uid = make_kuid(userns, in->id);
if (!uid_valid(entry->e_uid)) {
argp->invalid = true;
return true;
}
break;
case ACL_GROUP:
- entry->e_gid = make_kgid(&init_user_ns, in->id);
+ entry->e_gid = make_kgid(userns, in->id);
if (!gid_valid(entry->e_gid)) {
argp->invalid = true;
return true;
--
2.56.0
next prev parent reply other threads:[~2026-10-27 13:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 13:51 [PATCH v1 0/2] User namespaces for NFSD's NFS_ACL implementation Chuck Lever
2026-10-27 13:51 ` Chuck Lever [this message]
2026-10-27 13:51 ` [PATCH v1 2/2] NFSD: Map NFS_ACLv3 entry IDs through the request's user namespace Chuck Lever
2026-10-27 14:07 ` [PATCH v1 0/2] User namespaces for NFSD's NFS_ACL implementation Jeff Layton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261027135158.164034-2-cel@kernel.org \
--to=cel@kernel.org \
--cc=dai.ngo@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox