syzbot


KASAN: use-after-free Read in usb_audio_disconnect

Status: fixed on 2021/04/09 19:46
Subsystems: sound usb
[Documentation on labels]
Reported-by: syzbot+ffad4c74b3b3ea3aa9c3@syzkaller.appspotmail.com
Fix commit: c5aa956eaeb0 ALSA: usb-audio: fix use after free in usb_audio_disconnect
First crash: 1134d, last: 1129d
Cause bisection: introduced by (bisect log) :
commit 9799110825dba087c2bdce886977cf84dada2005
Author: Kai-Heng Feng <kai.heng.feng@canonical.com>
Date: Thu Mar 4 04:34:16 2021 +0000

  ALSA: usb-audio: Disable USB autosuspend properly in setup_disable_autosuspend()

Crash: KASAN: use-after-free Read in usb_audio_disconnect (log)
Repro: C syz .config
  
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] KASAN: use-after-free Read in usb_audio_disconnect 2 (4) 2021/03/09 12:23
Last patch testing requests (1)
Created Duration User Patch Repo Result
2021/03/29 04:09 16m ducheng2@gmail.com linux-next OK

Sample crash report:
usb 1-1: USB disconnect, device number 2
==================================================================
BUG: KASAN: use-after-free in usb_audio_disconnect+0x750/0x800 sound/usb/card.c:918
Read of size 2 at addr ffff888027a08f24 by task kworker/0:2/2966

CPU: 0 PID: 2966 Comm: kworker/0:2 Not tainted 5.12.0-rc1-next-20210305-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: usb_hub_wq hub_event
Call Trace:
 __dump_stack lib/dump_stack.c:79 [inline]
 dump_stack+0xfa/0x151 lib/dump_stack.c:120
 print_address_description.constprop.0.cold+0x5b/0x2f8 mm/kasan/report.c:232
 __kasan_report mm/kasan/report.c:399 [inline]
 kasan_report.cold+0x7c/0xd8 mm/kasan/report.c:416
 usb_audio_disconnect+0x750/0x800 sound/usb/card.c:918
 usb_unbind_interface+0x1d8/0x8d0 drivers/usb/core/driver.c:458
 __device_release_driver+0x3bd/0x6f0 drivers/base/dd.c:1156
 device_release_driver_internal drivers/base/dd.c:1187 [inline]
 device_release_driver+0x26/0x40 drivers/base/dd.c:1210
 bus_remove_device+0x2eb/0x5a0 drivers/base/bus.c:533
 device_del+0x502/0xd40 drivers/base/core.c:3421
 usb_disable_device+0x35b/0x7b0 drivers/usb/core/message.c:1413
 usb_disconnect.cold+0x27d/0x791 drivers/usb/core/hub.c:2218
 hub_port_connect drivers/usb/core/hub.c:5074 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5363 [inline]
 port_event drivers/usb/core/hub.c:5509 [inline]
 hub_event+0x1c9c/0x4320 drivers/usb/core/hub.c:5591
 process_one_work+0x98d/0x1600 kernel/workqueue.c:2275
 worker_thread+0x64c/0x1120 kernel/workqueue.c:2421
 kthread+0x3b1/0x4a0 kernel/kthread.c:292
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294

Allocated by task 5:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:427 [inline]
 ____kasan_kmalloc mm/kasan/common.c:506 [inline]
 ____kasan_kmalloc mm/kasan/common.c:465 [inline]
 __kasan_kmalloc+0x99/0xc0 mm/kasan/common.c:515
 kmalloc include/linux/slab.h:561 [inline]
 kzalloc include/linux/slab.h:686 [inline]
 snd_card_new+0xc2/0xcb0 sound/core/init.c:176
 snd_usb_audio_create sound/usb/card.c:588 [inline]
 usb_audio_probe+0x1547/0x2c70 sound/usb/card.c:755
 usb_probe_interface+0x315/0x7f0 drivers/usb/core/driver.c:396
 really_probe+0x291/0xe60 drivers/base/dd.c:554
 driver_probe_device+0x26b/0x3d0 drivers/base/dd.c:740
 __device_attach_driver+0x1d1/0x290 drivers/base/dd.c:846
 bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:431
 __device_attach+0x228/0x4a0 drivers/base/dd.c:914
 bus_probe_device+0x1e4/0x290 drivers/base/bus.c:491
 device_add+0xbdb/0x1db0 drivers/base/core.c:3242
 usb_set_configuration+0x113f/0x1910 drivers/usb/core/message.c:2164
 usb_generic_driver_probe+0xba/0x100 drivers/usb/core/generic.c:238
 usb_probe_device+0xd9/0x2c0 drivers/usb/core/driver.c:293
 really_probe+0x291/0xe60 drivers/base/dd.c:554
 driver_probe_device+0x26b/0x3d0 drivers/base/dd.c:740
 __device_attach_driver+0x1d1/0x290 drivers/base/dd.c:846
 bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:431
 __device_attach+0x228/0x4a0 drivers/base/dd.c:914
 bus_probe_device+0x1e4/0x290 drivers/base/bus.c:491
 device_add+0xbdb/0x1db0 drivers/base/core.c:3242
 usb_new_device.cold+0x721/0x1058 drivers/usb/core/hub.c:2555
 hub_port_connect drivers/usb/core/hub.c:5223 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5363 [inline]
 port_event drivers/usb/core/hub.c:5509 [inline]
 hub_event+0x2357/0x4320 drivers/usb/core/hub.c:5591
 process_one_work+0x98d/0x1600 kernel/workqueue.c:2275
 worker_thread+0x64c/0x1120 kernel/workqueue.c:2421
 kthread+0x3b1/0x4a0 kernel/kthread.c:292
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294

