syzbot


KASAN: use-after-free Write in usb_anchor_resume_wakeups

Status: closed as dup on 2019/08/21 12:26
Reported-by: syzbot+6c355f8d5f11884fa38e@syzkaller.appspotmail.com
First crash: 1183d, last: 794d
Duplicate of (1):
Title Repro Cause bisect Fix bisect Count Last Reported
KASAN: use-after-free Read in usb_anchor_resume_wakeups 41 793d 1176d

Sample crash report:
usblp0: nonzero read bulk status received: -71
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_write include/linux/instrumented.h:71 [inline]
BUG: KASAN: use-after-free in atomic_dec include/asm-generic/atomic-instrumented.h:330 [inline]
BUG: KASAN: use-after-free in usb_anchor_resume_wakeups+0x2c/0xe0 drivers/usb/core/urb.c:907
Write of size 4 at addr ffff8881d9444218 by task systemd-udevd/123

CPU: 1 PID: 123 Comm: systemd-udevd Not tainted 5.8.0-rc6-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:77 [inline]
 dump_stack+0xf6/0x16e lib/dump_stack.c:118
 print_address_description.constprop.0+0x1a/0x210 mm/kasan/report.c:383
 __kasan_report mm/kasan/report.c:513 [inline]
 kasan_report.cold+0x37/0x7c mm/kasan/report.c:530
 check_memory_region_inline mm/kasan/generic.c:186 [inline]
 check_memory_region+0xf4/0x1c0 mm/kasan/generic.c:192
 instrument_atomic_write include/linux/instrumented.h:71 [inline]
 atomic_dec include/asm-generic/atomic-instrumented.h:330 [inline]
 usb_anchor_resume_wakeups+0x2c/0xe0 drivers/usb/core/urb.c:907
 __usb_hcd_giveback_urb+0x33a/0x560 drivers/usb/core/hcd.c:1653
 usb_hcd_giveback_urb+0x367/0x410 drivers/usb/core/hcd.c:1716
 dummy_timer+0x11f2/0x3240 drivers/usb/gadget/udc/dummy_hcd.c:1967
 call_timer_fn+0x1ac/0x6e0 kernel/time/timer.c:1415
 expire_timers kernel/time/timer.c:1460 [inline]
 __run_timers.part.0+0x54c/0x9e0 kernel/time/timer.c:1784
 __run_timers kernel/time/timer.c:1756 [inline]
 run_timer_softirq+0x80/0x120 kernel/time/timer.c:1797
 __do_softirq+0x222/0x95b kernel/softirq.c:292
 asm_call_on_stack+0xf/0x20 arch/x86/entry/entry_64.S:711
 </IRQ>
 __run_on_irqstack arch/x86/include/asm/irq_stack.h:22 [inline]
 run_on_irqstack_cond arch/x86/include/asm/irq_stack.h:48 [inline]
 do_softirq_own_stack+0xed/0x140 arch/x86/kernel/irq_64.c:77
 invoke_softirq kernel/softirq.c:387 [inline]
 __irq_exit_rcu kernel/softirq.c:417 [inline]
 irq_exit_rcu+0x150/0x1f0 kernel/softirq.c:429
 sysvec_apic_timer_interrupt+0x49/0xc0 arch/x86/kernel/apic/apic.c:1091
 asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:585
