[PATCH] ksmbd: reject a security descriptor with OffsetDacl but no DACL_PRESENT
From: Ian Bridges
Date: Sun Nov 22 2026 - 10:56:16 EST
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@xxxxxxxxxxxxxxx
Signed-off-by: Ian Bridges <icb@xxxxxxxxxxxx>
---
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