[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1333719157-31240-1-git-send-email-xi.wang@gmail.com>
Date: Fri, 6 Apr 2012 09:32:36 -0400
From: Xi Wang <xi.wang@...il.com>
To: Mauro Carvalho Chehab <mchehab@...radead.org>,
Guennadi Liakhovetski <g.liakhovetski@....de>
Cc: linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
Xi Wang <xi.wang@...il.com>
Subject: [PATCH 1/2] [media] v4l2-ctrls: fix integer overflow in v4l2_g_ext_ctrls()
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@...il.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists