syzbot


KASAN: use-after-free Write in hiddev_release

Status: auto-obsoleted due to no activity on 2024/11/15 13:12
Reported-by: syzbot+dbdf7fb3a0cfa7cd7851@syzkaller.appspotmail.com
First crash: 108d, last: 108d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in hiddev_release (2) input usb 1 715d 701d 0/28 auto-obsoleted due to no activity on 2023/04/19 04:42

Sample crash report:
usb 1-1: string descriptor 0 read error: -19
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read_write include/linux/instrumented.h:102 [inline]
BUG: KASAN: use-after-free in atomic_try_cmpxchg_acquire include/linux/atomic/atomic-instrumented.h:541 [inline]
BUG: KASAN: use-after-free in queued_spin_lock include/asm-generic/qspinlock.h:111 [inline]
BUG: KASAN: use-after-free in do_raw_spin_lock include/linux/spinlock.h:187 [inline]
BUG: KASAN: use-after-free in __raw_spin_lock include/linux/spinlock_api_smp.h:134 [inline]
BUG: KASAN: use-after-free in _raw_spin_lock+0x97/0x1b0 kernel/locking/spinlock.c:154
Write of size 4 at addr ffff88810d381218 by task syz.0.2391/9530

CPU: 1 PID: 9530 Comm: syz.0.2391 Not tainted 6.1.90-syzkaller-00020-gd6a513a78492 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:316 [inline]
 print_report+0x158/0x4e0 mm/kasan/report.c:427
 kasan_report+0x13c/0x170 mm/kasan/report.c:531
 kasan_check_range+0x294/0x2a0 mm/kasan/generic.c:189
 __kasan_check_write+0x14/0x20 mm/kasan/shadow.c:37
 instrument_atomic_read_write include/linux/instrumented.h:102 [inline]
 atomic_try_cmpxchg_acquire include/linux/atomic/atomic-instrumented.h:541 [inline]
 queued_spin_lock include/asm-generic/qspinlock.h:111 [inline]
 do_raw_spin_lock include/linux/spinlock.h:187 [inline]
 __raw_spin_lock include/linux/spinlock_api_smp.h:134 [inline]
 _raw_spin_lock+0x97/0x1b0 kernel/locking/spinlock.c:154
 __mutex_unlock_slowpath+0x1c3/0x440 kernel/locking/mutex.c:960
 mutex_unlock+0x17b/0x260 kernel/locking/mutex.c:565
 hiddev_release+0x3a9/0x400 drivers/hid/usbhid/hiddev.c:238
 __fput+0x3ab/0x870 fs/file_table.c:320
 ____fput+0x15/0x20 fs/file_table.c:348
 task_work_run+0x24d/0x2e0 kernel/task_work.c:179
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop+0x94/0xa0 kernel/entry/common.c:177
 exit_to_user_mode_prepare+0x5a/0xa0 kernel/entry/common.c:210
 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline]
 syscall_exit_to_user_mode+0x26/0x130 kernel/entry/common.c:303
 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f3edc179e79
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f3edcefd038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffea RBX: 00007f3edc315f80 RCX: 00007f3edc179e79
RDX: 0000000020000400 RSI: 0000000081044804 RDI: 000000000000000b
RBP: 00007f3edc1e7916 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f3edc315f80 R15: 00007ffd93c95178
 </TASK>

