From: Haogang Chen <haogangchen@gmail.com>
To: laurent.pinchart@ideasonboard.com, mchehab@infradead.org
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Haogang Chen <haogangchen@gmail.com>
Subject: [PATCH] Media: video: uvc: integer overflow in uvc_ioctl_ctrl_map()
Date: Tue, 29 Nov 2011 16:32:25 -0500 [thread overview]
Message-ID: <1322602345-26279-1-git-send-email-haogangchen@gmail.com> (raw)
There is a potential integer overflow in uvc_ioctl_ctrl_map(). When a
large xmap->menu_count is passed from the userspace, the subsequent call
to kmalloc() will allocate a buffer smaller than expected.
map->menu_count and map->menu_info would later be used in a loop (e.g.
in uvc_query_v4l2_ctrl), which leads to out-of-bound access.
The patch checks the ioctl argument and returns -EINVAL for zero or too
large values in xmap->menu_count.
Signed-off-by: Haogang Chen <haogangchen@gmail.com>
---
drivers/media/video/uvc/uvc_v4l2.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c
index dadf11f..9a180d6 100644
--- a/drivers/media/video/uvc/uvc_v4l2.c
+++ b/drivers/media/video/uvc/uvc_v4l2.c
@@ -58,6 +58,12 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,
break;
case V4L2_CTRL_TYPE_MENU:
+ if (xmap->menu_count == 0 ||
+ xmap->menu_count > INT_MAX / sizeof(*map->menu_info)) {
+ kfree(map);
+ return -EINVAL;
+ }
+
size = xmap->menu_count * sizeof(*map->menu_info);
map->menu_info = kmalloc(size, GFP_KERNEL);
if (map->menu_info == NULL) {
--
1.7.5.4
next reply other threads:[~2011-11-29 21:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-29 21:32 Haogang Chen [this message]
2011-11-30 1:22 ` Laurent Pinchart
2011-11-30 2:28 ` Haogang Chen
2011-11-30 9:14 ` Laurent Pinchart
2011-12-11 10:22 ` Mauro Carvalho Chehab
2011-12-11 10:31 ` Laurent Pinchart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1322602345-26279-1-git-send-email-haogangchen@gmail.com \
--to=haogangchen@gmail.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®