From: Yeonsu Jung <victorr0618@gmail.com>
To: Chuck Lever <cel@kernel.org>, Jeff Layton <jlayton@kernel.org>,
Trond Myklebust <trondmy@kernel.org>,
Anna Schumaker <anna@kernel.org>
Cc: NeilBrown <neil@brown.name>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
linux-nfs@vger.kernel.org, bobtobabz@gmail.com
Subject: [PATCH] NFS: reject invalid decoded NFSACLs
Date: Tue, 1 Dec 2026 13:32:38 +0900 [thread overview]
Message-ID: <20261201043238.562-1-victorr0618@gmail.com> (raw)
posix_acl_from_nfsacl() sorts decoded NFSACL entries and removes the
extra mask entry used by Solaris, but it does not validate the resulting
POSIX ACL. A malicious NFS server can therefore return an ACL that ends
in ACL_GROUP and lacks the required ACL_MASK and ACL_OTHER entries.
If that NFS mount is re-exported, NFSD can pass the invalid ACL to
_posix_to_nfsv4_one(). Its group walk assumes that posix_acl_valid() has
already succeeded, so it can read beyond the ACL and emit more than the
2 * a_count ACEs allocated by nfsd4_get_nfs4_acl(), causing a heap
out-of-bounds write.
Validate the ACL after sorting and applying the Solaris compatibility
fix. Have the NFSD request decoders record validation failures as
semantic errors so that invalid SETACL requests continue to receive the
protocol's INVAL response instead of RPC GARBAGE_ARGS.
Validated on the nfsd-testing base shown below with an x86-64 kernel
built by GCC 13.3 with W=1, CONFIG_WERROR=y, Generic KASAN, and lockdep. A
validation-only fixture on the unpatched kernel supplied a three-entry
GROUP-tail ACL with extra backing entries. The NFSv4 ACL converter
emitted eight ACEs into a six-ACE allocation, and KASAN reported a
slab-out-of-bounds write.
On the patched kernel, the malformed ACL returned -EINVAL, while a
valid Solaris ACL normalized successfully. In two-VM re-export tests,
both Solaris and extended named-group ACLs produced successful downstream
NFSv4.1 GETACL responses; 64 malformed ACL replies were rejected in
each run. Normal NFSv4.1 mount, read/write, and unmount tests passed.
No KASAN, lockdep, Oops, or panic report occurred in the patched runs.
The vulnerability research and validation were conducted by members of
the Tobabz team as part of the Best of the Best 15th program.
Fixes: b7fa0554cf1b ("[PATCH] NFS: Add support for NFSv3 ACLs")
Cc: stable@vger.kernel.org
Signed-off-by: Yeonsu Jung <victorr0618@gmail.com>
---
fs/nfs_common/nfsacl.c | 5 +++--
fs/nfsd/nfs2acl.c | 4 +++-
fs/nfsd/nfs3acl.c | 4 +++-
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/fs/nfs_common/nfsacl.c b/fs/nfs_common/nfsacl.c
index cb43fa203a..25f450a9ef 100644
--- a/fs/nfs_common/nfsacl.c
+++ b/fs/nfs_common/nfsacl.c
@@ -224,7 +224,8 @@ cmp_acl_entry(const void *x, const void *y)
* Sorts the entries into POSIX 1003.1e draft 17 order and removes the
* bogus ACL_MASK entry Solaris adds to a minimal ACL.
*
- * Return: 0. Always succeeds; a NULL @acl is a no-op.
+ * Return: 0 if @acl is valid, otherwise a negative error code. A NULL @acl
+ * is a no-op.
*/
int
posix_acl_from_nfsacl(struct posix_acl *acl)
@@ -260,7 +261,7 @@ posix_acl_from_nfsacl(struct posix_acl *acl)
sizeof(struct posix_acl_entry));
acl->a_count = 3;
}
- return 0;
+ return posix_acl_valid(&init_user_ns, acl);
}
EXPORT_SYMBOL_GPL(posix_acl_from_nfsacl);
diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c
index ed41fc6dbc..b9a5b5a94b 100644
--- a/fs/nfsd/nfs2acl.c
+++ b/fs/nfsd/nfs2acl.c
@@ -695,7 +695,9 @@ bool nfs_acl2_secattr_decode_end(struct xdrgen_aggregate_cursor *c, bool ok)
*/
if (!ok || argp->invalid)
return true;
- return posix_acl_from_nfsacl(acl) == 0;
+ if (posix_acl_from_nfsacl(acl))
+ argp->invalid = true;
+ return true;
}
/*
diff --git a/fs/nfsd/nfs3acl.c b/fs/nfsd/nfs3acl.c
index 50e5aee8b4..066397db9c 100644
--- a/fs/nfsd/nfs3acl.c
+++ b/fs/nfsd/nfs3acl.c
@@ -570,7 +570,9 @@ bool nfs_acl3_secattr_decode_end(struct xdrgen_aggregate_cursor *c, bool ok)
*/
if (!ok || argp->invalid)
return true;
- return posix_acl_from_nfsacl(acl) == 0;
+ if (posix_acl_from_nfsacl(acl))
+ argp->invalid = true;
+ return true;
}
/*
base-commit: 36fd4049e3c2bb901118e11be63bf7a7922bea8c
--
2.50.1 (Apple Git-155)
reply other threads:[~2026-12-01 4:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261201043238.562-1-victorr0618@gmail.com \
--to=victorr0618@gmail.com \
--cc=Dai.Ngo@oracle.com \
--cc=anna@kernel.org \
--cc=bobtobabz@gmail.com \
--cc=cel@kernel.org \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=tom@talpey.com \
--cc=trondmy@kernel.org \
/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