Skip to contentSkip to conversation

ALSA: usb-audio: Fix an out-of-bounds bug in __snd_usb_parse_audio_interface()

PATCH Applied Dongxiang Ke 2 participants 2 messages Sep 6, 2022 Sound

lore
Share & tools
lore
Applied
#1 lore raw
In reply to Dongxiang Ke
Quoted 8 lines · Dongxiang Ke

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.

Thanks, applied.

Takashi

#0 lore raw

PATCH 1/1 ALSA: usb-audio: Fix an out-of-bounds bug in __snd_usb_parse_audio_interface()

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.

---
 sound/usb/stream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/stream.c +1 -1
index ceb93d798182..40ce8a1cb318 100644
@@ -1105,7 +1105,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++) {
Signature · 1 line
2.30.2