Skip to content

Commit eeb827f

Browse files
namjaejeonSteve French
authored andcommitted
cifs: add validation check for the fields in smb_aces
cifs.ko is missing validation check when accessing smb_aces. This patch add validation check for the fields in smb_aces. Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 1821e90 commit eeb827f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

fs/smb/client/cifsacl.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,23 @@ static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl,
811811
return;
812812

813813
for (i = 0; i < num_aces; ++i) {
814+
if (end_of_acl - acl_base < acl_size)
815+
break;
816+
814817
ppace[i] = (struct smb_ace *) (acl_base + acl_size);
818+
acl_base = (char *)ppace[i];
819+
acl_size = offsetof(struct smb_ace, sid) +
820+
offsetof(struct smb_sid, sub_auth);
821+
822+
if (end_of_acl - acl_base < acl_size ||
823+
ppace[i]->sid.num_subauth == 0 ||
824+
ppace[i]->sid.num_subauth > SID_MAX_SUB_AUTHORITIES ||
825+
(end_of_acl - acl_base <
826+
acl_size + sizeof(__le32) * ppace[i]->sid.num_subauth) ||
827+
(le16_to_cpu(ppace[i]->size) <
828+
acl_size + sizeof(__le32) * ppace[i]->sid.num_subauth))
829+
break;
830+
815831
#ifdef CONFIG_CIFS_DEBUG2
816832
dump_ace(ppace[i], end_of_acl);
817833
#endif
@@ -855,7 +871,6 @@ static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl,
855871
(void *)ppace[i],
856872
sizeof(struct smb_ace)); */
857873

858-
acl_base = (char *)ppace[i];
859874
acl_size = le16_to_cpu(ppace[i]->size);
860875
}
861876

0 commit comments

Comments
 (0)