[PATCH 3/3] media: uvcvideo: Fix unaligned and OOB access
From: Ricardo Ribalda
Date: Mon Nov 16 2026 - 06:56:59 EST
meta->buf and scr point to packed metadata and USB packet memory that do
not need to be aligned to anything. Also, scr + 4 is a 16-bit field, so
reading it as a u32 reads 2 bytes out of bounds.
We use *_unaligned() in the rest of uvc_video_decode_meta(), but not in
the debug print.
Fix this.
Fixes: 088ead255245 ("media: uvcvideo: Add a metadata device node")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Ricardo Ribalda <ribalda@xxxxxxxxxxxx>
---
drivers/media/usb/uvc/uvc_video.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index e9be0a627033..3e3296ec5c65 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -1532,9 +1532,9 @@ static void uvc_video_decode_meta(struct uvc_streaming *stream,
"%s(): t-sys %lluns, SOF %u, len %u, flags 0x%x, PTS %u, STC %u frame SOF %u\n",
__func__, ktime_to_ns(time), meta->sof, meta->length,
meta->flags,
- has_pts ? *(u32 *)meta->buf : 0,
- has_scr ? *(u32 *)scr : 0,
- has_scr ? *(u32 *)(scr + 4) & 0x7ff : 0);
+ has_pts ? get_unaligned_le32(meta->buf) : 0,
+ has_scr ? get_unaligned_le32(scr) : 0,
+ has_scr ? get_unaligned_le16(scr + 4) & 0x7ff : 0);
}
/* ------------------------------------------------------------------------
--
2.56.0.679.gc527c65306-goog