Skip to content

Commit 3531733

Browse files
committedFeb 18, 2025·
ksmbd: fix2
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
1 parent 0d15ae2 commit 3531733

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed
 

‎smbacl.c

+12-3
Original file line numberDiff line numberDiff line change
@@ -899,11 +899,20 @@ static void set_mode_dacl(struct user_namespace *user_ns,
899899

900900
static int parse_sid(struct smb_sid *psid, char *end_of_acl)
901901
{
902-
char *acl_base = (char *)psid;
902+
/*
903+
* validate that we do not go past end of ACL - sid must be at least 8
904+
* bytes long (assuming no sub-auths - e.g. the null SID
905+
*/
906+
if (end_of_acl < (char *)psid + 8) {
907+
pr_err("ACL too small to parse SID %p\n", psid);
908+
return -EINVAL;
909+
}
910+
911+
if (!psid->num_subauth)
912+
return 0;
903913

904914
if (psid->num_subauth > SID_MAX_SUB_AUTHORITIES ||
905-
(end_of_acl - acl_base <
906-
offsetof(struct smb_sid, sub_auth) + sizeof(__le32) * psid->num_subauth))
915+
end_of_acl < (char *)psid + 8 + sizeof(__le32) * psid->num_subauth)
907916
return -EINVAL;
908917

909918
return 0;

0 commit comments

Comments
 (0)
Please sign in to comment.