mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] ksmbd: omit the DACL flags when the query omits the DACL
@ 2026-11-19  6:56 Ian Bridges
  0 siblings, 0 replies; only message in thread
From: Ian Bridges @ 2026-11-19  6:56 UTC (permalink / raw)
  To: linkinjeon
  Cc: senozhatsky, tom, chenxiaosong, linux-cifs, linux-kernel,
	Ian Bridges, stable

A client can query a file's owner or group without requesting its
DACL. ksmbd leaves the DACL out of that reply but copies the control
flags from the stored security descriptor.

The reply then has DACL_PRESENT set with a zero DACL offset. That
combination describes a NULL DACL, rather than saying that the client
did not request DACL information. The reply can also claim that the
omitted DACL is protected or auto-inherited. These flags are wrong only
in the reply. The server still enforces the file's stored DACL.

When the query omits the DACL, clear DACL_PRESENT,
DACL_AUTO_INHERITED and DACL_PROTECTED from the copied flags. Preserve
the other control bits, including those describing the owner or group.

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

Since v1
- Also clear DACL_AUTO_INHERITED and DACL_PROTECTED, as requested by
  Namjae Jeon.

Tested on ksmbd-for-next 267029b35ad1 with KASAN. Queries for the owner,
the group or both now omit all three flags. Tested protected and
auto-inherited DACLs, separately and together, with descriptors stored
through SET_INFO or inheritance. Descriptors stored without
DACL_PRESENT also keep their unrelated flags. Other tested query
results and smbtorture results match the base.

This patch was developed with LLM assistance.

v1: https://lore.kernel.org/linux-cifs/20261118174000.76954-1-icb@fastmail.org/

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

diff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c
index a87c22fa9a6e..1aa29966953a 100644
--- a/fs/smb/server/smbacl.c
+++ b/fs/smb/server/smbacl.c
@@ -1077,8 +1077,14 @@ int build_sec_desc(const struct mnt_idmap *idmap,
 	pntsd->sacloffset = 0;
 	pntsd->revision = cpu_to_le16(1);
 	pntsd->type = cpu_to_le16(SELF_RELATIVE);
-	if (ppntsd)
+	if (ppntsd) {
 		pntsd->type |= ppntsd->type;
+		/* These DACL flags are returned only with the DACL */
+		if (!(addition_info & DACL_SECINFO))
+			pntsd->type &= ~cpu_to_le16(DACL_PRESENT |
+						    DACL_AUTO_INHERITED |
+						    DACL_PROTECTED);
+	}
 
 	if (addition_info & OWNER_SECINFO) {
 		pntsd->osidoffset = cpu_to_le32(offset);
-- 
2.47.3


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

only message in thread, other threads:[~2026-11-19  6:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19  6:56 [PATCH v2] ksmbd: omit the DACL flags when the query omits the 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®