* Buffer overflow in uvc-video.
@ 2008-09-20 8:12 Ralph Loader
2008-09-22 13:22 ` [Linux-uvc-devel] " Laurent Pinchart
0 siblings, 1 reply; 2+ messages in thread
From: Ralph Loader @ 2008-09-20 8:12 UTC (permalink / raw)
To: linux-uvc-devel; +Cc: linux-kernel
Hi,
There appears to be a buffer overflow in
drivers/media/video/uvc/uvc_ctrl.c:
Sep 20 17:53:12 i kernel: BUG kmalloc-8 (Not tainted): Redzone
overwritten Sep 20 17:53:12 i kernel:
--------------------------------------------------------------------
--------- Sep 20 17:53:12 i kernel:
Sep 20 17:53:12 i kernel: INFO: 0xf2c5ce08-0xf2c5ce0b. First byte 0xa1
instead of 0xcc
Sep 20 17:53:12 i kernel: INFO: Allocated in
uvc_query_v4l2_ctrl+0x3c/0x239 [uvcvideo] age=13 cpu=1 pid=4975
...
A fixed size 8-byte buffer is allocated, and a variable size field is
read into it; there is no particular bound on the size of the field
(it is dependent on hardware and configuration) and it can overflow
[also verified by inserting printk's.]
The patch below attempts to size the buffer to the correctly; I do not
know if sufficient validation of that size is carried out.
Cheers,
Ralph Loader.
diff --git a/drivers/media/video/uvc/uvc_ctrl.c
b/drivers/media/video/uvc/uvc_ct rl.c
index 6ef3e52..feab12a 100644
--- a/drivers/media/video/uvc/uvc_ctrl.c
+++ b/drivers/media/video/uvc/uvc_ctrl.c
@@ -592,7 +592,7 @@ int uvc_query_v4l2_ctrl(struct uvc_video_device
*video, if (ctrl == NULL)
return -EINVAL;
- data = kmalloc(8, GFP_KERNEL);
+ data = kmalloc(ctrl->info->size, GFP_KERNEL);
if (data == NULL)
return -ENOMEM;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Linux-uvc-devel] Buffer overflow in uvc-video.
2008-09-20 8:12 Buffer overflow in uvc-video Ralph Loader
@ 2008-09-22 13:22 ` Laurent Pinchart
0 siblings, 0 replies; 2+ messages in thread
From: Laurent Pinchart @ 2008-09-22 13:22 UTC (permalink / raw)
To: linux-uvc-devel; +Cc: Ralph Loader, linux-kernel
Hi Ralph,
On Saturday 20 September 2008, Ralph Loader wrote:
> Hi,
>
> There appears to be a buffer overflow in
> drivers/media/video/uvc/uvc_ctrl.c:
>
> Sep 20 17:53:12 i kernel: BUG kmalloc-8 (Not tainted): Redzone
> overwritten Sep 20 17:53:12 i kernel:
> --------------------------------------------------------------------
> --------- Sep 20 17:53:12 i kernel:
> Sep 20 17:53:12 i kernel: INFO: 0xf2c5ce08-0xf2c5ce0b. First byte 0xa1
> instead of 0xcc
> Sep 20 17:53:12 i kernel: INFO: Allocated in
> uvc_query_v4l2_ctrl+0x3c/0x239 [uvcvideo] age=13 cpu=1 pid=4975
> ...
>
>
> A fixed size 8-byte buffer is allocated, and a variable size field is
> read into it; there is no particular bound on the size of the field
> (it is dependent on hardware and configuration) and it can overflow
> [also verified by inserting printk's.]
Thanks for catching this.
> The patch below attempts to size the buffer to the correctly; I do not
> know if sufficient validation of that size is carried out.
UVC control sizes come either from the predefined controls (uvc_ctrls in
uvc_ctrl.c) or from user-defined controls.
Predefined controls size doesn't need any validation. User-defined controls
size should be validated, but defining a new UVC control from userspace
requires root privileges. This currently mitigates the issue. I'll submit a
patch with an upper bound check on the size.
> Cheers,
> Ralph Loader.
>
> diff --git a/drivers/media/video/uvc/uvc_ctrl.c
> b/drivers/media/video/uvc/uvc_ct rl.c
> index 6ef3e52..feab12a 100644
> --- a/drivers/media/video/uvc/uvc_ctrl.c
> +++ b/drivers/media/video/uvc/uvc_ctrl.c
> @@ -592,7 +592,7 @@ int uvc_query_v4l2_ctrl(struct uvc_video_device
> *video, if (ctrl == NULL)
> return -EINVAL;
>
> - data = kmalloc(8, GFP_KERNEL);
> + data = kmalloc(ctrl->info->size, GFP_KERNEL);
> if (data == NULL)
> return -ENOMEM;
Laurent Pinchart
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-09-22 13:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-20 8:12 Buffer overflow in uvc-video Ralph Loader
2008-09-22 13:22 ` [Linux-uvc-devel] " Laurent Pinchart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®