* [patch] cifs: proper fix for integer overflow in parse_dacl()
@ 2012-09-27 20:49 Dan Carpenter
[not found] ` <20120927204908.GA13222-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2012-09-27 20:49 UTC (permalink / raw)
To: Steve French; +Cc: linux-cifs, kernel-janitors, samba-technical
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 <dan.carpenter@oracle.com>
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index 2ee5c54..bc9fcfb 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -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");
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [patch] cifs: proper fix for integer overflow in parse_dacl()
[not found] ` <20120927204908.GA13222-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
@ 2012-10-03 12:43 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2012-10-03 12:43 UTC (permalink / raw)
To: Steve French
Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA,
samba-technical-w/Ol4Ecudpl8XjKLYN78aQ,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA
On Thu, Sep 27, 2012 at 11:49:08PM +0300, Dan Carpenter wrote:
> 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.
>
Uh... It turns out that I still suck at understanding C. My first
patch was fine. Sorry for the noise.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-10-03 12:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-27 20:49 [patch] cifs: proper fix for integer overflow in parse_dacl() Dan Carpenter
[not found] ` <20120927204908.GA13222-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
2012-10-03 12:43 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox