Skip to content

Commit 1b8b67f

Browse files
namjaejeonSteve French
authored andcommitted
ksmbd: fix incorrect validation for num_aces field of smb_acl
parse_dcal() validate num_aces to allocate posix_ace_state_array. if (num_aces > ULONG_MAX / sizeof(struct smb_ace *)) It is an incorrect validation that we can create an array of size ULONG_MAX. smb_acl has ->size field to calculate actual number of aces in request buffer size. Use this to check invalid num_aces. Reported-by: Igor Leite Ladessa <[email protected]> Tested-by: Igor Leite Ladessa <[email protected]> Signed-off-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 62e7dd0 commit 1b8b67f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

fs/smb/server/smbacl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,9 @@ static void parse_dacl(struct mnt_idmap *idmap,
398398
if (num_aces <= 0)
399399
return;
400400

401-
if (num_aces > ULONG_MAX / sizeof(struct smb_ace *))
401+
if (num_aces > (le16_to_cpu(pdacl->size) - sizeof(struct smb_acl)) /
402+
(offsetof(struct smb_ace, sid) +
403+
offsetof(struct smb_sid, sub_auth) + sizeof(__le16)))
402404
return;
403405

404406
ret = init_acl_state(&acl_state, num_aces);
@@ -432,6 +434,7 @@ static void parse_dacl(struct mnt_idmap *idmap,
432434
offsetof(struct smb_sid, sub_auth);
433435

434436
if (end_of_acl - acl_base < acl_size ||
437+
ppace[i]->sid.num_subauth == 0 ||
435438
ppace[i]->sid.num_subauth > SID_MAX_SUB_AUTHORITIES ||
436439
(end_of_acl - acl_base <
437440
acl_size + sizeof(__le32) * ppace[i]->sid.num_subauth) ||

0 commit comments

Comments
 (0)