RIP: 0010:orc_find arch/x86/kernel/unwind_orc.c:162 [inline]
RIP: 0010:unwind_next_frame+0x1fe/0x1f60 arch/x86/kernel/unwind_orc.c:446
Code: 43 ff 39 c6 0f 83 fb 10 00 00 48 b8 00 00 00 00 00 fc ff df 89 f2 48 8d 3c 95 b8 bc b0 88 49 89 f8 49 c1 e8 03 45 0f b6 04 00 <48> 89 f8 83 e0 07 83 c0 03 44 38 c0 7c 09 45 84 c0 0f 85 2f 15 00
RSP: 0018:ffff8881d07ff5d0 EFLAGS: 00000a02
RAX: dffffc0000000000 RBX: ffff8881d07ff6a8 RCX: ffffffff816934d1
RDX: 0000000000006934 RSI: 0000000000006934 RDI: ffffffff88b26188
RBP: 1ffff1103a0ffec2 R08: 0000000000000000 R09: ffffffff885a8b84
R10: 000000000001d5c9 R11: 000000000004e017 R12: ffff8881d07ff6f0
R13: ffff8881d07ff6dd R14: ffff8881d07ff6f8 R15: 0000000000000001
 arch_stack_walk+0x81/0xf0 arch/x86/kernel/stacktrace.c:25
 stack_trace_save+0x8c/0xc0 kernel/stacktrace.c:123
 save_stack+0x1b/0x40 mm/kasan/common.c:48
 set_track mm/kasan/common.c:56 [inline]
 __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494
 slab_post_alloc_hook mm/slab.h:586 [inline]
 slab_alloc_node mm/slub.c:2824 [inline]
 slab_alloc mm/slub.c:2832 [inline]
 kmem_cache_alloc+0xd2/0x310 mm/slub.c:2837
 vm_area_dup+0x1c/0x1d0 kernel/fork.c:359
 dup_mmap kernel/fork.c:548 [inline]
 dup_mm+0x44d/0x1110 kernel/fork.c:1371
 copy_mm kernel/fork.c:1427 [inline]
 copy_process+0x27eb/0x63b0 kernel/fork.c:2098
 _do_fork+0x12c/0xa30 kernel/fork.c:2443
 __do_sys_clone+0xef/0x150 kernel/fork.c:2599
 do_syscall_64+0x50/0x90 arch/x86/entry/common.c:384
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7ff5ffed938b
Code: Bad RIP value.
RSP: 002b:00007ffc809ae510 EFLAGS: 00000246 ORIG_RAX: 0000000000000038
RAX: ffffffffffffffda RBX: 00007ffc809ae510 RCX: 00007ff5ffed938b
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000001200011
RBP: 00007ffc809ae560 R08: 00007ff6010898c0 R09: 0000000000000210
R10: 00007ff601089b90 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000020 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 3331:
 save_stack+0x1b/0x40 mm/kasan/common.c:48
 set_track mm/kasan/common.c:56 [inline]
 __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494
 kmalloc include/linux/slab.h:555 [inline]
 kzalloc include/linux/slab.h:669 [inline]
 usblp_probe+0xed/0x11f0 drivers/usb/class/usblp.c:1105
 usb_probe_interface+0x315/0x7f0 drivers/usb/core/driver.c:374
 really_probe+0x291/0xc90 drivers/base/dd.c:520
 driver_probe_device+0x26b/0x3d0 drivers/base/dd.c:696
 __device_attach_driver+0x1d1/0x290 drivers/base/dd.c:802
 bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:431
 __device_attach+0x28d/0x430 drivers/base/dd.c:868
 bus_probe_device+0x1e4/0x290 drivers/base/bus.c:491
 device_add+0xb09/0x1c10 drivers/base/core.c:2700
 usb_set_configuration+0xf05/0x18a0 drivers/usb/core/message.c:2032
 usb_generic_driver_probe+0xba/0xf2 drivers/usb/core/generic.c:241
 usb_probe_device+0xd9/0x250 drivers/usb/core/driver.c:272
 really_probe+0x291/0xc90 drivers/base/dd.c:520
 driver_probe_device+0x26b/0x3d0 drivers/base/dd.c:696
 __device_attach_driver+0x1d1/0x290 drivers/base/dd.c:802
 bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:431
 __device_attach+0x28d/0x430 drivers/base/dd.c:868
 bus_probe_device+0x1e4/0x290 drivers/base/bus.c:491
 device_add+0xb09/0x1c10 drivers/base/core.c:2700
 usb_new_device.cold+0x71d/0xfd4 drivers/usb/core/hub.c:2554
 hub_port_connect drivers/usb/core/hub.c:5208 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5348 [inline]
 port_event drivers/usb/core/hub.c:5494 [inline]
 hub_event+0x2361/0x4390 drivers/usb/core/hub.c:5576
 process_one_work+0x94c/0x15f0 kernel/workqueue.c:2269
 process_scheduled_works kernel/workqueue.c:2331 [inline]
 worker_thread+0x82b/0x1120 kernel/workqueue.c:2417
 kthread+0x392/0x470 kernel/kthread.c:291
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293

