syzbot


KASAN: use-after-free Read in __usb_hcd_giveback_urb

Status: upstream: reported syz repro on 2024/04/06 03:35
Reported-by: syzbot+94936196e16d5ad44ed6@syzkaller.appspotmail.com
First crash: 382d, last: 16d
Bug presence (1)
Date Name Commit Repro Result
2025/03/22 upstream (ToT) 183601b78a9b C Didn't crash
Similar bugs (5)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 KASAN: use-after-free Read in __usb_hcd_giveback_urb 32 36d 529d 0/3 upstream: reported on 2023/11/11 02:11
upstream KASAN: use-after-free Read in __usb_hcd_giveback_urb (2) usb 1 874d 869d 0/28 auto-obsoleted due to no activity on 2023/03/31 19:51
upstream KASAN: use-after-free Read in __usb_hcd_giveback_urb usb 1 1721d 1720d 0/28 auto-closed as invalid on 2020/12/04 05:52
upstream KASAN: slab-use-after-free Read in __usb_hcd_giveback_urb usb 1 612d 611d 0/28 auto-obsoleted due to no activity on 2023/11/28 05:12
upstream KASAN: slab-use-after-free Read in __usb_hcd_giveback_urb (2) usb 213 1d10h 397d 0/28 upstream: reported on 2024/03/22 17:26

Sample crash report:
xpad 1-1:179.65: xpad_irq_in - usb_submit_urb failed with result -19
xpad 1-1:179.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:85 [inline]
BUG: KASAN: use-after-free in do_raw_spin_lock+0x290/0x370 kernel/locking/spinlock_debug.c:114
Read of size 4 at addr ffff888056f2385c by task dhcpcd-run-hook/11288

CPU: 0 PID: 11288 Comm: dhcpcd-run-hook Not tainted 6.1.133-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:316 [inline]
 print_report+0x15f/0x4f0 mm/kasan/report.c:427
 kasan_report+0x136/0x160 mm/kasan/report.c:531
 debug_spin_lock_before kernel/locking/spinlock_debug.c:85 [inline]
 do_raw_spin_lock+0x290/0x370 kernel/locking/spinlock_debug.c:114
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:111 [inline]
 _raw_spin_lock_irqsave+0xdd/0x120 kernel/locking/spinlock.c:162
 __wake_up_common_lock kernel/sched/wait.c:137 [inline]
 __wake_up+0xfd/0x1c0 kernel/sched/wait.c:160
 __usb_hcd_giveback_urb+0x3a8/0x530 drivers/usb/core/hcd.c:1678
 dummy_timer+0x8dc/0x32b0 drivers/usb/gadget/udc/dummy_hcd.c:1994
 __run_hrtimer kernel/time/hrtimer.c:1691 [inline]
 __hrtimer_run_queues+0x5e5/0xe50 kernel/time/hrtimer.c:1755
 hrtimer_run_softirq+0x196/0x2c0 kernel/time/hrtimer.c:1772
 handle_softirqs+0x2ee/0xa40 kernel/softirq.c:578
 __do_softirq kernel/softirq.c:612 [inline]
 invoke_softirq kernel/softirq.c:452 [inline]
 __irq_exit_rcu+0x157/0x240 kernel/softirq.c:661
 irq_exit_rcu+0x5/0x20 kernel/softirq.c:673
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1118 [inline]
 sysvec_apic_timer_interrupt+0xa0/0xc0 arch/x86/kernel/apic/apic.c:1118
 </IRQ>
 <TASK>
 asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:691
