From: Xi Wang <xi.wang@gmail.com>
To: Mauro Carvalho Chehab <mchehab@infradead.org>,
Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Xi Wang <xi.wang@gmail.com>
Subject: [PATCH 2/2] [media] v4l2-ctrls: fix integer overflow in try_set_ext_ctrls()
Date: Fri, 6 Apr 2012 09:32:37 -0400 [thread overview]
Message-ID: <1333719157-31240-2-git-send-email-xi.wang@gmail.com> (raw)
In-Reply-To: <1333719157-31240-1-git-send-email-xi.wang@gmail.com>
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
prev parent reply other threads:[~2012-04-06 13:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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=1333719157-31240-2-git-send-email-xi.wang@gmail.com \
--to=xi.wang@gmail.com \
--cc=g.liakhovetski@gmx.de \
--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