Freed by task 3114:
 save_stack+0x1b/0x40 mm/kasan/common.c:48
 set_track mm/kasan/common.c:56 [inline]
 kasan_set_free_info mm/kasan/common.c:316 [inline]
 __kasan_slab_free+0x116/0x160 mm/kasan/common.c:455
 slab_free_hook mm/slub.c:1474 [inline]
 slab_free_freelist_hook+0x53/0x140 mm/slub.c:1507
 slab_free mm/slub.c:3072 [inline]
 kfree+0xbc/0x2c0 mm/slub.c:4052
 usblp_disconnect.cold+0x24/0x29 drivers/usb/class/usblp.c:1382
 usb_unbind_interface+0x1d8/0x8d0 drivers/usb/core/driver.c:436
 __device_release_driver+0x3b7/0x6e0 drivers/base/dd.c:1108
 device_release_driver_internal drivers/base/dd.c:1139 [inline]
 device_release_driver+0x26/0x40 drivers/base/dd.c:1162
 bus_remove_device+0x2eb/0x5a0 drivers/base/bus.c:533
 device_del+0x47c/0xd20 drivers/base/core.c:2877
 usb_disable_device+0x387/0x930 drivers/usb/core/message.c:1245
 usb_disconnect.cold+0x27d/0x780 drivers/usb/core/hub.c:2217
 hub_port_connect drivers/usb/core/hub.c:5059 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5348 [inline]
 port_event drivers/usb/core/hub.c:5494 [inline]
 hub_event+0x1c93/0x4390 drivers/usb/core/hub.c:5576
 process_one_work+0x94c/0x15f0 kernel/workqueue.c:2269
 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415
 kthread+0x392/0x470 kernel/kthread.c:291
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293

The buggy address belongs to the object at ffff8881d9444000
 which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 536 bytes inside of
 1024-byte region [ffff8881d9444000, ffff8881d9444400)
The buggy address belongs to the page:
page:ffffea0007651000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 head:ffffea0007651000 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x200000000010200(slab|head)
raw: 0200000000010200 ffffea000716be00 0000000300000003 ffff8881da002280
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8881d9444100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881d9444180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8881d9444200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff8881d9444280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881d9444300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (9):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-upstream-usb 2020/07/26 02:19 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 9a360a7cae11 1f7cc1ca .config log report
ci2-upstream-usb 2019/12/18 13:10 https://github.com/google/kasan.git usb-fuzzer d533c9925862 64ca0a37 .config log report
ci2-upstream-usb 2019/12/17 16:22 https://github.com/google/kasan.git usb-fuzzer 4cc037ecf2cb 1af3875f .config log report
ci2-upstream-usb 2019/10/11 02:51 https://github.com/google/kasan.git usb-fuzzer 58d5f26a5584 1a3bad90 .config log report
ci2-upstream-usb 2019/07/21 10:21 https://github.com/google/kasan.git usb-fuzzer 6a3599ceaa39 1656845f .config log report
ci2-upstream-usb 2019/07/19 06:42 https://github.com/google/kasan.git usb-fuzzer 6a3599ceaa39 7bb222f7 .config log report
ci2-upstream-usb 2019/07/14 19:05 https://github.com/google/kasan.git usb-fuzzer 6a3599ceaa39 2bbe2f05 .config log report
ci2-upstream-usb 2019/07/06 04:52 https://github.com/google/kasan.git usb-fuzzer 7829a896a587 f62e1e85 .config log report
ci2-upstream-usb 2019/07/02 19:03 https://github.com/google/kasan.git usb-fuzzer 7829a896a587 5f175e9c .config log report
* Struck through repros no longer work on HEAD.