syzbot


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

Status: auto-obsoleted due to no activity on 2022/09/19 12:39
Reported-by: syzbot+85a77e0b4ff5f6de9418@syzkaller.appspotmail.com
First crash: 423d, last: 198d
similar bugs (3):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in usb_anchor_resume_wakeups 41 863d 1246d 0/24 auto-closed as invalid on 2020/11/24 04:41
upstream KASAN: use-after-free Read in usb_anchor_resume_wakeups (4) 1 71d 66d 0/24 upstream: reported on 2022/10/01 13:43
upstream KASAN: use-after-free Read in usb_anchor_resume_wakeups (2) 4 592d 694d 0/24 auto-closed as invalid on 2021/08/21 21:47

Sample crash report:
xpad 4-1:0.65: xpad_irq_in - usb_submit_urb failed with result -19
xpad 4-1:0.65: xpad_irq_out - usb_submit_urb failed with result -19
==================================================================
BUG: KASAN: use-after-free in register_lock_class+0x112c/0x11b0 kernel/locking/lockdep.c:1306
Read of size 1 at addr ffff888076d65891 by task kworker/u4:19/8803

CPU: 1 PID: 8803 Comm: kworker/u4:19 Not tainted 5.18.0-rc6-syzkaller-00009-gfeb9c5e19e91 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events_unbound call_usermodehelper_exec_work
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0xeb/0x495 mm/kasan/report.c:313
 print_report mm/kasan/report.c:429 [inline]
 kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491
 register_lock_class+0x112c/0x11b0 kernel/locking/lockdep.c:1306
 __lock_acquire+0x10a/0x56c0 kernel/locking/lockdep.c:4908
 lock_acquire kernel/locking/lockdep.c:5641 [inline]
 lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5606
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
 _raw_spin_lock_irqsave+0x39/0x50 kernel/locking/spinlock.c:162
 __wake_up_common_lock+0xb4/0x130 kernel/sched/wait.c:136
 usb_anchor_resume_wakeups drivers/usb/core/urb.c:958 [inline]
 usb_anchor_resume_wakeups+0xbe/0xe0 drivers/usb/core/urb.c:951
 __usb_hcd_giveback_urb+0x2df/0x5c0 drivers/usb/core/hcd.c:1673
 usb_hcd_giveback_urb+0x367/0x410 drivers/usb/core/hcd.c:1747
 dummy_timer+0x11f9/0x32b0 drivers/usb/gadget/udc/dummy_hcd.c:1988
 call_timer_fn+0x1a5/0x6b0 kernel/time/timer.c:1421
 expire_timers kernel/time/timer.c:1466 [inline]
 __run_timers.part.0+0x679/0xa80 kernel/time/timer.c:1737
 __run_timers kernel/time/timer.c:1715 [inline]
 run_timer_softirq+0xb3/0x1d0 kernel/time/timer.c:1750
 __do_softirq+0x29b/0x9c2 kernel/softirq.c:558
 invoke_softirq kernel/softirq.c:432 [inline]
 __irq_exit_rcu+0x123/0x180 kernel/softirq.c:637
 irq_exit_rcu+0x5/0x20 kernel/softirq.c:649
 sysvec_apic_timer_interrupt+0x93/0xc0 arch/x86/kernel/apic/apic.c:1097
 </IRQ>
 <TASK>
 asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:645
