提交 6bd94e3b 编写于 作者: D Dongxiang Ke 提交者: Jialin Zhang

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

stable inclusion
from stable-v5.10.143
commit 6123bec8480d23369e2ee0b2208611619f269faf
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I6D0U6

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6123bec8480d23369e2ee0b2208611619f269faf

--------------------------------

commit e53f47f6 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: NDongxiang Ke <kdx.glider@gmail.com>
Link: https://lore.kernel.org/r/20220906024928.10951-1-kdx.glider@gmail.comSigned-off-by: NTakashi Iwai <tiwai@suse.de>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
Reviewed-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 6df89c5e
...@@ -1106,7 +1106,7 @@ static int __snd_usb_parse_audio_interface(struct snd_usb_audio *chip, ...@@ -1106,7 +1106,7 @@ static int __snd_usb_parse_audio_interface(struct snd_usb_audio *chip,
* Dallas DS4201 workaround: It presents 5 altsettings, but the last * Dallas DS4201 workaround: It presents 5 altsettings, but the last
* one misses syncpipe, and does not produce any sound. * 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; num = 4;
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册