From: Alan Stern <stern@rowland.harvard.edu>
To: Griffin Kroah-Hartman <griffin@kroah.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] usb: core: strengthen size check in usb_parse_interface()
Date: Mon, 13 Jul 2026 12:13:04 -0400 [thread overview]
Message-ID: <b2498cb4-61f7-429a-920a-e27ecd7986e4@rowland.harvard.edu> (raw)
In-Reply-To: <20260713-usb_core_patches_1-v1-2-7721c2b33f53@kroah.com>
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.
> This matches the size check in usb_parse_configuration() as well.
Right. There's no point in doing the same size check twice.
Alan Stern
>
> Assisted-by: gkh_clanker_t1000
> Signed-off-by: Griffin Kroah-Hartman <griffin@kroah.com>
> ---
> drivers/usb/core/config.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
> index 17c93e95945f..91a51cedc1b8 100644
> --- a/drivers/usb/core/config.c
> +++ b/drivers/usb/core/config.c
> @@ -623,7 +623,7 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
>
> /* Parse all the endpoint descriptors */
> n = 0;
> - while (size > 0) {
> + while (size >= sizeof(struct usb_descriptor_header)) {
> if (((struct usb_descriptor_header *) buffer)->bDescriptorType
> == USB_DT_INTERFACE)
> break;
>
> --
> 2.55.0
>
>
next prev parent reply other threads:[~2026-07-13 16:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 15:43 [PATCH 0/3] USB core defense "hardening" changes Griffin Kroah-Hartman
2026-07-13 15:43 ` [PATCH 1/3] usb: core: Add size check to find_next_descriptor() Griffin Kroah-Hartman
2026-07-13 16:14 ` Alan Stern
2026-07-13 15:43 ` [PATCH 2/3] usb: core: strengthen size check in usb_parse_interface() Griffin Kroah-Hartman
2026-07-13 16:13 ` Alan Stern [this message]
2026-07-14 5:53 ` Greg Kroah-Hartman
2026-07-14 6:20 ` Oliver Neukum
2026-07-14 6:30 ` Greg Kroah-Hartman
2026-07-14 7:06 ` Oliver Neukum
2026-07-14 16:41 ` Alan Stern
2026-07-13 15:43 ` [PATCH 3/3] usb: core: Add lock to usb_wakeup_notification() Griffin Kroah-Hartman
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=b2498cb4-61f7-429a-920a-e27ecd7986e4@rowland.harvard.edu \
--to=stern@rowland.harvard.edu \
--cc=gregkh@linuxfoundation.org \
--cc=griffin@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@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®