From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Ricardo Ribalda <ribalda@chromium.org>
Cc: Hans de Goede <hansg@kernel.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Guennadi Liakhovetski <guennadi.liakhovetski@intel.com>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Sinan Turunc <enscrpt@pm.me>,
stable@vger.kernel.org
Subject: Re: [PATCH 1/3] media: uvcvideo: Reject short metadata
Date: Mon, 16 Nov 2026 15:08:39 +0200 [thread overview]
Message-ID: <20261116130839.GA1714298@killaraus.ideasonboard.com> (raw)
In-Reply-To: <20261116-uvc-shortmeta-v1-1-487cfe42fa89@chromium.org>
On Mon, Nov 16, 2026 at 11:56:37AM +0000, Ricardo Ribalda wrote:
> The UVC header has two bits saying whether the packet contains the
> optional PTS or SCR fields.
>
> If the header says that those fields are there, but the header is not
> big enough to hold them, there is something wrong going on and we could
> read out of bounds.
There are multiple checks scattered through the code for this already,
some of them causing the whole data packet to be dropped, others just
short-circuiting operations such as clock and stats updates. Did you ned
see those ? It's getting too messy.
> Mark the metadata as invalid and move on.
>
> Reported-by: Sinan Turunc <enscrpt@pm.me>
> Closes: https://lore.kernel.org/linux-media/20261115121701.189-1-enscrpt@pm.me/
> Fixes: 088ead255245 ("media: uvcvideo: Add a metadata device node")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> drivers/media/usb/uvc/uvc_video.c | 8 ++++++++
> drivers/media/usb/uvc/uvcvideo.h | 1 +
> 2 files changed, 9 insertions(+)
>
> diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> index a92a986ab714..9cc5d83acbc2 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -1487,6 +1487,14 @@ static void uvc_video_decode_meta(struct uvc_streaming *stream,
> if (has_scr)
> len_std += 6;
>
> + if (length < len_std) {
> + uvc_warn_once(stream->dev, UVC_WARN_META_SHORT,
> + "UVC non compliance: payload header length %u is shorter than expected %zu (flags 0x%02x).\n",
> + length, len_std, mem[1]);
> + meta_buf->error = 1;
> + return;
> + }
> +
> if (stream->meta.format == V4L2_META_FMT_UVC)
> length = len_std;
>
> diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
> index af8cef94ffff..59e23e55bc2e 100644
> --- a/drivers/media/usb/uvc/uvcvideo.h
> +++ b/drivers/media/usb/uvc/uvcvideo.h
> @@ -661,6 +661,7 @@ static inline struct uvc_fh *to_uvc_fh(struct file *filp)
> #define UVC_WARN_PROBE_DEF 1
> #define UVC_WARN_XU_GET_RES 2
> #define UVC_WARN_QUERY_CTRL 3
> +#define UVC_WARN_META_SHORT 4
>
> extern unsigned int uvc_clock_param;
> extern unsigned int uvc_no_drop_param;
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2026-11-16 13:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 11:56 [PATCH 0/3] media: uvcvideo: Improve checks for medatata size Ricardo Ribalda
2026-11-16 11:56 ` [PATCH 1/3] media: uvcvideo: Reject short metadata Ricardo Ribalda
2026-11-16 13:08 ` Laurent Pinchart [this message]
2026-11-16 13:23 ` Ricardo Ribalda
2026-11-16 14:06 ` Laurent Pinchart
2026-11-16 11:56 ` [PATCH 2/3] media: uvcvideo: Check header length in uvc_video_clock_decode() Ricardo Ribalda
2026-11-16 13:09 ` Laurent Pinchart
2026-11-16 11:56 ` [PATCH 3/3] media: uvcvideo: Fix unaligned and OOB access Ricardo Ribalda
2026-11-16 14:01 ` Laurent Pinchart
2026-11-16 14:27 ` Ricardo Ribalda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116130839.GA1714298@killaraus.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=enscrpt@pm.me \
--cc=guennadi.liakhovetski@intel.com \
--cc=hansg@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=ribalda@chromium.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®