[PATCH] ksmbd: fix maximal access leak when object has no NT ACL
"Gaƫl Blivet-Bailly" <[email protected]> Fri, 17 Jul 2026 09:15:04 +0200
| Newsgroups | org.kernel.vger.linux-cifs |
|---|---|
| Message-ID | <[email protected]> |
From: Gael Blivet <[email protected]> smb2_open()'s maximal-access handling sets maximal_access to the FILE_MAXIMAL_ACCESS_LE request sentinel, then calls smb_check_perm_dacl() to compute the real access mask from the object's DACL. smb_check_perm_dacl() returns success without touching *pdaccess when the object has no stored NT ACL xattr (ksmbd_vfs_get_sd_xattr() fails, taking an early goto err_out with rc still 0). This leaves maximal_access holding the raw FILE_MAXIMAL_ACCESS_LE sentinel instead of a real access mask. Observed live: a freshly-created share root shows macOS's "no entry" (prohibited-access) badge on connect, even though POSIX permissions clearly allow access -- macOS requests maximal access via the MxAc create context on every share-root open, not via DesiredAccess, so it trusts the leaked sentinel verbatim instead of falling through to the correct POSIX-based path. Fall back to ksmbd_vfs_query_maximal_access() -- the same POSIX-based computation already used for the DesiredAccess-requested-maximal-access case below -- whenever the sentinel comes back unmodified. Signed-off-by: Gael Blivet <[email protected]> Assisted-by: Claude:claude-sonnet-5 --- fs/smb/server/smb2pdu.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c index 602b60417..1a9009025 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -4156,6 +4156,17 @@ int smb2_open(struct ksmbd_work *work) 0, sess->user->uid, false); if (rc) goto err_out; + + /* + * smb_check_perm_dacl() returns success without + * touching *pdaccess when the object has no stored + * NT ACL, leaving maximal_access as the + * FILE_MAXIMAL_ACCESS_LE request sentinel instead of + * a real access mask. + */ + if (maximal_access == FILE_MAXIMAL_ACCESS_LE) + ksmbd_vfs_query_maximal_access(idmap, path.dentry, + &maximal_access); } } base-commit: b0532660f76e08c75143d9d030a9e8c4f2e2bb1e -- 2.43.0