* [PATCH] v4l2-ctrls.c/uvc: zero v4l2_event
@ 2018-12-18 13:37 Hans Verkuil
2018-12-18 22:03 ` Laurent Pinchart
0 siblings, 1 reply; 2+ messages in thread
From: Hans Verkuil @ 2018-12-18 13:37 UTC (permalink / raw)
To: Linux Media Mailing List; +Cc: Laurent Pinchart, Kieran Bingham
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
---
For details see: https://syzkaller.appspot.com/bug?extid=4f021cf3697781dbd9fb
---
diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index d45415cbe6e7..14cff91b7aea 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -1212,7 +1212,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;
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index 5e3806feb5d7..8a82427c4d54 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1387,7 +1387,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;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] v4l2-ctrls.c/uvc: zero v4l2_event
2018-12-18 13:37 [PATCH] v4l2-ctrls.c/uvc: zero v4l2_event Hans Verkuil
@ 2018-12-18 22:03 ` Laurent Pinchart
0 siblings, 0 replies; 2+ messages in thread
From: Laurent Pinchart @ 2018-12-18 22:03 UTC (permalink / raw)
To: Hans Verkuil; +Cc: Linux Media Mailing List, Kieran Bingham
Hi Hans,
Thank you for the patch.
On Tuesday, 18 December 2018 15:37:08 EET Hans Verkuil wrote:
> 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.
Indeed :-(
maybe s/it's these/it's only these/ ?
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
I assume you will merge this directly, without a need for me to take the patch
in my UVC branch ?
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> Reported-by: syzbot+4f021cf3697781dbd9fb@syzkaller.appspotmail.com
> ---
> For details see:
> https://syzkaller.appspot.com/bug?extid=4f021cf3697781dbd9fb ---
> diff --git a/drivers/media/usb/uvc/uvc_ctrl.c
> b/drivers/media/usb/uvc/uvc_ctrl.c index d45415cbe6e7..14cff91b7aea 100644
> --- a/drivers/media/usb/uvc/uvc_ctrl.c
> +++ b/drivers/media/usb/uvc/uvc_ctrl.c
> @@ -1212,7 +1212,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;
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c
> b/drivers/media/v4l2-core/v4l2-ctrls.c index 5e3806feb5d7..8a82427c4d54
> 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
> @@ -1387,7 +1387,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;
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-12-18 22:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-18 13:37 [PATCH] v4l2-ctrls.c/uvc: zero v4l2_event Hans Verkuil
2018-12-18 22:03 ` Laurent Pinchart
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.