syzbot


KASAN: use-after-free Read in usb_anchor_resume_wakeups (2)

Status: auto-closed as invalid on 2021/08/21 21:47
Subsystems: usb
[Documentation on labels]
Reported-by: syzbot+39c636a0650bcbb172ec@syzkaller.appspotmail.com
First crash: 1201d, last: 1098d
Discussions (1)
Title Replies (including bot) Last reply
KASAN: use-after-free Read in usb_anchor_resume_wakeups (2) 2 (3) 2021/01/12 04:55
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in usb_anchor_resume_wakeups (3) usb 6 704d 923d 0/26 auto-obsoleted due to no activity on 2022/09/19 12:39
upstream KASAN: use-after-free Read in usb_anchor_resume_wakeups usb 41 1369d 1752d 0/26 auto-closed as invalid on 2020/11/24 04:41
upstream KASAN: use-after-free Read in usb_anchor_resume_wakeups (4) usb 39 1d21h 572d 0/26 upstream: reported on 2022/10/01 13:43
linux-5.15 KASAN: use-after-free Read in usb_anchor_resume_wakeups 1 330d 330d 0/3 auto-obsoleted due to no activity on 2023/09/08 22:47

Sample crash report:
xpad 5-1:0.65: xpad_irq_in - usb_submit_urb failed with result -19
xpad 5-1:0.65: xpad_irq_out - usb_submit_urb failed with result -19
==================================================================
BUG: KASAN: use-after-free in debug_spin_lock_before kernel/locking/spinlock_debug.c:83 [inline]
BUG: KASAN: use-after-free in do_raw_spin_lock+0x262/0x2b0 kernel/locking/spinlock_debug.c:112
Read of size 4 at addr ffff88802719385c by task systemd-udevd/30887

CPU: 0 PID: 30887 Comm: systemd-udevd Not tainted 5.12.0-rc8-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:79 [inline]
 dump_stack+0x141/0x1d7 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
 debug_spin_lock_before kernel/locking/spinlock_debug.c:83 [inline]
 do_raw_spin_lock+0x262/0x2b0 kernel/locking/spinlock_debug.c:112
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:117 [inline]
 _raw_spin_lock_irqsave+0x41/0x50 kernel/locking/spinlock.c:159
 __wake_up_common_lock+0xb4/0x130 kernel/sched/wait.c:137
 usb_anchor_resume_wakeups drivers/usb/core/urb.c:937 [inline]
 usb_anchor_resume_wakeups+0xbe/0xe0 drivers/usb/core/urb.c:930
 __usb_hcd_giveback_urb+0x2df/0x5c0 drivers/usb/core/hcd.c:1659
 usb_hcd_giveback_urb+0x367/0x410 drivers/usb/core/hcd.c:1726
 dummy_timer+0x11f4/0x32a0 drivers/usb/gadget/udc/dummy_hcd.c:1971
 call_timer_fn+0x1a5/0x6b0 kernel/time/timer.c:1431
 expire_timers kernel/time/timer.c:1476 [inline]
 __run_timers.part.0+0x67c/0xa50 kernel/time/timer.c:1745
 __run_timers kernel/time/timer.c:1726 [inline]
 run_timer_softirq+0xb3/0x1d0 kernel/time/timer.c:1758
 __do_softirq+0x29b/0x9f6 kernel/softirq.c:345
 invoke_softirq kernel/softirq.c:221 [inline]
 __irq_exit_rcu kernel/softirq.c:422 [inline]
 irq_exit_rcu+0x134/0x200 kernel/softirq.c:434
 sysvec_apic_timer_interrupt+0x93/0xc0 arch/x86/kernel/apic/apic.c:1100
 </IRQ>
 asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:632
