From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: David Laight <david.laight.linux@gmail.com>
Cc: Natasha Klaus <natalie.klaus@runtimeverification.com>,
noambs2999@gmail.com, ribalda@chromium.org, hansg@kernel.org,
mchehab@kernel.org, linux-media@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: uvcvideo: Fix integer overflow in frame buffer size calculation
Date: Mon, 28 Sep 2026 23:48:10 +0300 [thread overview]
Message-ID: <20260928204810.GK4406@killaraus.ideasonboard.com> (raw)
In-Reply-To: <20260820113129.299aa918@pumpkin>
On Thu, Aug 20, 2026 at 11:31:29AM +0100, David Laight wrote:
> On Thu, 20 Aug 2026 12:13:39 +0300 Natasha Klaus wrote:
> > On Tue, 18 Aug 2026, David Laight wrote:
> > > I'd bet there is a requirement that width*bpp is a multiple of 8 (or even 32)?
> > > You definitely don't want the divide rounding down!
> >
> > There is no such check. bpp is a raw descriptor byte at uvc_driver.c:405, and
> > wWidth is unvalidated. The rounding is pre-existing, c0efd232929c has the same
> > /8, so it is not a regression, but it should be DIV_ROUND_UP. uvc_driver.c:431
> > already uses it thirty lines below.
>
> I'd guess that the only values of bpp that have ever been used are 1, 2, 4, 8,
> 16, 24?, 32 and maybe 64 (for 16bit colour).
Looking at the descriptors for 456 devices, I get 6 different bpp values
with the following number of formats for each bpp:
43 bBitsPerPixel 8
1 bBitsPerPixel 10
18 bBitsPerPixel 12
446 bBitsPerPixel 16
12 bBitsPerPixel 24
1 bBitsPerPixel 32
We of course can't rule out other values. For cameras outputting raw
data (very uncommon), 14, 18, 20 or 22 could be seen.
This being said, I expect width * bpp to always be a multiple of 8.
Splitting a byte across two lines wouldn't make sense.
> Anything else won't go through a hardware FIFO.
> Similarly the hardware wants to do a whole number of memory reads for each
> video line - otherwise it all gets hard to get the porches right.
>
> > > > + if (bufsize > U32_MAX) {
> > >
> > > Should that be >= ?
> >
> > No, U32_MAX itself fits.
>
> Brain fade :-)
>
> David
>
> > > I'd include the bpp, width and height values in the trace.
> >
> > Agreed, will do.
> >
> > I am carrying this as part of a three-patch series at Ricardo's request. Will
> > fold in the rounding and the trace values.
> >
> > Natasha
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2026-09-28 20:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 10:14 [PATCH] media: uvcvideo: Fix integer overflow in frame buffer size calculation Noam Ben Shimon
2026-08-10 14:12 ` Ricardo Ribalda
2026-08-12 10:32 ` [PATCH v2] " Noam Ben Shimon
2026-08-18 6:45 ` Natasha Klaus
2026-08-18 6:54 ` Ricardo Ribalda
2026-08-18 6:57 ` Ricardo Ribalda
2026-08-20 9:53 ` Noam Ben
2026-08-18 7:59 ` [PATCH] media: uvcvideo: Skip frame descriptors with a zero computed size Natasha Klaus
2026-08-18 8:31 ` Ricardo Ribalda
2026-08-18 9:40 ` Natasha Klaus
2026-08-18 9:53 ` Natasha Klaus
2026-08-18 10:18 ` Ricardo Ribalda
2026-08-20 9:43 ` Noam Ben
2026-08-18 10:32 ` Natasha Klaus
2026-08-18 10:40 ` Ricardo Ribalda
2026-08-18 8:28 ` [PATCH] media: uvcvideo: Fix integer overflow in frame buffer size calculation David Laight
2026-08-20 9:13 ` Natasha Klaus
2026-08-20 10:31 ` David Laight
2026-09-28 20:48 ` Laurent Pinchart [this message]
2026-08-20 10:01 ` Noam Ben
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=20260928204810.GK4406@killaraus.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=david.laight.linux@gmail.com \
--cc=hansg@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=natalie.klaus@runtimeverification.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.