RIP: 0010:filter_irq_stacks+0x28/0x90 kernel/stacktrace.c:395
Code: 00 00 41 54 41 89 f4 55 53 48 83 ec 08 85 f6 74 30 48 bd 00 00 00 00 00 fc ff df 31 db 48 89 f8 48 c1 e8 03 80 3c 28 00 75 4b <48> 8b 07 48 3d 00 01 80 89 72 18 48 3d d0 0d 80 89 73 10 44 8d 63
RSP: 0018:ffffc900045f7588 EFLAGS: 00000246
RAX: 1ffff920008beecb RBX: 0000000000000007 RCX: 0000000000000001
RDX: 0000000000000cc0 RSI: 000000000000000d RDI: ffffc900045f7658
RBP: dffffc0000000000 R08: ffffffff8e307d9a R09: ffffc900045f752c
R10: fffff520008beeaa R11: 000000000008a079 R12: 000000000000000d
R13: 0000000000000cc0 R14: ffffc900045f7620 R15: 0000000000000001
 __stack_depot_save+0x35/0x500 lib/stackdepot.c:360
 kasan_save_stack+0x2e/0x40 mm/kasan/common.c:39
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:436 [inline]
 __kasan_slab_alloc+0x90/0xc0 mm/kasan/common.c:469
 kasan_slab_alloc include/linux/kasan.h:224 [inline]
 slab_post_alloc_hook mm/slab.h:749 [inline]
 slab_alloc_node mm/slub.c:3217 [inline]
 slab_alloc mm/slub.c:3225 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3232 [inline]
 kmem_cache_alloc+0x204/0x3b0 mm/slub.c:3242
 prepare_creds+0x3f/0x7b0 kernel/cred.c:260
 copy_creds+0xa3/0xd50 kernel/cred.c:365
 copy_process+0xf30/0x6fe0 kernel/fork.c:2094
 kernel_clone+0xe7/0xab0 kernel/fork.c:2639
 kernel_thread+0xb5/0xf0 kernel/fork.c:2691
 call_usermodehelper_exec_work kernel/umh.c:174 [inline]
 call_usermodehelper_exec_work+0xcc/0x180 kernel/umh.c:160
 process_one_work+0x996/0x1610 kernel/workqueue.c:2289
 worker_thread+0x665/0x1080 kernel/workqueue.c:2436
 kthread+0x2e9/0x3a0 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298
 </TASK>

Allocated by task 7718:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:436 [inline]
 ____kasan_kmalloc mm/kasan/common.c:515 [inline]
 ____kasan_kmalloc mm/kasan/common.c:474 [inline]
 __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:524
 kmalloc include/linux/slab.h:581 [inline]
 kzalloc include/linux/slab.h:714 [inline]
 xpad_probe+0x26c/0x1c20 drivers/input/joystick/xpad.c:1757
 usb_probe_interface+0x315/0x7f0 drivers/usb/core/driver.c:396
 call_driver_probe drivers/base/dd.c:542 [inline]
 really_probe+0x23e/0xb20 drivers/base/dd.c:621
 __driver_probe_device+0x338/0x4d0 drivers/base/dd.c:752
 driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:782
 __device_attach_driver+0x20b/0x2f0 drivers/base/dd.c:899
 bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:427
 __device_attach+0x228/0x4a0 drivers/base/dd.c:970
 bus_probe_device+0x1e4/0x290 drivers/base/bus.c:487
 device_add+0xb83/0x1e20 drivers/base/core.c:3405
 usb_set_configuration+0x101e/0x1900 drivers/usb/core/message.c:2170
 usb_generic_driver_probe+0xba/0x100 drivers/usb/core/generic.c:238
 usb_probe_device+0xd9/0x2c0 drivers/usb/core/driver.c:293
 call_driver_probe drivers/base/dd.c:542 [inline]
 really_probe+0x23e/0xb20 drivers/base/dd.c:621
 __driver_probe_device+0x338/0x4d0 drivers/base/dd.c:752
 driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:782
 __device_attach_driver+0x20b/0x2f0 drivers/base/dd.c:899
 bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:427
 __device_attach+0x228/0x4a0 drivers/base/dd.c:970
 bus_probe_device+0x1e4/0x290 drivers/base/bus.c:487
 device_add+0xb83/0x1e20 drivers/base/core.c:3405
 usb_new_device.cold+0x641/0x1091 drivers/usb/core/hub.c:2566
 hub_port_connect drivers/usb/core/hub.c:5363 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5507 [inline]
 port_event drivers/usb/core/hub.c:5665 [inline]
 hub_event+0x25c6/0x4680 drivers/usb/core/hub.c:5747
 process_one_work+0x996/0x1610 kernel/workqueue.c:2289
 worker_thread+0x665/0x1080 kernel/workqueue.c:2436
 kthread+0x2e9/0x3a0 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

