mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] media: uvcvideo: Fix NULL deref on events for uninitialized controls
@ 2026-09-07 12:18 Wei Jie LAW
  2026-09-29 15:13 ` Hans de Goede
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Jie LAW @ 2026-09-07 12:18 UTC (permalink / raw)
  To: laurent.pinchart, hansg, mchehab
  Cc: Wei Jie Law, guennadi.liakhovetski, linux-media, linux-kernel,
	stable, ribalda

From: Wei Jie Law <98lawweijie@gmail.com>

A null-ptr-deref exists in v6.12.105 and upstream. KASAN crash log:

  KASAN: null-ptr-deref in range [0x0000000000000080-0x0000000000000087]
  Workqueue: events uvc_ctrl_status_event_work
  RIP: 0010:uvc_ctrl_status_event+0x105/0x280
   uvc_ctrl_status_event_work+0x82/0x240
   process_one_work+0x66f/0x10b0

XU controls are initialized lazily, on the first UVCIOC_CTRL_MAP or
UVCIOC_CTRL_QUERY.  Until then ctrl->info is all zeroes, so
info.mappings is not a valid list head, list_empty() returns false, and
uvc_ctrl_status_event() walks it from a NULL next pointer.

Fixes: e5225c820c05 ("media: uvcvideo: Send a control event when a Control Change interrupt arrives")
Cc: stable@vger.kernel.org
Signed-off-by: Wei Jie Law <98lawweijie@gmail.com>
Assisted-by: Claude:claude-opus-5
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>

---
Changes in v2:
- dropped comments in code based on review received
- add Reviewed-by from Ricardo Ribalda
- drop the former [2/2] patch as it is a duplicate (out-of-bounds read in
  uvc_ctrl_status_event()): already handled by
  https://lore.kernel.org/linux-media/20260813-uvc-status-11-v1-1-2cf43e9590b0@chromium.org/

v1: https://lore.kernel.org/all/20260907062819.2519878-2-98lawweijie@gmail.com/
---
 drivers/media/usb/uvc/uvc_ctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index 3ca108b83f1d..ea28c4e819bd 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -2209,7 +2209,7 @@ bool uvc_ctrl_status_event_async(struct urb *urb, struct uvc_video_chain *chain,
 	struct uvc_device *dev = chain->dev;
 	struct uvc_ctrl_work *w = &dev->async_ctrl;
 
-	if (list_empty(&ctrl->info.mappings))
+	if (!ctrl->initialized || list_empty(&ctrl->info.mappings))
 		return false;
 
 	w->data = data;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] media: uvcvideo: Fix NULL deref on events for uninitialized controls
  2026-09-07 12:18 [PATCH v2] media: uvcvideo: Fix NULL deref on events for uninitialized controls Wei Jie LAW
@ 2026-09-29 15:13 ` Hans de Goede
  0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2026-09-29 15:13 UTC (permalink / raw)
  To: Wei Jie LAW, laurent.pinchart, mchehab
  Cc: guennadi.liakhovetski, linux-media, linux-kernel, stable, ribalda

Hi,

On 7-Sep-26 14:18, Wei Jie LAW wrote:
> From: Wei Jie Law <98lawweijie@gmail.com>
> 
> A null-ptr-deref exists in v6.12.105 and upstream. KASAN crash log:
> 
>   KASAN: null-ptr-deref in range [0x0000000000000080-0x0000000000000087]
>   Workqueue: events uvc_ctrl_status_event_work
>   RIP: 0010:uvc_ctrl_status_event+0x105/0x280
>    uvc_ctrl_status_event_work+0x82/0x240
>    process_one_work+0x66f/0x10b0
> 
> XU controls are initialized lazily, on the first UVCIOC_CTRL_MAP or
> UVCIOC_CTRL_QUERY.  Until then ctrl->info is all zeroes, so
> info.mappings is not a valid list head, list_empty() returns false, and
> uvc_ctrl_status_event() walks it from a NULL next pointer.
> 
> Fixes: e5225c820c05 ("media: uvcvideo: Send a control event when a Control Change interrupt arrives")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wei Jie Law <98lawweijie@gmail.com>
> Assisted-by: Claude:claude-opus-5
> Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>

Thank you for your patch.

I have merged this into:

https://gitlab.freedesktop.org/linux-media/users/uvc/-/commits/for-next/

Regards,

Hans



> 
> ---
> Changes in v2:
> - dropped comments in code based on review received
> - add Reviewed-by from Ricardo Ribalda
> - drop the former [2/2] patch as it is a duplicate (out-of-bounds read in
>   uvc_ctrl_status_event()): already handled by
>   https://lore.kernel.org/linux-media/20260813-uvc-status-11-v1-1-2cf43e9590b0@chromium.org/
> 
> v1: https://lore.kernel.org/all/20260907062819.2519878-2-98lawweijie@gmail.com/
> ---
>  drivers/media/usb/uvc/uvc_ctrl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
> index 3ca108b83f1d..ea28c4e819bd 100644
> --- a/drivers/media/usb/uvc/uvc_ctrl.c
> +++ b/drivers/media/usb/uvc/uvc_ctrl.c
> @@ -2209,7 +2209,7 @@ bool uvc_ctrl_status_event_async(struct urb *urb, struct uvc_video_chain *chain,
>  	struct uvc_device *dev = chain->dev;
>  	struct uvc_ctrl_work *w = &dev->async_ctrl;
>  
> -	if (list_empty(&ctrl->info.mappings))
> +	if (!ctrl->initialized || list_empty(&ctrl->info.mappings))
>  		return false;
>  
>  	w->data = data;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-29 15:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-07 12:18 [PATCH v2] media: uvcvideo: Fix NULL deref on events for uninitialized controls Wei Jie LAW
2026-09-29 15:13 ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®