Allocated by task 351:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_alloc_info+0x1f/0x30 mm/kasan/generic.c:505
 ____kasan_kmalloc mm/kasan/common.c:379 [inline]
 __kasan_kmalloc+0x9c/0xb0 mm/kasan/common.c:388
 kasan_kmalloc include/linux/kasan.h:212 [inline]
 kmalloc_trace+0x44/0xa0 mm/slab_common.c:1052
 kmalloc include/linux/slab.h:556 [inline]
 kzalloc include/linux/slab.h:692 [inline]
 hiddev_connect+0x96/0x5c0 drivers/hid/usbhid/hiddev.c:893
 hid_connect+0x534/0x1a90 drivers/hid/hid-core.c:2186
 hid_hw_start+0xa4/0x120 drivers/hid/hid-core.c:2294
 plantronics_probe+0x2d6/0x3b0 drivers/hid/hid-plantronics.c:191
 hid_device_probe+0x292/0x3a0 drivers/hid/hid-core.c:2625
 really_probe+0x2b8/0x920 drivers/base/dd.c:639
 __driver_probe_device+0x1a0/0x310 drivers/base/dd.c:808
 driver_probe_device+0x54/0x3d0 drivers/base/dd.c:838
 __device_attach_driver+0x2e3/0x490 drivers/base/dd.c:966
 bus_for_each_drv+0x183/0x200 drivers/base/bus.c:427
 __device_attach+0x312/0x510 drivers/base/dd.c:1038
 device_initial_probe+0x1a/0x20 drivers/base/dd.c:1087
 bus_probe_device+0xbe/0x1e0 drivers/base/bus.c:487
 device_add+0xb60/0xf10 drivers/base/core.c:3686
 hid_add_device+0x3ad/0x510 drivers/hid/hid-core.c:2777
 usbhid_probe+0xc1f/0xff0 drivers/hid/usbhid/hid-core.c:1424
 usb_probe_interface+0x5b6/0xa90 drivers/usb/core/driver.c:397
 really_probe+0x2b8/0x920 drivers/base/dd.c:639
 __driver_probe_device+0x1a0/0x310 drivers/base/dd.c:808
 driver_probe_device+0x54/0x3d0 drivers/base/dd.c:838
 __device_attach_driver+0x2e3/0x490 drivers/base/dd.c:966
 bus_for_each_drv+0x183/0x200 drivers/base/bus.c:427
 __device_attach+0x312/0x510 drivers/base/dd.c:1038
 device_initial_probe+0x1a/0x20 drivers/base/dd.c:1087
 bus_probe_device+0xbe/0x1e0 drivers/base/bus.c:487
 device_add+0xb60/0xf10 drivers/base/core.c:3686
 usb_set_configuration+0x190f/0x1e80 drivers/usb/core/message.c:2165
 usb_generic_driver_probe+0x8b/0x150 drivers/usb/core/generic.c:238
 usb_probe_device+0x144/0x260 drivers/usb/core/driver.c:294
 really_probe+0x2b8/0x920 drivers/base/dd.c:639
 __driver_probe_device+0x1a0/0x310 drivers/base/dd.c:808
 driver_probe_device+0x54/0x3d0 drivers/base/dd.c:838
 __device_attach_driver+0x2e3/0x490 drivers/base/dd.c:966
 bus_for_each_drv+0x183/0x200 drivers/base/bus.c:427
 __device_attach+0x312/0x510 drivers/base/dd.c:1038
 device_initial_probe+0x1a/0x20 drivers/base/dd.c:1087
 bus_probe_device+0xbe/0x1e0 drivers/base/bus.c:487
 device_add+0xb60/0xf10 drivers/base/core.c:3686
 usb_new_device+0xf2f/0x1820 drivers/usb/core/hub.c:2645
 hub_port_connect drivers/usb/core/hub.c:5553 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5693 [inline]
 port_event drivers/usb/core/hub.c:5853 [inline]
 hub_event+0x2db1/0x4830 drivers/usb/core/hub.c:5935
 process_one_work+0x73d/0xcb0 kernel/workqueue.c:2299
 worker_thread+0xa60/0x1260 kernel/workqueue.c:2446
 kthread+0x26d/0x300 kernel/kthread.c:386
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308

Freed by task 9538:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:516
 ____kasan_slab_free+0x131/0x180 mm/kasan/common.c:241
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:249
 kasan_slab_free include/linux/kasan.h:178 [inline]
 slab_free_hook mm/slub.c:1745 [inline]
 slab_free_freelist_hook mm/slub.c:1771 [inline]
 slab_free mm/slub.c:3684 [inline]
 __kmem_cache_free+0x218/0x3b0 mm/slub.c:3697
 kfree+0x7a/0xf0 mm/slab_common.c:1009
 hiddev_release+0x375/0x400 drivers/hid/usbhid/hiddev.c:232
 __fput+0x3ab/0x870 fs/file_table.c:320
 ____fput+0x15/0x20 fs/file_table.c:348
 task_work_run+0x24d/0x2e0 kernel/task_work.c:179
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop+0x94/0xa0 kernel/entry/common.c:177
 exit_to_user_mode_prepare+0x5a/0xa0 kernel/entry/common.c:210
 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline]
 syscall_exit_to_user_mode+0x26/0x130 kernel/entry/common.c:303
 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb4/0xc0 mm/kasan/generic.c:486
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:496
 kvfree_call_rcu+0x9f/0x800 kernel/rcu/tree.c:3444
 __hw_addr_flush net/core/dev_addr_lists.c:490 [inline]
 dev_addr_flush+0x190/0x230 net/core/dev_addr_lists.c:535
 free_netdev+0x1de/0x480 net/core/dev.c:10751
 netdev_run_todo+0xb7f/0xd00 net/core/dev.c:10413
 rtnl_unlock+0xe/0x10 net/core/rtnetlink.c:147
 ip_tunnel_delete_nets+0x343/0x380 net/ipv4/ip_tunnel.c:1154
 erspan_exit_batch_net+0x22/0x30 net/ipv4/ip_gre.c:1723
 ops_exit_list net/core/net_namespace.c:174 [inline]
 cleanup_net+0x6c9/0xbf0 net/core/net_namespace.c:601
 process_one_work+0x73d/0xcb0 kernel/workqueue.c:2299
 worker_thread+0xa60/0x1260 kernel/workqueue.c:2446
 kthread+0x26d/0x300 kernel/kthread.c:386
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308

