mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ksmbd: reject a security descriptor with OffsetDacl but no DACL_PRESENT
@ 2026-11-22 15:56 Ian Bridges
  0 siblings, 0 replies; only message in thread
From: Ian Bridges @ 2026-11-22 15:56 UTC (permalink / raw)
  To: linkinjeon
  Cc: senozhatsky, tom, chenxiaosong, linux-cifs, linux-kernel,
	Ian Bridges, stable

parse_sec_desc() returns early when DACL_PRESENT is clear and checks
nothing else in the descriptor. set_info_sec() then removes the POSIX
ACLs and stores the descriptor as sent, OffsetDacl included. The
access check, inheritance and QUERY use the DACL at OffsetDacl without
looking at DACL_PRESENT. A SET_INFO without the flag can therefore
store a DACL that was never checked or mapped to the mode, and that
DACL is enforced.

A descriptor without DACL_PRESENT has no DACL, so its OffsetDacl must
be zero. Reject a nonzero OffsetDacl in that case with -EINVAL, as
parse_sec_desc() does for other malformed descriptors.

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

Tested on ksmbd-for-next 89d5e8fdd5a7 with KASAN. A SET_INFO with
DACL_PRESENT clear and a nonzero OffsetDacl now fails with
STATUS_INVALID_PARAMETER, and the file keeps its previous descriptor
and POSIX ACL. Before, the DACL was stored without checks, the POSIX
ACL was removed, and a deny ACE in the DACL was enforced. A CREATE
whose security descriptor context has this form now fails the same way
after the file is created, as a CREATE with another malformed context
does. Descriptors with DACL_PRESENT set, owner and group changes from
smbcacls and the Linux cifs client, and smbtorture give the same
results as the base.

This patch was developed with LLM assistance.

 fs/smb/server/smbacl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c
index 7bb28ea195c8..446b4f69d7c4 100644
--- a/fs/smb/server/smbacl.c
+++ b/fs/smb/server/smbacl.c
@@ -963,6 +963,9 @@ int parse_sec_desc(const struct mnt_idmap *idmap, struct smb_ntsd *pntsd,
 	pntsd_type = le16_to_cpu(pntsd->type);
 	if (!(pntsd_type & DACL_PRESENT)) {
 		ksmbd_debug(SMB, "DACL_PRESENT in DACL type is not set\n");
+		/* Without DACL_PRESENT, OffsetDacl must be 0 (MS-DTYP 2.4.6) */
+		if (dacloffset)
+			return -EINVAL;
 		return rc;
 	}
 
-- 
2.47.3


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

only message in thread, other threads:[~2026-11-22 15:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-22 15:56 [PATCH] ksmbd: reject a security descriptor with OffsetDacl but no DACL_PRESENT 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®