RIP: 0010:ma_dead_node lib/maple_tree.c:536 [inline]
RIP: 0010:mas_next_nentry lib/maple_tree.c:4751 [inline]
RIP: 0010:mas_next_entry+0x980/0xfb0 lib/maple_tree.c:4837
Code: 07 e8 74 f5 e2 f6 eb 1d e8 0d ae ca f6 89 c3 31 ff 89 c6 e8 c2 f8 e2 f6 85 db 0f 84 c8 00 00 00 e8 55 f5 e2 f6 48 8b 5c 24 08 <48> b8 00 00 00 00 00 fc ff df 48 8b 4c 24 58 80 3c 01 00 74 08 4c
RSP: 0018:ffffc9000356f1f8 EFLAGS: 00000293
RAX: ffffffff8aa7b4dc RBX: ffffc9000356f378 RCX: ffff88802f5b1dc0
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000000
RBP: 1ffff920006ade73 R08: ffffffff8aa7b4d3 R09: ffffffff8aa7b002
R10: 0000000000000003 R11: ffff88802f5b1dc0 R12: ffff8880250f3a00
R13: 0000000000000001 R14: ffff8880769a2288 R15: ffffc9000356f360
 validate_mm_mt+0x25c/0x670 mm/mmap.c:295
 validate_mm+0x16e/0x380 mm/mmap.c:331
 __vma_adjust+0x1d41/0x1f40 mm/mmap.c:870
 __split_vma+0x36c/0x4c0 mm/mmap.c:-1
 do_mas_align_munmap+0x95f/0x15a0 mm/mmap.c:2489
 do_mas_munmap+0x246/0x2b0 mm/mmap.c:2638
 __mmap_region mm/mmap.c:2686 [inline]
 mmap_region+0x8d4/0x2660 mm/mmap.c:2904
 do_mmap+0x8c5/0xf60 mm/mmap.c:1424
 vm_mmap_pgoff+0x1ca/0x2d0 mm/util.c:520
 ksys_mmap_pgoff+0x4f5/0x6d0 mm/mmap.c:1470
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f526566cb74
Code: 63 08 44 89 e8 5b 41 5c 41 5d c3 41 89 ca 41 f7 c1 ff 0f 00 00 74 0c c7 05 f5 46 01 00 16 00 00 00 eb 17 b8 09 00 00 00 0f 05 <48> 3d 00 f0 ff ff 76 0c f7 d8 89 05 dc 46 01 00 48 83 c8 ff c3 0f
RSP: 002b:00007ffd43c8dd68 EFLAGS: 00000246 ORIG_RAX: 0000000000000009
RAX: ffffffffffffffda RBX: 00007ffd43c8dde0 RCX: 00007f526566cb74
RDX: 0000000000000001 RSI: 0000000000028000 RDI: 00007f5265623000
RBP: 00007ffd43c8e0d0 R08: 0000000000000003 R09: 0000000000097000
R10: 0000000000000812 R11: 0000000000000246 R12: 00007f526564f0c0
R13: 00007ffd43c8e158 R14: 0000000000096066 R15: 0000000000000000
 </TASK>

