ksmbd: check the ACEs after an NFS mode ACE in a DACL
Subsystems (3)
PATCH 1/1 ksmbd: check the ACEs after an NFS mode ACE in a DACL
An allow ACE with SID S-1-5-88-3-<mode> supplies the POSIX mode directly, and parse_dacl() stops walking the ACEs at the first one. The same walk checks each ACE and maps its generic rights, so the ACEs after the NFS mode ACE are neither checked nor mapped. set_info_sec() still stores the entire DACL and the request succeeds, but part of that DACL can have no effect.
Continue checking the remaining ACEs and mapping their generic rights, while preserving the mode from the first NFS mode ACE.
---
Without this patch, an ACE allowing GENERIC_READ after the NFS mode ACE grants no access, because the right stays unmapped. A malformed ACE after the NFS mode ACE is stored instead of being refused. The access check and QUERY stop at it, so the ACEs after it are neither applied nor returned.
Tested on ksmbd-for-next 2ef9bd9fa819 with KASAN. CREATE now rejects a malformed ACE after an NFS mode ACE with STATUS_INVALID_PARAMETER. GENERIC_READ in a later ACE is stored as the mapped rights, 0x120089, and now grants read access. Other tested descriptors are stored unchanged, and smbtorture results match the base.
This patch was developed with LLM assistance.
fs/smb/server/smbacl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/smb/server/smbacl.c +6 -1
@@ -401,6 +401,7 @@ static int parse_dacl(const struct mnt_idmap *idmap,struct posix_acl_state acl_state, default_acl_state;umode_t mode =0 , acl_mode;bool owner_found = false, group_found = false, others_found = false; +bool nfs_mode_found = false;if (!pdacl)return 0 ;
@@ -479,13 +480,17 @@ static int parse_dacl(const struct mnt_idmap *idmap, ppace[i]->access_req =smb_map_generic_desired_access (ppace[i]->access_req); +/* ACEs after an NFS mode ACE do not change the POSIX mapping */ +if (nfs_mode_found) +continue ; +if (ppace[i]->type ==ACCESS_ALLOWED && ppace[i]->sid.num_subauth >=3 && !(compare_sids (&ppace[i]->sid, &sid_unix_NFS_mode))) { fattr->cf_mode =le32_to_cpu (ppace[i]->sid.sub_auth[2 ]); fattr->cf_posix_mode = true; -break ; + nfs_mode_found = true; }else if (!compare_sids (&ppace[i]->sid, pownersid)) { acl_mode = access_flags_to_mode(fattr, ppace[i]->access_req,
Signature · 1 line
2.47.3
Quoted 8 lines · Ian Bridges
An allow ACE with SID S-1-5-88-3-<mode> supplies the POSIX mode directly, and
parse_dacl()stops walking the ACEs at the first one. The same walk checks each ACE and maps its generic rights, so the ACEs after the NFS mode ACE are neither checked nor mapped.set_info_sec()still stores the entire DACL and the request succeeds, but part of that DACL can have no effect.
Quoted 6 lines
Continue checking the remaining ACEs and mapping their generic rights, while preserving the mode from the first NFS mode ACE.
Fixes e2f34481b24d ("cifsd: add server-side procedures for SMB3")Signed-off-by Ian Bridges <[email protected]>
Applied it to #ksmbd-for-next.
Thanks!