From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+a828133770f62293563e@syzkaller.appspotmail.com
Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
mchehab@kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [media?] WARNING in __v4l2_ctrl_modify_dimensions
Date: Tue, 3 Sep 2024 10:57:55 +0800 [thread overview]
Message-ID: <tencent_A536BA4B40741D769567D23CF5373096CA09@qq.com> (raw)
In-Reply-To: <000000000000013050062127830a@google.com>
The warning appears because the size passed to kvzalloc is larger than INT_MAX.
Add parameter size check before calling kvzalloc in __v4l2_ctrl_modify_dimensions.
#syz test
diff --git a/drivers/media/v4l2-core/v4l2-ctrls-api.c b/drivers/media/v4l2-core/v4l2-ctrls-api.c
index e5a364efd5e6..0b008cc94901 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls-api.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls-api.c
@@ -986,6 +986,7 @@ int __v4l2_ctrl_modify_dimensions(struct v4l2_ctrl *ctrl,
unsigned int elems = 1;
unsigned int i;
void *p_array;
+ unsigned int bytes;
lockdep_assert_held(ctrl->handler->lock);
@@ -996,7 +997,12 @@ int __v4l2_ctrl_modify_dimensions(struct v4l2_ctrl *ctrl,
elems *= dims[i];
if (elems == 0)
return -EINVAL;
- p_array = kvzalloc(2 * elems * ctrl->elem_size, GFP_KERNEL);
+
+ bytes = 2 * elems * ctrl->elem_size;
+ if (unlikely(bytes > INT_MAX))
+ return -EINVAL;
+
+ p_array = kvzalloc(bytes, GFP_KERNEL);
if (!p_array)
return -ENOMEM;
kvfree(ctrl->p_array);
next prev parent reply other threads:[~2024-09-03 3:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-02 18:57 syzbot
2024-09-03 2:57 ` Edward Adam Davis [this message]
2024-09-03 3:18 ` syzbot
2024-09-03 10:24 ` Hans Verkuil
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=tencent_A536BA4B40741D769567D23CF5373096CA09@qq.com \
--to=eadavis@qq.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=syzbot+a828133770f62293563e@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/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®