linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] [media] v4l2-ctrls: fix integer overflow in v4l2_g_ext_ctrls()
@ 2012-04-06 13:32 Xi Wang
  2012-04-06 13:32 ` [PATCH 2/2] [media] v4l2-ctrls: fix integer overflow in try_set_ext_ctrls() Xi Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Xi Wang @ 2012-04-06 13:32 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Guennadi Liakhovetski
  Cc: linux-media, linux-kernel, Xi Wang

A large cs->count from userspace may overflow the allocation size,
leading to memory corruption.  v4l2_g_ext_ctrls() can be reached
from subdev_do_ioctl() or __video_do_ioctl().

Use kmalloc_array() to avoid the overflow.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
---
 drivers/media/video/v4l2-ctrls.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 18015c0..f355fd5 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -1996,7 +1996,8 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *cs
 		return class_check(hdl, cs->ctrl_class);
 
 	if (cs->count > ARRAY_SIZE(helper)) {
-		helpers = kmalloc(sizeof(helper[0]) * cs->count, GFP_KERNEL);
+		helpers = kmalloc_array(cs->count, sizeof(helper[0]),
+					GFP_KERNEL);
 		if (helpers == NULL)
 			return -ENOMEM;
 	}
-- 
1.7.5.4


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

* [PATCH 2/2] [media] v4l2-ctrls: fix integer overflow in try_set_ext_ctrls()
  2012-04-06 13:32 [PATCH 1/2] [media] v4l2-ctrls: fix integer overflow in v4l2_g_ext_ctrls() Xi Wang
@ 2012-04-06 13:32 ` Xi Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Xi Wang @ 2012-04-06 13:32 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Guennadi Liakhovetski
  Cc: linux-media, linux-kernel, Xi Wang

A large cs->count from userspace may overflow the allocation size,
leading to memory corruption.  try_set_ext_ctrls() can be reached
from subdev_do_ioctl() or __video_do_ioctl().

Use kmalloc_array() to avoid the overflow.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
---
 drivers/media/video/v4l2-ctrls.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index f355fd5..6f38a5d 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -2219,7 +2219,8 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
 		return class_check(hdl, cs->ctrl_class);
 
 	if (cs->count > ARRAY_SIZE(helper)) {
-		helpers = kmalloc(sizeof(helper[0]) * cs->count, GFP_KERNEL);
+		helpers = kmalloc_array(cs->count, sizeof(helper[0]),
+					GFP_KERNEL);
 		if (!helpers)
 			return -ENOMEM;
 	}
-- 
1.7.5.4


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

end of thread, other threads:[~2012-04-06 13:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-06 13:32 [PATCH 1/2] [media] v4l2-ctrls: fix integer overflow in v4l2_g_ext_ctrls() Xi Wang
2012-04-06 13:32 ` [PATCH 2/2] [media] v4l2-ctrls: fix integer overflow in try_set_ext_ctrls() Xi Wang

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).