Freed by task 2966:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track+0x1c/0x30 mm/kasan/common.c:46
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:357
 ____kasan_slab_free mm/kasan/common.c:360 [inline]
 ____kasan_slab_free mm/kasan/common.c:325 [inline]
 __kasan_slab_free+0xf5/0x130 mm/kasan/common.c:367
 kasan_slab_free include/linux/kasan.h:199 [inline]
 slab_free_hook mm/slub.c:1562 [inline]
 slab_free_freelist_hook+0x72/0x1b0 mm/slub.c:1600
 slab_free mm/slub.c:3161 [inline]
 kfree+0xe5/0x7b0 mm/slub.c:4215
 device_release+0x9f/0x240 drivers/base/core.c:2108
 kobject_cleanup lib/kobject.c:705 [inline]
 kobject_release lib/kobject.c:736 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x1c8/0x540 lib/kobject.c:753
 put_device+0x1b/0x30 drivers/base/core.c:3341
 snd_card_free_when_closed+0x35/0x50 sound/core/init.c:518
 usb_audio_disconnect+0x2ba/0x800 sound/usb/card.c:913
 usb_unbind_interface+0x1d8/0x8d0 drivers/usb/core/driver.c:458
 __device_release_driver+0x3bd/0x6f0 drivers/base/dd.c:1156
 device_release_driver_internal drivers/base/dd.c:1187 [inline]
 device_release_driver+0x26/0x40 drivers/base/dd.c:1210
 bus_remove_device+0x2eb/0x5a0 drivers/base/bus.c:533
 device_del+0x502/0xd40 drivers/base/core.c:3421
 usb_disable_device+0x35b/0x7b0 drivers/usb/core/message.c:1413
 usb_disconnect.cold+0x27d/0x791 drivers/usb/core/hub.c:2218
 hub_port_connect drivers/usb/core/hub.c:5074 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5363 [inline]
 port_event drivers/usb/core/hub.c:5509 [inline]
 hub_event+0x1c9c/0x4320 drivers/usb/core/hub.c:5591
 process_one_work+0x98d/0x1600 kernel/workqueue.c:2275
 worker_thread+0x64c/0x1120 kernel/workqueue.c:2421
 kthread+0x3b1/0x4a0 kernel/kthread.c:292
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294

The buggy address belongs to the object at ffff888027a08000
 which belongs to the cache kmalloc-8k of size 8192
The buggy address is located 3876 bytes inside of
 8192-byte region [ffff888027a08000, ffff888027a0a000)
The buggy address belongs to the page:
page:0000000024fc4526 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x27a08
head:0000000024fc4526 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head)
raw: 00fff00000010200 dead000000000100 dead000000000122 ffff888010842280
raw: 0000000000000000 0000000000020002 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888027a08e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888027a08e80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888027a08f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff888027a08f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888027a09000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (15):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/03/05 13:45 linux-next 4641b32307b3 9d751681 .config console log report syz C ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in usb_audio_disconnect
2021/03/05 13:27 linux-next 4641b32307b3 9d751681 .config console log report syz C ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in usb_audio_disconnect
2021/03/10 11:00 linux-next 3aa6f5082286 26967e35 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in usb_audio_disconnect
2021/03/10 10:59 linux-next 3aa6f5082286 26967e35 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in usb_audio_disconnect
2021/03/08 23:54 linux-next 4641b32307b3 09fbf400 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in usb_audio_disconnect
2021/03/08 20:27 linux-next 4641b32307b3 09fbf400 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in usb_audio_disconnect
2021/03/07 10:31 linux-next 4641b32307b3 e4b4d570 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in usb_audio_disconnect
2021/03/05 13:03 linux-next 4641b32307b3 9d751681 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in usb_audio_disconnect
2021/03/05 12:36 linux-next 4641b32307b3 9d751681 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in usb_audio_disconnect
2021/03/05 12:32 linux-next 4641b32307b3 9d751681 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in usb_audio_disconnect
2021/03/05 12:19 linux-next 4641b32307b3 9d751681 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in usb_audio_disconnect
2021/03/05 11:53 linux-next 4641b32307b3 9d751681 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in usb_audio_disconnect
2021/03/05 11:44 linux-next 4641b32307b3 9d751681 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in usb_audio_disconnect
2021/03/05 11:36 linux-next 4641b32307b3 9d751681 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in usb_audio_disconnect
2021/03/05 11:28 linux-next 4641b32307b3 9d751681 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in usb_audio_disconnect
* Struck through repros no longer work on HEAD.