mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ian Bridges <icb@fastmail.org>
To: linkinjeon@kernel.org
Cc: senozhatsky@chromium.org, tom@talpey.com,
	chenxiaosong@chenxiaosong.com, linux-cifs@vger.kernel.org,
	linux-kernel@vger.kernel.org, Ian Bridges <icb@fastmail.org>,
	stable@vger.kernel.org
Subject: [PATCH] ksmbd: return only the control flags of the parts in a query reply
Date: Sun, 22 Nov 2026 10:01:49 -0600	[thread overview]
Message-ID: <20261122160149.403491-1-icb@fastmail.org> (raw)

build_sec_desc() copies the stored control flags into the query reply
and clears only the DACL flags when the DACL is not requested. A
SET_INFO without DACL_PRESENT stores the control word as the client
sent it. Its other flags then appear in every reply, such as
OWNER_DEFAULTED in a reply without the owner, and SACL_PRESENT
although ksmbd refuses to query the SACL.

Copy a stored control flag into the reply only when the part it goes
with is in the reply. OWNER_DEFAULTED goes with the owner and
GROUP_DEFAULTED with the group. DACL_PRESENT, DACL_DEFAULTED,
DACL_AUTO_INHERITED and DACL_PROTECTED go with the DACL. The SACL
flags and the other stored bits, such as SERVER_SECURITY and
RM_CONTROL_VALID, are not copied.

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. After a SET_INFO of
the owner with DACL_PRESENT clear and other control flags set, every
query reply returned those flags, for example 0xebf3 for the owner
alone. The replies are now 0x8001 for the owner, 0x8002 for the group
and 0x8004 for the DACL. Replies for descriptors stored with
DACL_PRESENT, 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 | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c
index 7bb28ea195c8..a4a36983852b 100644
--- a/fs/smb/server/smbacl.c
+++ b/fs/smb/server/smbacl.c
@@ -1111,13 +1111,17 @@ int build_sec_desc(const struct mnt_idmap *idmap,
 	pntsd->revision = cpu_to_le16(1);
 	pntsd->type = cpu_to_le16(SELF_RELATIVE);
 	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_DEFAULTED |
-						    DACL_AUTO_INHERITED |
-						    DACL_PROTECTED);
+		u16 flags = 0;
+
+		/* Return the stored flags only of the parts in the reply */
+		if (addition_info & OWNER_SECINFO)
+			flags |= OWNER_DEFAULTED;
+		if (addition_info & GROUP_SECINFO)
+			flags |= GROUP_DEFAULTED;
+		if (addition_info & DACL_SECINFO)
+			flags |= DACL_PRESENT | DACL_DEFAULTED |
+				 DACL_AUTO_INHERITED | DACL_PROTECTED;
+		pntsd->type |= ppntsd->type & cpu_to_le16(flags);
 	}
 
 	if (addition_info & OWNER_SECINFO) {
-- 
2.47.3


                 reply	other threads:[~2026-11-22 16:01 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=20261122160149.403491-1-icb@fastmail.org \
    --to=icb@fastmail.org \
    --cc=chenxiaosong@chenxiaosong.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=senozhatsky@chromium.org \
    --cc=stable@vger.kernel.org \
    --cc=tom@talpey.com \
    /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

all inboxes | Powered by JetHome®