From: Natasha Klaus <natalie.klaus@runtimeverification.com>
To: laurent.pinchart@ideasonboard.com, hansg@kernel.org, mchehab@kernel.org
Cc: ribalda@chromium.org, noambs2999@gmail.com,
david.laight.linux@gmail.com, linux-media@vger.kernel.org,
linux-kernel@vger.kernel.org,
Natasha Klaus <natalie.klaus@runtimeverification.com>
Subject: [PATCH 0/3] media: uvcvideo: harden the frame buffer size computation
Date: Thu, 20 Aug 2026 12:56:23 +0300 [thread overview]
Message-ID: <20260820095626.111196-1-natalie.klaus@runtimeverification.com> (raw)
uvc_parse_frame() recomputes dwMaxVideoFrameBufferSize for uncompressed
formats from three descriptor fields that nothing validates. The product
is evaluated in 32-bit signed arithmetic, so it wraps, and the driver
stores a size that is usually far too small and sometimes exactly zero.
Noam Ben Shimon reported and fixed the overflow. Reviewing it surfaced a
second route to a zero size, and Ricardo Ribalda asked for a series
rather than two independent patches, so the two cases are not handled
inconsistently.
1/3 changes the return convention of uvc_parse_frame() so it can
report "skip this frame descriptor" separately from a fatal
error. Suggested by Ricardo.
2/3 Noam's overflow check, adapted to skip rather than reject, with
DIV_ROUND_UP and the operand values in the diagnostic per David
Laight's review.
3/3 the zero-size case.
On stable: 1/3 carries Cc: stable with no Fixes: tag of its own. It is a
prerequisite, since 2/3 and 3/3 need -EINVAL to mean "skip". Backporting
2/3 without 1/3 is not broken, it reverts to discarding the streaming
interface, but the commit message would then describe something the
backport does not do. Both or neither, please.
Carrying 2/3 on Noam's behalf, with his agreement on the list.
Build tested on x86_64 only, no hardware and no UVC gadget.
Natasha Klaus (2):
media: uvcvideo: Let uvc_parse_frame() report a skipped frame
media: uvcvideo: Skip frame descriptors with a zero computed size
Noam Ben Shimon (1):
media: uvcvideo: Fix integer overflow in frame buffer size calculation
drivers/media/usb/uvc/uvc_driver.c | 52 ++++++++++++++++++++++--------
1 file changed, 39 insertions(+), 13 deletions(-)
--
2.34.1
next reply other threads:[~2026-08-20 9:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 9:56 Natasha Klaus [this message]
2026-08-20 9:56 ` [PATCH 1/3] media: uvcvideo: Let uvc_parse_frame() report a skipped frame Natasha Klaus
2026-08-20 10:29 ` Ricardo Ribalda
2026-08-20 9:56 ` [PATCH 2/3] media: uvcvideo: Fix integer overflow in frame buffer size calculation Natasha Klaus
2026-08-20 10:26 ` Ricardo Ribalda
2026-08-20 9:56 ` [PATCH 3/3] media: uvcvideo: Skip frame descriptors with a zero computed size Natasha Klaus
2026-08-20 10:31 ` 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=20260820095626.111196-1-natalie.klaus@runtimeverification.com \
--to=natalie.klaus@runtimeverification.com \
--cc=david.laight.linux@gmail.com \
--cc=hansg@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=noambs2999@gmail.com \
--cc=ribalda@chromium.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