[PATCH 2/3] media: uvcvideo: Check header length in uvc_video_clock_decode()

From: Ricardo Ribalda

Date: Mon Nov 16 2026 - 06:57:07 EST


In UVC, the header size is defined in data[0]; all the bytes beyond that
length are pixels.

Currently, uvc_video_clock_decode() could parse pixels as PTS/SCR
because it checks the bounds against the USB packet size, not the header
size.

Fix it.

Fixes: 66847ef013cc ("[media] uvcvideo: Add UVC timestamps support")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Ricardo Ribalda <ribalda@xxxxxxxxxxxx>
---
drivers/media/usb/uvc/uvc_video.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 9cc5d83acbc2..e9be0a627033 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -582,8 +582,12 @@ uvc_video_clock_decode(struct uvc_streaming *stream, struct uvc_buffer *buf,
}

/* Check for invalid headers. */
- if (len < header_size)
+ if (len < header_size || data[0] < header_size) {
+ uvc_warn_once(stream->dev, UVC_WARN_META_SHORT,
+ "UVC non compliance: payload header length %u is shorter than expected %u (flags 0x%02x).\n",
+ data[0], header_size, data[1]);
return;
+ }

/*
* Extract the timestamps:

--
2.56.0.679.gc527c65306-goog