ksmbd: do not read past the DACL in the access denied debug message
Subsystems (3)
PATCH 1/1 ksmbd: do not read past the DACL in the access denied debug message
When smb_check_perm_dacl() falls back to the POSIX ACL and then denies the request, its debug message prints the access mask of the ACE that the second DACL walk stopped at. On that path the walk ran to the end of the DACL, so the pointer is one past the last ACE. If the DACL is the last part of the stored security descriptor, the message reads 4 bytes past the buffer, and KASAN reports a slab-out-of-bounds read in smb_check_perm_dacl().
Print the requested and allowed masks instead. They are what the check compares.
---
Notes:
ksmbd_debug() evaluates its arguments only when SMB debug output is on (/sys/class/ksmbd-control/debug). The 4 bytes go to the kernel log.
Tested on ksmbd-for-next d13da43938d1 with KASAN. With SMB debug enabled, a WRITE_DATA request reaches the POSIX ACL fallback and is denied. Before the fix, the denial triggers a KASAN report. After the fix, the request remains denied and KASAN reports no error. No other access result changes. smbtorture gives the same results as on the base.
A reproducer is available on request.
This fix was developed with LLM assistance.
fs/smb/server/smbacl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/server/smbacl.c +2 -2
@@ -1672,8 +1672,8 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path, }if (granted & ~access_bits) { -ksmbd_debug (SMB ,"Access denied with winACL, granted : %x, access_req : %x\n" , - granted,le32_to_cpu (ace->access_req)); +ksmbd_debug (SMB ,"Access denied with winACL, requested : %x, allowed : %x\n" , + granted, access_bits); rc = -EACCES ; goto err_out; }
base-commit: d13da43938d15b0b719827d8f2b32df8eaec5def
Signature · 1 line
2.47.3
Quoted 9 lines · Ian Bridges
When
smb_check_perm_dacl()falls back to the POSIX ACL and then denies the request, its debug message prints the access mask of the ACE that the second DACL walk stopped at. On that path the walk ran to the end of the DACL, so the pointer is one past the last ACE. If the DACL is the last part of the stored security descriptor, the message reads 4 bytes past the buffer, and KASAN reports a slab-out-of-bounds read insmb_check_perm_dacl().
Quoted 6 lines
Print the requested and allowed masks instead. They are what the check compares.
Fixes e2f34481b24d ("cifsd: add server-side procedures for SMB3")Signed-off-by Ian Bridges <[email protected]>
Applied it to #ksmbd-for-next.
Thanks!