RIP: 0010:check_kcov_mode+0xf/0x40 kernel/kcov.c:163
Code: c3 43 00 e9 a1 fe ff ff 48 8b 3c 24 e8 2a c3 43 00 e9 18 fe ff ff cc cc cc cc cc 65 8b 05 a9 02 8e 7e 89 c2 81 e2 00 01 00 00 <a9> 00 01 ff 00 74 10 31 c0 85 d2 74 15 8b 96 34 15 00 00 85 d2 74
RSP: 0018:ffffc90017b1f598 EFLAGS: 00000246
RAX: 0000000080000000 RBX: 0000000000000007 RCX: ffff8881443a0000
RDX: 0000000000000000 RSI: ffff8881443a0000 RDI: 0000000000000003
RBP: ffff8880180acb80 R08: 0000000000000000 R09: 0000000000000007
R10: ffffffff8392ee9a R11: 0000000000000010 R12: 0000000000000002
R13: 00000000000002ff R14: dffffc0000000000 R15: 0000000000000000
 write_comp_data kernel/kcov.c:218 [inline]
 __sanitizer_cov_trace_const_cmp1+0x22/0x80 kernel/kcov.c:270
 tomoyo_domain_quota_is_ok+0x32a/0x550 security/tomoyo/util.c:1092
 tomoyo_supervisor+0x2f2/0xf00 security/tomoyo/common.c:2089
 tomoyo_audit_path_log security/tomoyo/file.c:168 [inline]
 tomoyo_path_permission security/tomoyo/file.c:587 [inline]
 tomoyo_path_permission+0x270/0x3a0 security/tomoyo/file.c:573
 tomoyo_check_open_permission+0x33e/0x380 security/tomoyo/file.c:777
 tomoyo_file_open security/tomoyo/tomoyo.c:313 [inline]
 tomoyo_file_open+0xa3/0xd0 security/tomoyo/tomoyo.c:308
 security_file_open+0x52/0x4f0 security/security.c:1589
 do_dentry_open+0x358/0x11b0 fs/open.c:813
 do_open fs/namei.c:3367 [inline]
 path_openat+0x1c0e/0x27e0 fs/namei.c:3500
 do_filp_open+0x190/0x3d0 fs/namei.c:3527
 do_sys_openat2+0x16d/0x420 fs/open.c:1187
 do_sys_open fs/open.c:1203 [inline]
 __do_sys_open fs/open.c:1211 [inline]
 __se_sys_open fs/open.c:1207 [inline]
 __x64_sys_open+0x119/0x1c0 fs/open.c:1207
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7fc2a63066f0
Code: 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 83 3d 19 30 2c 00 00 75 10 b8 02 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e8 fe 9d 01 00 48 89 04 24
RSP: 002b:00007ffd4282d3e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000002
RAX: ffffffffffffffda RBX: 0000564ce6c1ef00 RCX: 00007fc2a63066f0
RDX: 00000000000001b6 RSI: 0000000000080000 RDI: 00007ffd4282d590
RBP: 0000000000000008 R08: 0000000000000008 R09: 0000000000000001
R10: 0000000000080000 R11: 0000000000000246 R12: 0000564ce6aa168a
R13: 0000000000000001 R14: 00007ffd4282d590 R15: 00007ffd4282d5f0

Allocated by task 6078:
 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:554 [inline]
 kzalloc include/linux/slab.h:684 [inline]
 xpad_probe+0x26c/0x1c20 drivers/input/joystick/xpad.c:1747
 usb_probe_interface+0x315/0x7f0 drivers/usb/core/driver.c:396
 really_probe+0x291/0xe60 drivers/base/dd.c:559
 driver_probe_device+0x26b/0x3d0 drivers/base/dd.c:745
 __device_attach_driver+0x1d1/0x290 drivers/base/dd.c:851
 bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:431
 __device_attach+0x228/0x4a0 drivers/base/dd.c:919
 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:559
 driver_probe_device+0x26b/0x3d0 drivers/base/dd.c:745
 __device_attach_driver+0x1d1/0x290 drivers/base/dd.c:851
 bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:431
 __device_attach+0x228/0x4a0 drivers/base/dd.c:919
 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 2311:
 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+0x92/0x210 mm/slub.c:1600
 slab_free mm/slub.c:3161 [inline]
 kfree+0xe5/0x7f0 mm/slub.c:4213
 xpad_disconnect+0x1cb/0x530 drivers/input/joystick/xpad.c:1895
 usb_unbind_interface+0x1d8/0x8d0 drivers/usb/core/driver.c:458
 __device_release_driver+0x3bd/0x6f0 drivers/base/dd.c:1161
 device_release_driver_internal drivers/base/dd.c:1192 [inline]
 device_release_driver+0x26/0x40 drivers/base/dd.c:1215
 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

Last potentially related work creation:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_record_aux_stack+0xe5/0x110 mm/kasan/generic.c:345
 insert_work+0x48/0x370 kernel/workqueue.c:1331
 __queue_work+0x5c1/0xf00 kernel/workqueue.c:1497
 queue_work_on+0xee/0x110 kernel/workqueue.c:1524
 ops_exit_list+0xb0/0x160 net/core/net_namespace.c:175
 cleanup_net+0x4ea/0xb10 net/core/net_namespace.c:595
 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 ffff888027193800
 which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 92 bytes inside of
 1024-byte region [ffff888027193800, ffff888027193c00)
The buggy address belongs to the page:
page:ffffea00009c6400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x27190
head:ffffea00009c6400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head)
raw: 00fff00000010200 0000000000000000 0000000900000001 ffff888010441dc0
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888027193700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888027193780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888027193800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff888027193880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888027193900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/04/23 21:46 upstream 18a3c5f7abfd 17f0b706 .config console log report info ci-upstream-kasan-gce KASAN: use-after-free Read in usb_anchor_resume_wakeups
2021/03/02 04:36 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing fe07bfda2fb9 183afb6c .config console log report info ci2-upstream-usb KASAN: use-after-free Read in usb_anchor_resume_wakeups
2021/02/08 11:41 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing d8c849037d93 2ce644fc .config console log report info ci2-upstream-usb KASAN: use-after-free Read in usb_anchor_resume_wakeups
2021/01/11 01:34 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 841081d89d5a 2c1f2513 .config console log report info ci2-upstream-usb
* Struck through repros no longer work on HEAD.