Second to last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb4/0xc0 mm/kasan/generic.c:486
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:496
 kvfree_call_rcu+0x9f/0x800 kernel/rcu/tree.c:3444
 drop_sysctl_table+0x311/0x450 fs/proc/proc_sysctl.c:1729
 unregister_sysctl_table+0x76/0x120 fs/proc/proc_sysctl.c:1767
 unregister_net_sysctl_table+0x15/0x20 net/sysctl_net.c:175
 unix_sysctl_unregister+0x5e/0x90 net/unix/sysctl_net_unix.c:57
 unix_net_exit+0x73/0xb0 net/unix/af_unix.c:3670
 ops_exit_list net/core/net_namespace.c:169 [inline]
 cleanup_net+0x64b/0xbf0 net/core/net_namespace.c:601
 process_one_work+0x73d/0xcb0 kernel/workqueue.c:2299
 worker_thread+0xa60/0x1260 kernel/workqueue.c:2446
 kthread+0x26d/0x300 kernel/kthread.c:386
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308

The buggy address belongs to the object at ffff88810d381200
 which belongs to the cache kmalloc-128 of size 128
The buggy address is located 24 bytes inside of
 128-byte region [ffff88810d381200, ffff88810d381280)

The buggy address belongs to the physical page:
page:ffffea000434e040 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10d381
flags: 0x4000000000000200(slab|zone=1)
raw: 4000000000000200 ffffea00043ab940 dead000000000004 ffff888100042a80
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x12c00(GFP_NOIO|__GFP_NOWARN|__GFP_NORETRY), pid 1, tgid 1 (swapper/0), ts 2117655078, free_ts 0
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x213/0x220 mm/page_alloc.c:2590
 prep_new_page+0x1b/0x110 mm/page_alloc.c:2597
 get_page_from_freelist+0x27ea/0x2870 mm/page_alloc.c:4425
 __alloc_pages+0x3a1/0x780 mm/page_alloc.c:5714
 alloc_slab_page+0x6c/0xf0
 allocate_slab mm/slub.c:1962 [inline]
 new_slab+0x90/0x3e0 mm/slub.c:2015
 ___slab_alloc+0x6f9/0xb80 mm/slub.c:3203
 __slab_alloc+0x5d/0xa0 mm/slub.c:3302
 slab_alloc_node mm/slub.c:3387 [inline]
 __kmem_cache_alloc_node+0x1af/0x250 mm/slub.c:3460
 __do_kmalloc_node mm/slab_common.c:956 [inline]
 __kmalloc_node+0xa3/0x1e0 mm/slab_common.c:964
 kmalloc_node include/linux/slab.h:582 [inline]
 kvmalloc_node+0x221/0x640 mm/util.c:592
 kvzalloc_node include/linux/slab.h:713 [inline]
 sbitmap_init_node+0x48b/0x5f0 lib/sbitmap.c:113
 blk_mq_alloc_hctx block/blk-mq.c:3748 [inline]
 blk_mq_alloc_and_init_hctx+0x4d9/0xdd0 block/blk-mq.c:4196
 blk_mq_realloc_hw_ctxs+0x192/0x490 block/blk-mq.c:4229
 blk_mq_init_allocated_queue+0x4c6/0x1660 block/blk-mq.c:4291
 blk_mq_init_queue_data block/blk-mq.c:4101 [inline]
 blk_mq_init_queue+0xa1/0x120 block/blk-mq.c:4111
page_owner free stack trace missing

Memory state around the buggy address:
 ffff88810d381100: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88810d381180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88810d381200: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff88810d381280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88810d381300: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/08/17 13:06 android14-6.1 d6a513a78492 dbc93b08 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in hiddev_release
* Struck through repros no longer work on HEAD.