]> git.hungrycats.org Git - linux/commitdiff
ALSA: ua101: Reject too-short USB descriptors
authorCássio Gabriel <cassiogabrielcontato@gmail.com>
Tue, 19 May 2026 03:32:15 +0000 (00:32 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 1 Jun 2026 15:29:50 +0000 (17:29 +0200)
commit b59d5c51bb328a60749b4dd5fe7e649bfb4089b4 upstream.

find_format_descriptor() walks the class-specific interface extras by
advancing with bLength. It rejects descriptors that extend past the
remaining buffer, but it does not reject descriptor lengths smaller than
a USB descriptor header.

Reject too-short descriptors before using bLength to advance the local
scan. This keeps the UA-101 parser robust against malformed descriptor
data and matches the usual USB descriptor walking rules.

Fixes: 63978ab3e3e9 ("sound: add Edirol UA-101 support")
Cc: stable@vger.kernel.org
Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
Link: https://patch.msgid.link/20260519-alsa-ua101-desc-len-v1-1-4307d1a5e054@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/usb/misc/ua101.c

index e9ce9f903cc63cb2a6af4c8138325be85da5a117..0d73775966b76d79bb49fa854b736fd77a23ac14 100644 (file)
@@ -915,8 +915,9 @@ find_format_descriptor(struct usb_interface *interface)
                struct uac_format_type_i_discrete_descriptor *desc;
 
                desc = (struct uac_format_type_i_discrete_descriptor *)extra;
-               if (desc->bLength > extralen) {
-                       dev_err(&interface->dev, "descriptor overflow\n");
+               if (desc->bLength < sizeof(struct usb_descriptor_header) ||
+                   desc->bLength > extralen) {
+                       dev_err(&interface->dev, "invalid descriptor length\n");
                        return NULL;
                }
                if (desc->bLength == UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(1) &&