ksmbd: return only the control flags of the parts in a query reply
Subsystems (3)
PATCH 1/1 ksmbd: return only the control flags of the parts in a query reply
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.
---
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(-)
fs/smb/server/smbacl.c +11 -7
@@ -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 ) {
Signature · 1 line
2.47.3
Quoted 15 lines · Ian Bridges
build_sec_desc()copies the stored control flags into the query reply and clears only the DACL flags when the DACL is not requested. ASET_INFOwithoutDACL_PRESENTstores the control word as the client sent it. Its other flags then appear in every reply, such asOWNER_DEFAULTEDin a reply without the owner, andSACL_PRESENTalthough 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_DEFAULTEDgoes with the owner andGROUP_DEFAULTEDwith the group.DACL_PRESENT,DACL_DEFAULTED,DACL_AUTO_INHERITEDandDACL_PROTECTEDgo with the DACL. The SACL flags and the other stored bits, such asSERVER_SECURITYandRM_CONTROL_VALID, are not copied.
Quoted 3 lines
Fixes e2f34481b24d ("cifsd: add server-side procedures for SMB3")Signed-off-by Ian Bridges <[email protected]>
Applied it to #ksmbd-for-next.
Thanks!