Allocated by task 4730:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 __kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:383
 kmalloc include/linux/slab.h:563 [inline]
 kzalloc include/linux/slab.h:699 [inline]
 xpad_probe+0x3be/0x1b80 drivers/input/joystick/xpad.c:1967
 usb_probe_interface+0x5c0/0xaf0 drivers/usb/core/driver.c:396
 call_driver_probe drivers/base/dd.c:-1 [inline]
 really_probe+0x2ab/0xcb0 drivers/base/dd.c:639
 __driver_probe_device+0x1a2/0x3d0 drivers/base/dd.c:785
 driver_probe_device+0x50/0x420 drivers/base/dd.c:815
 __device_attach_driver+0x2cf/0x510 drivers/base/dd.c:943
 bus_for_each_drv+0x183/0x200 drivers/base/bus.c:429
 __device_attach+0x359/0x570 drivers/base/dd.c:1015
 bus_probe_device+0xba/0x1e0 drivers/base/bus.c:489
 device_add+0xb48/0xfd0 drivers/base/core.c:3697
 usb_set_configuration+0x19dd/0x2020 drivers/usb/core/message.c:2165
 usb_generic_driver_probe+0x84/0x140 drivers/usb/core/generic.c:238
 usb_probe_device+0x130/0x260 drivers/usb/core/driver.c:293
 call_driver_probe drivers/base/dd.c:-1 [inline]
 really_probe+0x2ab/0xcb0 drivers/base/dd.c:639
 __driver_probe_device+0x1a2/0x3d0 drivers/base/dd.c:785
 driver_probe_device+0x50/0x420 drivers/base/dd.c:815
 __device_attach_driver+0x2cf/0x510 drivers/base/dd.c:943
 bus_for_each_drv+0x183/0x200 drivers/base/bus.c:429
 __device_attach+0x359/0x570 drivers/base/dd.c:1015
 bus_probe_device+0xba/0x1e0 drivers/base/bus.c:489
 device_add+0xb48/0xfd0 drivers/base/core.c:3697
 usb_new_device+0xbdd/0x1900 drivers/usb/core/hub.c:2631
 hub_port_connect drivers/usb/core/hub.c:5489 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5629 [inline]
 port_event drivers/usb/core/hub.c:5785 [inline]
 hub_event+0x2efe/0x5730 drivers/usb/core/hub.c:5867
 process_one_work+0x917/0x1260 kernel/workqueue.c:2292
 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Freed by task 4300:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:516
 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook mm/slub.c:1750 [inline]
 slab_free mm/slub.c:3661 [inline]
 __kmem_cache_free+0x25c/0x3c0 mm/slub.c:3674
 xpad_disconnect+0x355/0x480 drivers/input/joystick/xpad.c:2148
 usb_unbind_interface+0x1cd/0x840 drivers/usb/core/driver.c:458
 device_remove drivers/base/dd.c:550 [inline]
 __device_release_driver drivers/base/dd.c:1260 [inline]
 device_release_driver_internal+0x59e/0x880 drivers/base/dd.c:1286
 bus_remove_device+0x2e5/0x400 drivers/base/bus.c:531
 device_del+0x6e2/0xbd0 drivers/base/core.c:3885
 usb_disable_device+0x3b8/0x840 drivers/usb/core/message.c:1414
 usb_disconnect+0x33c/0x8c0 drivers/usb/core/hub.c:2286
 hub_port_connect drivers/usb/core/hub.c:5333 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5629 [inline]
 port_event drivers/usb/core/hub.c:5785 [inline]
 hub_event+0x1f78/0x5730 drivers/usb/core/hub.c:5867
 process_one_work+0x917/0x1260 kernel/workqueue.c:2292
 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:486
 kvfree_call_rcu+0x116/0x8c0 kernel/rcu/tree.c:3401
 batadv_hardif_release net/batman-adv/hard-interface.c:55 [inline]
 kref_put include/linux/kref.h:65 [inline]
 batadv_hardif_put net/batman-adv/hard-interface.h:95 [inline]
 batadv_hard_if_event+0x77c/0x1550 net/batman-adv/hard-interface.c:1014
 notifier_call_chain kernel/notifier.c:87 [inline]
 raw_notifier_call_chain+0xd0/0x170 kernel/notifier.c:455
 call_netdevice_notifiers_extack net/core/dev.c:2039 [inline]
 call_netdevice_notifiers net/core/dev.c:2053 [inline]
 unregister_netdevice_many+0xe48/0x1710 net/core/dev.c:10978
 default_device_exit_batch+0x98d/0xa20 net/core/dev.c:11491
 ops_exit_list net/core/net_namespace.c:177 [inline]
 cleanup_net+0x886/0xd20 net/core/net_namespace.c:640
 process_one_work+0x917/0x1260 kernel/workqueue.c:2292
 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Second to last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:486
 kvfree_call_rcu+0x116/0x8c0 kernel/rcu/tree.c:3401
 neigh_del net/core/neighbour.c:225 [inline]
 neigh_remove_one+0x5c6/0x6d0 net/core/neighbour.c:246
 neigh_forced_gc net/core/neighbour.c:279 [inline]
 neigh_alloc net/core/neighbour.c:485 [inline]
 ___neigh_create+0x459/0x24b0 net/core/neighbour.c:648
 ip6_finish_output2+0x16ba/0x1700 net/ipv6/ip6_output.c:129
 __ip6_finish_output net/ipv6/ip6_output.c:205 [inline]
 ip6_finish_output+0x6a0/0xa80 net/ipv6/ip6_output.c:216
 dst_output include/net/dst.h:453 [inline]
 NF_HOOK include/linux/netfilter.h:302 [inline]
 ndisc_send_skb+0xbf6/0x15f0 net/ipv6/ndisc.c:513
 addrconf_dad_completed+0x7fc/0xd30 net/ipv6/addrconf.c:4299
 addrconf_dad_work+0xdbe/0x16e0 net/ipv6/addrconf.c:-1
 process_one_work+0x917/0x1260 kernel/workqueue.c:2292
 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

The buggy address belongs to the object at ffff888056f23800
 which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 92 bytes inside of
 1024-byte region [ffff888056f23800, ffff888056f23c00)

