* [patch] gdth: integer overflow in ioctl
@ 2010-10-08 7:03 Dan Carpenter
2010-10-21 7:29 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2010-10-08 7:03 UTC (permalink / raw)
To: Achim Leubner
Cc: James E.J. Bottomley, linux-scsi, linux-kernel, kernel-janitors
gdth_ioctl_alloc() takes the size variable as an int.
copy_from_user() takes the size variable as an unsigned long.
gen.data_len and gen.sense_len are unsigned longs.
On x86_64 longs are 64 bit and ints are 32 bit.
We could pass in a very large number and the allocation would truncate
the size to 32 bits and allocate a small buffer. Then when we do the
copy_from_user(), it would result in a memory corruption.
CC: stable@kernel.org
Signed-off-by: Dan Carpenter <error27@gmail.com>
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index b860d65..4cf7ffa 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -4175,6 +4175,14 @@ static int ioc_general(void __user *arg, char *cmnd)
ha = gdth_find_ha(gen.ionode);
if (!ha)
return -EFAULT;
+
+ if (gen.data_len > INT_MAX)
+ return -EINVAL;
+ if (gen.sense_len > INT_MAX)
+ return -EINVAL;
+ if (gen.data_len + gen.sense_len > INT_MAX)
+ return -EINVAL;
+
if (gen.data_len + gen.sense_len != 0) {
if (!(buf = gdth_ioctl_alloc(ha, gen.data_len + gen.sense_len,
FALSE, &paddr)))
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [patch] gdth: integer overflow in ioctl
2010-10-08 7:03 [patch] gdth: integer overflow in ioctl Dan Carpenter
@ 2010-10-21 7:29 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2010-10-21 7:29 UTC (permalink / raw)
To: Achim Leubner, James E.J. Bottomley, linux-scsi, linux-kernel,
kernel-janitors
On Fri, Oct 08, 2010 at 09:03:07AM +0200, Dan Carpenter wrote:
> gdth_ioctl_alloc() takes the size variable as an int.
> copy_from_user() takes the size variable as an unsigned long.
> gen.data_len and gen.sense_len are unsigned longs.
> On x86_64 longs are 64 bit and ints are 32 bit.
>
> We could pass in a very large number and the allocation would truncate
> the size to 32 bits and allocate a small buffer. Then when we do the
> copy_from_user(), it would result in a memory corruption.
>
> CC: stable@kernel.org
> Signed-off-by: Dan Carpenter <error27@gmail.com>
>
I never know if anyone gets my emails and so I has a small sad face on
the front of my head here: ---------------> :(
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-10-21 7:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-08 7:03 [patch] gdth: integer overflow in ioctl Dan Carpenter
2010-10-21 7:29 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).