All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch -longterm] V4L/DVB: v4l2-ioctl: integer overflow in
@ 2011-12-15  6:34 ` Dan Carpenter
  0 siblings, 0 replies; 20+ messages in thread
From: Dan Carpenter @ 2011-12-15  6:34 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab; +Cc: kernel-janitors, stable

On a 32bit system the multiplication here could overflow.  p->count is
used in some of the V4L drivers.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This is a patch against the 2.6.32-longterm kernel.  In the stock
kernel, this code was totally rewritten and fixed in 2010 by d14e6d76ebf
"[media] v4l: Add multi-planar ioctl handling code".

Hopefully, someone can Ack this and we merge it into the stable tree.

diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index 265bfb5..7196303 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -414,6 +414,9 @@ video_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
 		p->error_idx = p->count;
 		user_ptr = (void __user *)p->controls;
 		if (p->count) {
+			err = -EINVAL;
+			if (p->count > ULONG_MAX / sizeof(struct v4l2_ext_control))
+				goto out_ext_ctrl;
 			ctrls_size = sizeof(struct v4l2_ext_control) * p->count;
 			/* Note: v4l2_ext_controls fits in sbuf[] so mbuf is still NULL. */
 			mbuf = kmalloc(ctrls_size, GFP_KERNEL);
@@ -1912,6 +1915,9 @@ long video_ioctl2(struct file *file,
 		p->error_idx = p->count;
 		user_ptr = (void __user *)p->controls;
 		if (p->count) {
+			err = -EINVAL;
+			if (p->count > ULONG_MAX / sizeof(struct v4l2_ext_control))
+				goto out_ext_ctrl;
 			ctrls_size = sizeof(struct v4l2_ext_control) * p->count;
 			/* Note: v4l2_ext_controls fits in sbuf[] so mbuf is still NULL. */
 			mbuf = kmalloc(ctrls_size, GFP_KERNEL);

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2012-01-05 17:56 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-15  6:34 [patch -longterm] V4L/DVB: v4l2-ioctl: integer overflow in Dan Carpenter
2011-12-15  6:34 ` [patch -longterm] V4L/DVB: v4l2-ioctl: integer overflow in video_usercopy() Dan Carpenter
2011-12-15  9:21 ` Mauro Carvalho Chehab
2011-12-15  9:21   ` Mauro Carvalho Chehab
2011-12-15  9:33   ` Hans Verkuil
2011-12-15  9:33     ` Hans Verkuil
2011-12-15  9:50     ` Mauro Carvalho Chehab
2011-12-15  9:50       ` Mauro Carvalho Chehab
2012-01-03 20:55       ` [patch -longterm] V4L/DVB: v4l2-ioctl: integer overflow in Greg KH
2012-01-03 20:55         ` [patch -longterm] V4L/DVB: v4l2-ioctl: integer overflow in video_usercopy() Greg KH
2012-01-04 13:35         ` [patch -longterm] V4L/DVB: v4l2-ioctl: integer overflow in Dan Carpenter
2012-01-04 13:35           ` [patch -longterm] V4L/DVB: v4l2-ioctl: integer overflow in video_usercopy() Dan Carpenter
2012-01-05  6:27         ` [patch -next] V4L/DVB: v4l2-ioctl: integer overflow in Dan Carpenter
2012-01-05  6:27           ` [patch -next] V4L/DVB: v4l2-ioctl: integer overflow in video_usercopy() Dan Carpenter
2012-01-05  6:28         ` [patch -longterm v2] V4L/DVB: v4l2-ioctl: integer overflow in Dan Carpenter
2012-01-05  6:28           ` [patch -longterm v2] V4L/DVB: v4l2-ioctl: integer overflow in video_usercopy() Dan Carpenter
2012-01-05 16:43           ` [patch -longterm v2] V4L/DVB: v4l2-ioctl: integer overflow in Greg KH
2012-01-05 16:43             ` [patch -longterm v2] V4L/DVB: v4l2-ioctl: integer overflow in video_usercopy() Greg KH
2012-01-05 17:56             ` [patch -longterm v2] V4L/DVB: v4l2-ioctl: integer overflow in Dan Carpenter
2012-01-05 17:56               ` [patch -longterm v2] V4L/DVB: v4l2-ioctl: integer overflow in video_usercopy() Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.