Freed by task 11761:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track+0x21/0x30 mm/kasan/common.c:45
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
 ____kasan_slab_free mm/kasan/common.c:366 [inline]
 ____kasan_slab_free+0x166/0x1a0 mm/kasan/common.c:328
 kasan_slab_free include/linux/kasan.h:200 [inline]
 slab_free_hook mm/slub.c:1728 [inline]
 slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1754
 slab_free mm/slub.c:3510 [inline]
 kfree+0xd6/0x4d0 mm/slub.c:4552
 xpad_disconnect+0x1cb/0x530 drivers/input/joystick/xpad.c:1905
 usb_unbind_interface+0x1d8/0x8e0 drivers/usb/core/driver.c:458
 device_remove drivers/base/dd.c:532 [inline]
 device_remove+0x11f/0x170 drivers/base/dd.c:524
 __device_release_driver drivers/base/dd.c:1200 [inline]
 device_release_driver_internal+0x4a3/0x680 drivers/base/dd.c:1223
 bus_remove_device+0x2eb/0x5a0 drivers/base/bus.c:529
 device_del+0x4f3/0xc80 drivers/base/core.c:3592
 usb_disable_device+0x35b/0x7b0 drivers/usb/core/message.c:1419
 usb_disconnect.cold+0x278/0x6ec drivers/usb/core/hub.c:2228
 hub_port_connect drivers/usb/core/hub.c:5207 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5507 [inline]
 port_event drivers/usb/core/hub.c:5665 [inline]
 hub_event+0x1e74/0x4680 drivers/usb/core/hub.c:5747
 process_one_work+0x996/0x1610 kernel/workqueue.c:2289
 worker_thread+0x665/0x1080 kernel/workqueue.c:2436
 kthread+0x2e9/0x3a0 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

Last potentially related work creation:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:348
 call_rcu+0x99/0x790 kernel/rcu/tree.c:3074
 pwq_unbound_release_workfn+0x267/0x340 kernel/workqueue.c:3729
 process_one_work+0x996/0x1610 kernel/workqueue.c:2289
 worker_thread+0x665/0x1080 kernel/workqueue.c:2436
 kthread+0x2e9/0x3a0 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

Second to last potentially related work creation:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:348
 call_rcu+0x99/0x790 kernel/rcu/tree.c:3074
 rxrpc_lookup_local+0xc66/0x1050 net/rxrpc/local_object.c:253
 rxrpc_sendmsg+0x369/0x630 net/rxrpc/af_rxrpc.c:542
 sock_sendmsg_nosec net/socket.c:705 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:725
 ____sys_sendmsg+0x6e2/0x800 net/socket.c:2413
 __sys_sendmsg_sock+0x26/0x30 net/socket.c:2479
 io_sendmsg+0x1da/0x5a0 fs/io_uring.c:5254
 io_issue_sqe+0x3683/0x8a00 fs/io_uring.c:7163
 __io_queue_sqe fs/io_uring.c:7512 [inline]
 io_queue_sqe fs/io_uring.c:7554 [inline]
 io_submit_sqe fs/io_uring.c:7759 [inline]
 io_submit_sqes+0x22be/0x98b0 fs/io_uring.c:7865
 __do_sys_io_uring_enter+0x119b/0x21d0 fs/io_uring.c:10810
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

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

The buggy address belongs to the physical page:
page:ffffea0001db5800 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x76d60
head:ffffea0001db5800 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000001 ffff888010c41dc0
raw: 0000000000000000 0000000080100010 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 0xd2a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3592, tgid 3589 (syz-fuzzer), ts 58847911762, free_ts 58840253313
 prep_new_page mm/page_alloc.c:2441 [inline]
 get_page_from_freelist+0xba2/0x3e00 mm/page_alloc.c:4182
 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5408
 alloc_pages+0x1aa/0x310 mm/mempolicy.c:2272
 alloc_slab_page mm/slub.c:1799 [inline]
 allocate_slab+0x26c/0x3c0 mm/slub.c:1944
 new_slab mm/slub.c:2004 [inline]
 ___slab_alloc+0x8df/0xf20 mm/slub.c:3005
 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3092
 slab_alloc_node mm/slub.c:3183 [inline]
 __kmalloc_node_track_caller+0x2cb/0x360 mm/slub.c:4947
 kmalloc_reserve net/core/skbuff.c:354 [inline]
 __alloc_skb+0xde/0x340 net/core/skbuff.c:426
 alloc_skb include/linux/skbuff.h:1300 [inline]
 __tcp_send_ack.part.0+0x67/0x760 net/ipv4/tcp_output.c:3945
 __tcp_send_ack net/ipv4/tcp_output.c:3977 [inline]
 tcp_send_ack+0x7d/0xa0 net/ipv4/tcp_output.c:3977
 tcp_cleanup_rbuf+0x46c/0x5b0 net/ipv4/tcp.c:1589
 tcp_recvmsg_locked+0x73e/0x1fd0 net/ipv4/tcp.c:2544
 tcp_recvmsg+0x137/0x610 net/ipv4/tcp.c:2574
 inet_recvmsg+0x11b/0x5e0 net/ipv4/af_inet.c:850
 sock_recvmsg_nosec net/socket.c:948 [inline]
 sock_recvmsg net/socket.c:966 [inline]
 sock_recvmsg net/socket.c:962 [inline]
 sock_read_iter+0x336/0x470 net/socket.c:1039
 call_read_iter include/linux/fs.h:2044 [inline]
 new_sync_read+0x4f9/0x5f0 fs/read_write.c:401
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1356 [inline]
 free_pcp_prepare+0x549/0xd20 mm/page_alloc.c:1406
 free_unref_page_prepare mm/page_alloc.c:3328 [inline]
 free_unref_page+0x19/0x6a0 mm/page_alloc.c:3423
 __put_page+0x17d/0x280 mm/swap.c:127
 folio_put include/linux/mm.h:1200 [inline]
 put_page include/linux/mm.h:1233 [inline]
 __skb_frag_unref include/linux/skbuff.h:3330 [inline]
 skb_release_data+0x513/0x810 net/core/skbuff.c:672
 skb_release_all net/core/skbuff.c:742 [inline]
 __kfree_skb+0x46/0x60 net/core/skbuff.c:756
 __sk_defer_free_flush net/ipv4/tcp.c:1601 [inline]
 sk_defer_free_flush include/net/tcp.h:1388 [inline]
 tcp_recvmsg+0x1ca/0x610 net/ipv4/tcp.c:2577
 inet_recvmsg+0x11b/0x5e0 net/ipv4/af_inet.c:850
 sock_recvmsg_nosec net/socket.c:948 [inline]
 sock_recvmsg net/socket.c:966 [inline]
 sock_recvmsg net/socket.c:962 [inline]
 sock_read_iter+0x336/0x470 net/socket.c:1039
 call_read_iter include/linux/fs.h:2044 [inline]
 new_sync_read+0x4f9/0x5f0 fs/read_write.c:401
 vfs_read+0x492/0x5d0 fs/read_write.c:482
 ksys_read+0x1e8/0x250 fs/read_write.c:620
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Memory state around the buggy address:
 ffff888076d65780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888076d65800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888076d65880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                         ^
 ffff888076d65900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888076d65980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
