Re: [PATCH 2/3] usb: core: strengthen size check in usb_parse_interface()
From: Greg Kroah-Hartman
Date: Tue Jul 14 2026 - 01:55:51 EST
On Mon, Jul 13, 2026 at 12:13:04PM -0400, Alan Stern wrote:
> On Mon, Jul 13, 2026 at 05:43:52PM +0200, Griffin Kroah-Hartman wrote:
> > Change the size check from size > 0 to size >= sizeof(struct
> > usb_descriptor_header) in usb_parse_interface(). This prevents a
> > malicious device from utilizing trailing bytes to incur an OOB read.
>
> No, because usb_parse_configuration() has already performed this check.
> A malicious device can't avoid that earlier check, and so we don't need
> to do it again.
Ok, this is my fault. I gave these tasks to the author here, as part of
an project for computer security masters students at vu.nl to help grind
down the huge number of LLM-reported issues that I've gotten over the
past few months (you'll see other patches from these students being
submitted all over the tree right now as well). Right now the LLMs seem
to be running at about 1/3 to 1/4 of "false positives", and these two
patches are a good example of that.
The thread here:
https://lore.kernel.org/all/alEsSl8i1_FpoU0f@fudgebox/
is also another example of where the LLM wanted to add more defensive
code, despite it not really being needed.
The bots really really want to please you, and come up with ways to
swear that the change is needed, and so manual code review is still
always required.
Even with that manual review, these two fooled me, as they are obviously
not wrong (what's the harm in adding more checks?) I caught that we
parsed the descriptors in usb_parse_configuration() but missed where
size was not incremented (I was looking at the buffer pointers).
Sashiko also missed this (catching it for the first patch, but not for
this one), proof that even the "best" LLM models out there today are
still not reliable.
Thanks for the review, much appreciated.
As for patch 3/3, I'm pretty sure that can't hurt as well. I'm starting
to get a lot of "something could happen in an IRQ while a device is
being removed" bug reports from these tools. Looks like they all just
discovered that very rare code path at the same time, something that
syzbot can't really fuzz for.
thanks,
greg k-h