mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ksmbd: check the ACEs after an NFS mode ACE in a DACL
@ 2026-11-20 16:34 Ian Bridges
  0 siblings, 0 replies; only message in thread
From: Ian Bridges @ 2026-11-20 16:34 UTC (permalink / raw)
  To: linkinjeon
  Cc: senozhatsky, tom, chenxiaosong, linux-cifs, linux-kernel,
	Ian Bridges, stable

An allow ACE with SID S-1-5-88-3-<mode> supplies the POSIX mode
directly, and parse_dacl() stops walking the ACEs at the first one.
The same walk checks each ACE and maps its generic rights, so the ACEs
after the NFS mode ACE are neither checked nor mapped. set_info_sec()
still stores the entire DACL and the request succeeds, but part of
that DACL can have no effect.

Continue checking the remaining ACEs and mapping their generic rights,
while preserving the mode from the first NFS mode ACE.

Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Cc: stable@vger.kernel.org
Signed-off-by: Ian Bridges <icb@fastmail.org>
---

Without this patch, an ACE allowing GENERIC_READ after the NFS mode
ACE grants no access, because the right stays unmapped. A malformed
ACE after the NFS mode ACE is stored instead of being refused. The
access check and QUERY stop at it, so the ACEs after it are neither
applied nor returned.

Tested on ksmbd-for-next 2ef9bd9fa819 with KASAN. CREATE now rejects a
malformed ACE after an NFS mode ACE with STATUS_INVALID_PARAMETER.
GENERIC_READ in a later ACE is stored as the mapped rights, 0x120089,
and now grants read access. Other tested descriptors are stored
unchanged, and smbtorture results match the base.

This patch was developed with LLM assistance.

 fs/smb/server/smbacl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c
index 58b74b95246e..7bb28ea195c8 100644
--- a/fs/smb/server/smbacl.c
+++ b/fs/smb/server/smbacl.c
@@ -401,6 +401,7 @@ static int parse_dacl(const struct mnt_idmap *idmap,
 	struct posix_acl_state acl_state, default_acl_state;
 	umode_t mode = 0, acl_mode;
 	bool owner_found = false, group_found = false, others_found = false;
+	bool nfs_mode_found = false;
 
 	if (!pdacl)
 		return 0;
@@ -479,13 +480,17 @@ static int parse_dacl(const struct mnt_idmap *idmap,
 		ppace[i]->access_req =
 			smb_map_generic_desired_access(ppace[i]->access_req);
 
+		/* ACEs after an NFS mode ACE do not change the POSIX mapping */
+		if (nfs_mode_found)
+			continue;
+
 		if (ppace[i]->type == ACCESS_ALLOWED &&
 		    ppace[i]->sid.num_subauth >= 3 &&
 		    !(compare_sids(&ppace[i]->sid, &sid_unix_NFS_mode))) {
 			fattr->cf_mode =
 				le32_to_cpu(ppace[i]->sid.sub_auth[2]);
 			fattr->cf_posix_mode = true;
-			break;
+			nfs_mode_found = true;
 		} else if (!compare_sids(&ppace[i]->sid, pownersid)) {
 			acl_mode = access_flags_to_mode(fattr,
 							ppace[i]->access_req,
-- 
2.47.3


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-20 16:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20 16:34 [PATCH] ksmbd: check the ACEs after an NFS mode ACE in a DACL Ian Bridges

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®