Skip to content

Commit

Permalink
media: vivid: Fix global-out-of-bounds read in precalculate_color()
Browse files Browse the repository at this point in the history
vivid_meta_out_process() is setting `brightness`, `contrast`, `saturation`
and `hue` using tpg_s_*(). This is wrong, since tpg_s_*() do not provide
range checks. Using tpg_s_*() here also makes the control framework
out-of-sync with the actual values. Use v4l2_ctrl_s_ctrl() instead.

This issue has been reported by syzbot as an out-of-bounds read bug in
precalculate_color().

Reported-and-tested-by: syzbot+02d9172bf4c43104cd70@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=02d9172bf4c43104cd70

Fixes: 746facd ("media: vivid: Add metadata output support")
Suggested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
  • Loading branch information
Peilin Ye authored and Mauro Carvalho Chehab committed Aug 26, 2020
1 parent 209d926 commit e3158a5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions drivers/media/test-drivers/vivid/vivid-meta-out.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,11 @@ void vivid_meta_out_process(struct vivid_dev *dev,
{
struct vivid_meta_out_buf *meta = vb2_plane_vaddr(&buf->vb.vb2_buf, 0);

tpg_s_brightness(&dev->tpg, meta->brightness);
tpg_s_contrast(&dev->tpg, meta->contrast);
tpg_s_saturation(&dev->tpg, meta->saturation);
tpg_s_hue(&dev->tpg, meta->hue);
v4l2_ctrl_s_ctrl(dev->brightness, meta->brightness);
v4l2_ctrl_s_ctrl(dev->contrast, meta->contrast);
v4l2_ctrl_s_ctrl(dev->saturation, meta->saturation);
v4l2_ctrl_s_ctrl(dev->hue, meta->hue);

dprintk(dev, 2, " %s brightness %u contrast %u saturation %u hue %d\n",
__func__, meta->brightness, meta->contrast,
meta->saturation, meta->hue);
Expand Down

0 comments on commit e3158a5

Please sign in to comment.