From: Peilin Ye <yepeilin.cs@gmail.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: syzkaller-bugs@googlegroups.com, linux-kernel@vger.kernel.org,
Hans Verkuil <hans.verkuil@cisco.com>,
linux-kernel-mentees@lists.linuxfoundation.org,
Peilin Ye <yepeilin.cs@gmail.com>,
linux-media@vger.kernel.org
Subject: [Linux-kernel-mentees] [PATCH] v4l2-tpg: Fix global-out-of-bounds read in precalculate_color()
Date: Mon, 10 Aug 2020 01:05:32 -0400 [thread overview]
Message-ID: <20200810050532.640075-1-yepeilin.cs@gmail.com> (raw)
precalculate_color() is reading out of `sin` since `tpg->hue` is not being
properly checked. Fix it. `cos` is safe, as long as `tpg->hue` is higher
than or equal to -192.
Fixes: 63881df94d3e ("[media] vivid: add the Test Pattern Generator")
Reported-and-tested-by: syzbot+02d9172bf4c43104cd70@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?id=db50123c788e2cc5a9d90de569c398b66293ee48
Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com>
---
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
index 50f1e0b28b25..52205fe096f7 100644
--- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
+++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
@@ -930,6 +930,9 @@ static void precalculate_color(struct tpg_data *tpg, int k)
/* Implement these operations */
int tmp_cb, tmp_cr;
+ if (tpg->hue < -128 || tpg->hue > 128)
+ return;
+
/* First convert to YCbCr */
color_to_ycbcr(tpg, r, g, b, &y, &cb, &cr);
--
2.25.1
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
next reply other threads:[~2020-08-10 5:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-10 5:05 Peilin Ye [this message]
2020-08-19 14:26 ` [Linux-kernel-mentees] [PATCH] v4l2-tpg: Fix global-out-of-bounds read in precalculate_color() Hans Verkuil
2020-08-19 15:16 ` Peilin Ye
2020-08-21 9:48 ` Peilin Ye
2020-08-21 10:12 ` Hans Verkuil
2020-08-21 10:26 ` Peilin Ye
2020-08-21 12:46 ` [Linux-kernel-mentees] [PATCH v2] vivid: " Peilin Ye
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=20200810050532.640075-1-yepeilin.cs@gmail.com \
--to=yepeilin.cs@gmail.com \
--cc=hans.verkuil@cisco.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).