UBSAN: shift-out-of-bounds in parse_audio_unit
syzbot
syzbotHello,
syzbot found the following issue on:
HEAD commit: a19ea421490d Merge tag 'platform-drivers-x86-v6.10-6' of g.. git tree: upstream console+strace: https://syzkaller.appspot.com/x/log.txt?x=173c2e9e980000 kernel config: https://syzkaller.appspot.com/x/.config?x=b63b35269462a0e0 dashboard link: https://syzkaller.appspot.com/bug?extid=78d5b129a762182225aa compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15773776980000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1373427e980000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/ea993841f842/disk-a19ea421.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/eef900c478c0/vmlinux-a19ea421.xz
kernel image: https://storage.googleapis.com/syzbot-assets/deecea0553fd/bzImage-a19ea421.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
usb 1-1: 0:2 : does not exist
------------[ cut here ]------------ UBSAN: shift-out-of-bounds in sound/usb/mixer.c:2057:20 shift exponent 42 is too large for 32-bit type 'int' CPU: 1 PID: 45 Comm: kworker/1:1 Not tainted 6.10.0-rc7-syzkaller-00025-ga19ea421490d #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024 Workqueue: usb_hub_wq hub_event Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114 ubsan_epilogue lib/ubsan.c:231 [inline] __ubsan_handle_shift_out_of_bounds+0x3c8/0x420 lib/ubsan.c:468 parse_audio_feature_unit sound/usb/mixer.c:2057 [inline] parse_audio_unit+0x277d/0x3f10 sound/usb/mixer.c:2907 snd_usb_mixer_controls sound/usb/mixer.c:3252 [inline] snd_usb_create_mixer+0x1365/0x2fa0 sound/usb/mixer.c:3599 usb_audio_probe+0x1688/0x2100 sound/usb/card.c:888 usb_probe_interface+0x645/0xbb0 drivers/usb/core/driver.c:399 really_probe+0x2b8/0xad0 drivers/base/dd.c:656 __driver_probe_device+0x1a2/0x390 drivers/base/dd.c:798 driver_probe_device+0x50/0x430 drivers/base/dd.c:828 __device_attach_driver+0x2d6/0x530 drivers/base/dd.c:956 bus_for_each_drv+0x24e/0x2e0 drivers/base/bus.c:457 __device_attach+0x333/0x520 drivers/base/dd.c:1028 bus_probe_device+0x189/0x260 drivers/base/bus.c:532 device_add+0x856/0xbf0 drivers/base/core.c:3679 usb_set_configuration+0x1976/0x1fb0 drivers/usb/core/message.c:2210 usb_generic_driver_probe+0x88/0x140 drivers/usb/core/generic.c:254 usb_probe_device+0x1b8/0x380 drivers/usb/core/driver.c:294 really_probe+0x2b8/0xad0 drivers/base/dd.c:656 __driver_probe_device+0x1a2/0x390 drivers/base/dd.c:798 driver_probe_device+0x50/0x430 drivers/base/dd.c:828 __device_attach_driver+0x2d6/0x530 drivers/base/dd.c:956 bus_for_each_drv+0x24e/0x2e0 drivers/base/bus.c:457 __device_attach+0x333/0x520 drivers/base/dd.c:1028 bus_probe_device+0x189/0x260 drivers/base/bus.c:532 device_add+0x856/0xbf0 drivers/base/core.c:3679 usb_new_device+0x104a/0x19a0 drivers/usb/core/hub.c:2651 hub_port_connect drivers/usb/core/hub.c:5521 [inline] hub_port_connect_change drivers/usb/core/hub.c:5661 [inline] port_event drivers/usb/core/hub.c:5821 [inline] hub_event+0x2d6a/0x5150 drivers/usb/core/hub.c:5903 process_one_work kernel/workqueue.c:3248 [inline] process_scheduled_works+0xa2c/0x1830 kernel/workqueue.c:3329 worker_thread+0x86d/0xd50 kernel/workqueue.c:3409 kthread+0x2f0/0x390 kernel/kthread.c:389 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 </TASK> ---[ end trace ]---
---
This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at [email protected].
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
bLength too small ?
#syz test: upstream a19ea421490d
sound/usb/mixer.c +3 -0
@@ -1999,6 +1999,9 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid,if (state->mixer->protocol ==UAC_VERSION_1 ) { csize = hdr->bControlSize; +printk ("c: %d, bLen: %d, %c, \n" , channels, hdr->bLength, hdr->bLength, __func__ ); +if (hdr->bLength <7 ) +return -EINVAL ; channels = (hdr->bLength -7 ) / csize -1 ; bmaControls = hdr->bmaControls; }else if (state->mixer->protocol ==UAC_VERSION_2 ) {
syzbot
syzbotsyzbot has tested the proposed patch but the reproducer is still triggering an issue:
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
UBSAN: shift-out-of-bounds in parse_audio_unit
usb 1-1: config 1 has 1 interface, different from the descriptor's value: 3 usb 1-1: New USB device found, idVendor=08b7, idProduct=0000, bcdDevice= 0.00 usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=3 usb 1-1: SerialNumber: syz
usb 1-1: 0:2 : does not exist
c: 0, bLen: 69, E,
------------[ cut here ]------------ UBSAN: shift-out-of-bounds in sound/usb/mixer.c:2060:20 shift exponent 42 is too large for 32-bit type 'int' CPU: 1 PID: 5219 Comm: kworker/1:3 Not tainted 6.10.0-rc7-syzkaller-00025-ga19ea421490d-dirty #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024 Workqueue: usb_hub_wq hub_event Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114 ubsan_epilogue lib/ubsan.c:231 [inline] __ubsan_handle_shift_out_of_bounds+0x3c8/0x420 lib/ubsan.c:468 parse_audio_feature_unit sound/usb/mixer.c:2060 [inline] parse_audio_unit+0x270f/0x3f60 sound/usb/mixer.c:2910 snd_usb_mixer_controls sound/usb/mixer.c:3255 [inline] snd_usb_create_mixer+0x1365/0x2fa0 sound/usb/mixer.c:3602 usb_audio_probe+0x1688/0x2100 sound/usb/card.c:888 usb_probe_interface+0x645/0xbb0 drivers/usb/core/driver.c:399 really_probe+0x2b8/0xad0 drivers/base/dd.c:656 __driver_probe_device+0x1a2/0x390 drivers/base/dd.c:798 driver_probe_device+0x50/0x430 drivers/base/dd.c:828 __device_attach_driver+0x2d6/0x530 drivers/base/dd.c:956 bus_for_each_drv+0x24e/0x2e0 drivers/base/bus.c:457 __device_attach+0x333/0x520 drivers/base/dd.c:1028 bus_probe_device+0x189/0x260 drivers/base/bus.c:532 device_add+0x856/0xbf0 drivers/base/core.c:3679 usb_set_configuration+0x1976/0x1fb0 drivers/usb/core/message.c:2210 usb_generic_driver_probe+0x88/0x140 drivers/usb/core/generic.c:254 usb_probe_device+0x1b8/0x380 drivers/usb/core/driver.c:294 really_probe+0x2b8/0xad0 drivers/base/dd.c:656 __driver_probe_device+0x1a2/0x390 drivers/base/dd.c:798 driver_probe_device+0x50/0x430 drivers/base/dd.c:828 __device_attach_driver+0x2d6/0x530 drivers/base/dd.c:956 bus_for_each_drv+0x24e/0x2e0 drivers/base/bus.c:457 __device_attach+0x333/0x520 drivers/base/dd.c:1028 bus_probe_device+0x189/0x260 drivers/base/bus.c:532 device_add+0x856/0xbf0 drivers/base/core.c:3679 usb_new_device+0x104a/0x19a0 drivers/usb/core/hub.c:2651 hub_port_connect drivers/usb/core/hub.c:5521 [inline] hub_port_connect_change drivers/usb/core/hub.c:5661 [inline] port_event drivers/usb/core/hub.c:5821 [inline] hub_event+0x2d6a/0x5150 drivers/usb/core/hub.c:5903 process_one_work kernel/workqueue.c:3248 [inline] process_scheduled_works+0xa2c/0x1830 kernel/workqueue.c:3329 worker_thread+0x86d/0xd50 kernel/workqueue.c:3409 kthread+0x2f0/0x390 kernel/kthread.c:389 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 </TASK> ---[ end trace ]---
Tested on:
commit: a19ea421 Merge tag 'platform-drivers-x86-v6.10-6' of g.. git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git console output: https://syzkaller.appspot.com/x/log.txt?x=1127894e980000 kernel config: https://syzkaller.appspot.com/x/.config?x=b63b35269462a0e0 dashboard link: https://syzkaller.appspot.com/bug?extid=78d5b129a762182225aa compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40 patch: https://syzkaller.appspot.com/x/patch.diff?x=103c33e1980000
csize is 0 ?
#syz test: upstream a19ea421490d
sound/usb/mixer.c +3 -0
@@ -1999,6 +1999,9 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid,if (state->mixer->protocol ==UAC_VERSION_1 ) { csize = hdr->bControlSize; +printk ("c: %d, bLen: %d, %d, \n" , channels, hdr->bLength, csize, __func__); +if (hdr->bLength <7 || csize <1 ) +return -EINVAL ; channels = (hdr->bLength -7 ) / csize -1 ; bmaControls = hdr->bmaControls; }else if (state->mixer->protocol ==UAC_VERSION_2 ) {
syzbot
syzbotsyzbot has tested the proposed patch but the reproducer is still triggering an issue:
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
UBSAN: shift-out-of-bounds in parse_audio_unit
usb 1-1: config 1 has 1 interface, different from the descriptor's value: 3 usb 1-1: New USB device found, idVendor=08b7, idProduct=0000, bcdDevice= 0.00 usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=3 usb 1-1: SerialNumber: syz
usb 1-1: 0:2 : does not exist
c: 0, bLen: 69, 1,
------------[ cut here ]------------ UBSAN: shift-out-of-bounds in sound/usb/mixer.c:2060:20 shift exponent 42 is too large for 32-bit type 'int' CPU: 1 PID: 5170 Comm: kworker/1:5 Not tainted 6.10.0-rc7-syzkaller-00025-ga19ea421490d-dirty #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024 Workqueue: usb_hub_wq hub_event Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114 ubsan_epilogue lib/ubsan.c:231 [inline] __ubsan_handle_shift_out_of_bounds+0x3c8/0x420 lib/ubsan.c:468 parse_audio_feature_unit sound/usb/mixer.c:2060 [inline] parse_audio_unit+0x2709/0x3f70 sound/usb/mixer.c:2910 snd_usb_mixer_controls sound/usb/mixer.c:3255 [inline] snd_usb_create_mixer+0x1365/0x2fa0 sound/usb/mixer.c:3602 usb_audio_probe+0x1688/0x2100 sound/usb/card.c:888 usb_probe_interface+0x645/0xbb0 drivers/usb/core/driver.c:399 really_probe+0x2b8/0xad0 drivers/base/dd.c:656 __driver_probe_device+0x1a2/0x390 drivers/base/dd.c:798 driver_probe_device+0x50/0x430 drivers/base/dd.c:828 __device_attach_driver+0x2d6/0x530 drivers/base/dd.c:956 bus_for_each_drv+0x24e/0x2e0 drivers/base/bus.c:457 __device_attach+0x333/0x520 drivers/base/dd.c:1028 bus_probe_device+0x189/0x260 drivers/base/bus.c:532 device_add+0x856/0xbf0 drivers/base/core.c:3679 usb_set_configuration+0x1976/0x1fb0 drivers/usb/core/message.c:2210 usb_generic_driver_probe+0x88/0x140 drivers/usb/core/generic.c:254 usb_probe_device+0x1b8/0x380 drivers/usb/core/driver.c:294 really_probe+0x2b8/0xad0 drivers/base/dd.c:656 __driver_probe_device+0x1a2/0x390 drivers/base/dd.c:798 driver_probe_device+0x50/0x430 drivers/base/dd.c:828 __device_attach_driver+0x2d6/0x530 drivers/base/dd.c:956 bus_for_each_drv+0x24e/0x2e0 drivers/base/bus.c:457 __device_attach+0x333/0x520 drivers/base/dd.c:1028 bus_probe_device+0x189/0x260 drivers/base/bus.c:532 device_add+0x856/0xbf0 drivers/base/core.c:3679 usb_new_device+0x104a/0x19a0 drivers/usb/core/hub.c:2651 hub_port_connect drivers/usb/core/hub.c:5521 [inline] hub_port_connect_change drivers/usb/core/hub.c:5661 [inline] port_event drivers/usb/core/hub.c:5821 [inline] hub_event+0x2d6a/0x5150 drivers/usb/core/hub.c:5903 process_one_work kernel/workqueue.c:3248 [inline] process_scheduled_works+0xa2c/0x1830 kernel/workqueue.c:3329 worker_thread+0x86d/0xd50 kernel/workqueue.c:3409 kthread+0x2f0/0x390 kernel/kthread.c:389 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 </TASK> ---[ end trace ]---
Tested on:
commit: a19ea421 Merge tag 'platform-drivers-x86-v6.10-6' of g.. git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git console output: https://syzkaller.appspot.com/x/log.txt?x=1367bf66980000 kernel config: https://syzkaller.appspot.com/x/.config?x=b63b35269462a0e0 dashboard link: https://syzkaller.appspot.com/bug?extid=78d5b129a762182225aa compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40 patch: https://syzkaller.appspot.com/x/patch.diff?x=12ecf85e980000
invalid bControlSize and bLength make channels too large
#syz test: upstream a19ea421490d
sound/usb/mixer.c +2 -0
@@ -2000,6 +2000,8 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid,if (state->mixer->protocol ==UAC_VERSION_1 ) { csize = hdr->bControlSize; channels = (hdr->bLength -7 ) / csize -1 ; +if (channels >32 ) +return -EINVAL ; bmaControls = hdr->bmaControls; }else if (state->mixer->protocol ==UAC_VERSION_2 ) {struct uac2_feature_unit_descriptor *ftr = _ftr;
syzbot
syzbotsyzbot has tested the proposed patch and the reproducer did not trigger any issue:
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Tested on:
commit: a19ea421 Merge tag 'platform-drivers-x86-v6.10-6' of g.. git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git console output: https://syzkaller.appspot.com/x/log.txt?x=1606be59980000 kernel config: https://syzkaller.appspot.com/x/.config?x=b63b35269462a0e0 dashboard link: https://syzkaller.appspot.com/bug?extid=78d5b129a762182225aa compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40 patch: https://syzkaller.appspot.com/x/patch.diff?x=14967149980000
Note: testing is done by a robot and is best-effort only.