cifs: proper fix for integer overflow in parse_dacl()
Subsystems (3)
PATCH 1/1 cifs: proper fix for integer overflow in parse_dacl()
I tried to fix this before by adding the ULONG_MAX check, but num_aces is an unsigned int so it should have been UINT_MAX. Sorry for that. These days we can just call kmalloc_array() which has the overflow check built in.
Reported-by pipacs
Signed-off-by Dan Carpenter <[email protected]>
fs/cifs/cifsacl.c +1 -3
@@ -910,9 +910,7 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl,umode_t group_mask =S_IRWXG ;umode_t other_mask =S_IRWXU |S_IRWXG |S_IRWXO ; -if (num_aces >ULONG_MAX /sizeof (struct cifs_ace *)) -return ; - ppace =kmalloc (num_aces *sizeof (struct cifs_ace *), + ppace =kmalloc_array (num_aces,sizeof (struct cifs_ace *),GFP_KERNEL );if (!ppace) {cERROR (1 ,"DACL memory allocation error" );
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 5 lines · Dan Carpenter
I tried to fix this before by adding the
ULONG_MAXcheck, butnum_acesis an unsigned int so it should have beenUINT_MAX. Sorry for that. These days we can just callkmalloc_array()which has the overflow check built in.
Uh... It turns out that I still suck at understanding C. My first patch was fine. Sorry for the noise.
regards,
dan carpenter