lkml.org 
[lkml]   [2020]   [Aug]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[Linux-kernel-mentees] [PATCH] v4l2-tpg: Fix global-out-of-bounds read in precalculate_color()
Date
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
\
 
 \ /
  Last update: 2020-08-10 07:09    [W:0.106 / U:0.752 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site