]> git.itanic.dy.fi Git - linux-stable/commitdiff
ALSA: usb-audio: Fix an out-of-bounds bug in __snd_usb_parse_audio_interface()
authorDongxiang Ke <kdx.glider@gmail.com>
Tue, 6 Sep 2022 02:49:28 +0000 (10:49 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 15 Sep 2022 10:04:54 +0000 (12:04 +0200)
commit e53f47f6c1a56d2af728909f1cb894da6b43d9bf upstream.

There may be a bad USB audio device with a USB ID of (0x04fa, 0x4201) and
the number of it's interfaces less than 4, an out-of-bounds read bug occurs
when parsing the interface descriptor for this device.

Fix this by checking the number of interfaces.

Signed-off-by: Dongxiang Ke <kdx.glider@gmail.com>
Link: https://lore.kernel.org/r/20220906024928.10951-1-kdx.glider@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/usb/stream.c

index eff1ac1dc9ba3e3902c76ba23e0d37ad9cf659f9..d35684e5f07f091c6b1a6c52243fa60fe822e16f 100644 (file)
@@ -1103,7 +1103,7 @@ static int __snd_usb_parse_audio_interface(struct snd_usb_audio *chip,
         * Dallas DS4201 workaround: It presents 5 altsettings, but the last
         * one misses syncpipe, and does not produce any sound.
         */
-       if (chip->usb_id == USB_ID(0x04fa, 0x4201))
+       if (chip->usb_id == USB_ID(0x04fa, 0x4201) && num >= 4)
                num = 4;
 
        for (i = 0; i < num; i++) {