The buggy address belongs to the physical page:
page:ffffea00015bc800 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x56f20
head:ffffea00015bc800 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 dead000000000100 dead000000000122 ffff888017c41dc0
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3612, tgid 3612 (klogd), ts 83772306203, free_ts 22967620289
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2532
 prep_new_page mm/page_alloc.c:2539 [inline]
 get_page_from_freelist+0x3731/0x38d0 mm/page_alloc.c:4328
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5606
 alloc_slab_page+0x6a/0x150 mm/slub.c:1794
 allocate_slab mm/slub.c:1939 [inline]
 new_slab+0x84/0x2d0 mm/slub.c:1992
 ___slab_alloc+0xc20/0x1270 mm/slub.c:3180
 __slab_alloc mm/slub.c:3279 [inline]
 slab_alloc_node mm/slub.c:3364 [inline]
 __kmem_cache_alloc_node+0x19f/0x260 mm/slub.c:3437
 kmalloc_trace+0x26/0xe0 mm/slab_common.c:1026
 kmalloc include/linux/slab.h:563 [inline]
 syslog_print+0x10c/0x620 kernel/printk/printk.c:1500
 do_syslog+0x819/0x910 kernel/printk/printk.c:1679
 __do_sys_syslog kernel/printk/printk.c:1771 [inline]
 __se_sys_syslog kernel/printk/printk.c:1769 [inline]
 __x64_sys_syslog+0x78/0x90 kernel/printk/printk.c:1769
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1459 [inline]
 free_pcp_prepare mm/page_alloc.c:1509 [inline]
 free_unref_page_prepare+0x12a6/0x15b0 mm/page_alloc.c:3384
 free_unref_page+0x33/0x3e0 mm/page_alloc.c:3479
 free_contig_range+0x9a/0x150 mm/page_alloc.c:9566
 destroy_args+0xfe/0x997 mm/debug_vm_pgtable.c:1031
 debug_vm_pgtable+0x46d/0x4c2 mm/debug_vm_pgtable.c:1354
 do_one_initcall+0x265/0x8f0 init/main.c:1298
 do_initcall_level+0x157/0x207 init/main.c:1371
 do_initcalls+0x49/0x86 init/main.c:1387
 kernel_init_freeable+0x45c/0x60f init/main.c:1626
 kernel_init+0x19/0x290 init/main.c:1514
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Memory state around the buggy address:
 ffff888056f23700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888056f23780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888056f23800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff888056f23880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888056f23900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
----------------
Code disassembly (best guess), 1 bytes skipped:
   0:	e8 74 f5 e2 f6       	call   0xf6e2f579
   5:	eb 1d                	jmp    0x24
   7:	e8 0d ae ca f6       	call   0xf6caae19
   c:	89 c3                	mov    %eax,%ebx
   e:	31 ff                	xor    %edi,%edi
  10:	89 c6                	mov    %eax,%esi
  12:	e8 c2 f8 e2 f6       	call   0xf6e2f8d9
  17:	85 db                	test   %ebx,%ebx
  19:	0f 84 c8 00 00 00    	je     0xe7
  1f:	e8 55 f5 e2 f6       	call   0xf6e2f579
  24:	48 8b 5c 24 08       	mov    0x8(%rsp),%rbx
* 29:	48 b8 00 00 00 00 00 	movabs $0xdffffc0000000000,%rax <-- trapping instruction
  30:	fc ff df
  33:	48 8b 4c 24 58       	mov    0x58(%rsp),%rcx
  38:	80 3c 01 00          	cmpb   $0x0,(%rcx,%rax,1)
  3c:	74 08                	je     0x46
  3e:	4c                   	rex.WR

Crashes (13):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/04/07 19:38 linux-6.1.y 3dfebb87d7eb a2ada0e7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in __usb_hcd_giveback_urb
2025/03/14 01:34 linux-6.1.y 344a09659766 e2826670 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in __usb_hcd_giveback_urb
2025/02/22 13:34 linux-6.1.y 3a8358583626 d34966d1 .config console log report syz / log [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in __usb_hcd_giveback_urb
2025/02/04 00:58 linux-6.1.y 0cbb5f65e52f 8f267cef .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in __usb_hcd_giveback_urb
2025/01/14 16:36 linux-6.1.y c63962be84ef f310a27d .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in __usb_hcd_giveback_urb
2024/10/31 07:53 linux-6.1.y 7ec6f9fa3d97 96eb609f .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in __usb_hcd_giveback_urb
2024/10/30 04:54 linux-6.1.y 7ec6f9fa3d97 66aeb999 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in __usb_hcd_giveback_urb
2024/10/25 23:36 linux-6.1.y 7ec6f9fa3d97 045e728d .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in __usb_hcd_giveback_urb
2024/07/19 14:55 linux-6.1.y 9b3f9a5b12dc ee4e11c8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in __usb_hcd_giveback_urb
2024/06/20 17:51 linux-6.1.y eb44d83053d6 dac2aa43 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in __usb_hcd_giveback_urb
2024/04/22 01:30 linux-6.1.y 6741e066ec76 af24b050 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in __usb_hcd_giveback_urb
2024/04/15 22:40 linux-6.1.y cd5d98c0556c b9af7e61 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in __usb_hcd_giveback_urb
2024/04/06 03:34 linux-6.1.y 347385861c50 ca620dd8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in __usb_hcd_giveback_urb
* Struck through repros no longer work on HEAD.