Skip to content

Commit 2aca774

Browse files
namjaejeonvijay-suman
authored andcommitted
ksmbd: fix incorrect validation for num_aces field of smb_acl
[ Upstream commit 1b8b67f ] 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]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit c3a3484d9d31b27a3db0fab91fcf191132d65236) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent e356fb8 commit 2aca774

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

fs/ksmbd/smbacl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,9 @@ static void parse_dacl(struct user_namespace *user_ns,
396396
if (num_aces <= 0)
397397
return;
398398

399-
if (num_aces > ULONG_MAX / sizeof(struct smb_ace *))
399+
if (num_aces > (le16_to_cpu(pdacl->size) - sizeof(struct smb_acl)) /
400+
(offsetof(struct smb_ace, sid) +
401+
offsetof(struct smb_sid, sub_auth) + sizeof(__le16)))
400402
return;
401403

402404
ret = init_acl_state(&acl_state, num_aces);
@@ -430,6 +432,7 @@ static void parse_dacl(struct user_namespace *user_ns,
430432
offsetof(struct smb_sid, sub_auth);
431433

432434
if (end_of_acl - acl_base < acl_size ||
435+
ppace[i]->sid.num_subauth == 0 ||
433436
ppace[i]->sid.num_subauth > SID_MAX_SUB_AUTHORITIES ||
434437
(end_of_acl - acl_base <
435438
acl_size + sizeof(__le32) * ppace[i]->sid.num_subauth) ||

0 commit comments

Comments
 (0)