----------------
Code disassembly (best guess):
   0:	00 00                	add    %al,(%rax)
   2:	41 54                	push   %r12
   4:	41 89 f4             	mov    %esi,%r12d
   7:	55                   	push   %rbp
   8:	53                   	push   %rbx
   9:	48 83 ec 08          	sub    $0x8,%rsp
   d:	85 f6                	test   %esi,%esi
   f:	74 30                	je     0x41
  11:	48 bd 00 00 00 00 00 	movabs $0xdffffc0000000000,%rbp
  18:	fc ff df
  1b:	31 db                	xor    %ebx,%ebx
  1d:	48 89 f8             	mov    %rdi,%rax
  20:	48 c1 e8 03          	shr    $0x3,%rax
  24:	80 3c 28 00          	cmpb   $0x0,(%rax,%rbp,1)
  28:	75 4b                	jne    0x75
* 2a:	48 8b 07             	mov    (%rdi),%rax <-- trapping instruction
  2d:	48 3d 00 01 80 89    	cmp    $0xffffffff89800100,%rax
  33:	72 18                	jb     0x4d
  35:	48 3d d0 0d 80 89    	cmp    $0xffffffff89800dd0,%rax
  3b:	73 10                	jae    0x4d
  3d:	44                   	rex.R
  3e:	8d                   	.byte 0x8d
  3f:	63                   	.byte 0x63

Crashes (6):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce 2022/05/12 16:05 upstream feb9c5e19e91 9ad6612a .config log report info KASAN: use-after-free Read in usb_anchor_resume_wakeups
ci-upstream-kasan-gce-selinux-root 2022/04/14 18:05 upstream a19944809fe9 b17b2923 .config log report info KASAN: use-after-free Read in usb_anchor_resume_wakeups
ci-upstream-kasan-gce 2021/10/10 06:43 upstream 7fd2bf83d59a 838e7e2c .config log report info KASAN: use-after-free Read in usb_anchor_resume_wakeups
ci2-upstream-usb 2022/05/22 12:38 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 97fa5887cf28 7268fa62 .config log report info KASAN: use-after-free Read in usb_anchor_resume_wakeups
ci2-upstream-usb 2022/04/22 15:55 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 5c29e8649997 2738b391 .config log report info KASAN: use-after-free Read in usb_anchor_resume_wakeups
ci2-upstream-usb 2021/12/18 04:30 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing f2b42379c576 44068e19 .config log report info KASAN: use-after-free Read in usb_anchor_resume_wakeups
* Struck through repros no longer work on HEAD.