]> git.itanic.dy.fi Git - linux-stable/commitdiff
media: v4l2-ctrls.c/uvc: zero v4l2_event
authorHans Verkuil <hverkuil@xs4all.nl>
Tue, 18 Dec 2018 13:37:08 +0000 (08:37 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Apr 2019 04:22:08 +0000 (06:22 +0200)
commit f45f3f753b0a3d739acda8e311b4f744d82dc52a upstream.

Control events can leak kernel memory since they do not fully zero the
event. The same code is present in both v4l2-ctrls.c and uvc_ctrl.c, so
fix both.

It appears that all other event code is properly zeroing the structure,
it's these two places.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reported-by: syzbot+4f021cf3697781dbd9fb@syzkaller.appspotmail.com
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/usb/uvc/uvc_ctrl.c
drivers/media/v4l2-core/v4l2-ctrls.c

index 618e4e2b42077ff35129aa4cabe8a098b6cc4c40..fea09a33c6c8f44dbf7a16e5cf3fa22cfc0c08ed 100644 (file)
@@ -1202,7 +1202,7 @@ static void uvc_ctrl_fill_event(struct uvc_video_chain *chain,
 
        __uvc_query_v4l2_ctrl(chain, ctrl, mapping, &v4l2_ctrl);
 
-       memset(ev->reserved, 0, sizeof(ev->reserved));
+       memset(ev, 0, sizeof(*ev));
        ev->type = V4L2_EVENT_CTRL;
        ev->id = v4l2_ctrl.id;
        ev->u.ctrl.value = value;
index 2bdb2a3512a4aebb2a94a50dab39bc34f0f49835..0d878e6019f9acf2b1be40834af0f6a5f21ef51f 100644 (file)
@@ -1208,7 +1208,7 @@ static u32 user_flags(const struct v4l2_ctrl *ctrl)
 
 static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 changes)
 {
-       memset(ev->reserved, 0, sizeof(ev->reserved));
+       memset(ev, 0, sizeof(*ev));
        ev->type = V4L2_EVENT_CTRL;
        ev->id = ctrl->id;
        ev->u.ctrl.changes = changes;