syzbot


KASAN: slab-use-after-free Read in hiddev_disconnect

Status: auto-obsoleted due to no activity on 2023/11/20 22:03
Subsystems: input usb
[Documentation on labels]
Reported-by: syzbot+2a00772c09d79651bd74@syzkaller.appspotmail.com
First crash: 222d, last: 194d
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in hiddev_disconnect (4) input usb 1 541d 536d 0/26 auto-obsoleted due to no activity on 2023/01/07 23:19
upstream KASAN: use-after-free Read in hiddev_disconnect (5) input usb 1 409d 404d 0/26 auto-obsoleted due to no activity on 2023/05/19 23:02
upstream KASAN: use-after-free Read in hiddev_disconnect (3) input usb 1 667d 667d 0/26 auto-obsoleted due to no activity on 2022/09/03 10:29
upstream KASAN: use-after-free Read in hiddev_disconnect (2) input usb 1 833d 829d 0/26 auto-closed as invalid on 2022/02/19 22:15

Sample crash report:
usb 4-1: USB disconnect, device number 12
==================================================================
BUG: KASAN: slab-use-after-free in debug_spin_lock_before kernel/locking/spinlock_debug.c:85 [inline]
BUG: KASAN: slab-use-after-free in do_raw_spin_lock+0x26f/0x2b0 kernel/locking/spinlock_debug.c:114
Read of size 4 at addr ffff88804226e41c by task kworker/1:18/10317

CPU: 1 PID: 10317 Comm: kworker/1:18 Not tainted 6.5.0-rc7-syzkaller-00013-g53663f4103ff #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023
Workqueue: usb_hub_wq hub_event
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:364 [inline]
 print_report+0xc4/0x620 mm/kasan/report.c:475
 kasan_report+0xda/0x110 mm/kasan/report.c:588
 debug_spin_lock_before kernel/locking/spinlock_debug.c:85 [inline]
 do_raw_spin_lock+0x26f/0x2b0 kernel/locking/spinlock_debug.c:114
 __mutex_unlock_slowpath+0x198/0x640 kernel/locking/mutex.c:932
 hiddev_disconnect+0x15b/0x1c0 drivers/hid/usbhid/hiddev.c:940
 hid_disconnect+0xb8/0x1b0 drivers/hid/hid-core.c:2275
 hid_hw_stop drivers/hid/hid-core.c:2322 [inline]
 hid_device_remove+0x1a5/0x250 drivers/hid/hid-core.c:2684
 device_remove+0xc8/0x170 drivers/base/dd.c:567
 __device_release_driver drivers/base/dd.c:1270 [inline]
 device_release_driver_internal+0x44a/0x610 drivers/base/dd.c:1293
 bus_remove_device+0x22c/0x420 drivers/base/bus.c:574
 device_del+0x39a/0xa40 drivers/base/core.c:3814
 hid_remove_device drivers/hid/hid-core.c:2859 [inline]
 hid_destroy_device+0xe5/0x150 drivers/hid/hid-core.c:2879
 usbhid_disconnect+0xa0/0xe0 drivers/hid/usbhid/hid-core.c:1456
 usb_unbind_interface+0x1dd/0x8d0 drivers/usb/core/driver.c:458
 device_remove drivers/base/dd.c:569 [inline]
 device_remove+0x11f/0x170 drivers/base/dd.c:561
 __device_release_driver drivers/base/dd.c:1270 [inline]
 device_release_driver_internal+0x44a/0x610 drivers/base/dd.c:1293
 bus_remove_device+0x22c/0x420 drivers/base/bus.c:574
 device_del+0x39a/0xa40 drivers/base/core.c:3814
 usb_disable_device+0x36c/0x7f0 drivers/usb/core/message.c:1420
 usb_disconnect+0x2e1/0x890 drivers/usb/core/hub.c:2253
 hub_port_connect drivers/usb/core/hub.c:5261 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5566 [inline]
 port_event drivers/usb/core/hub.c:5726 [inline]
 hub_event+0x21bd/0x5230 drivers/usb/core/hub.c:5808
 process_one_work+0xaa2/0x16f0 kernel/workqueue.c:2600
 worker_thread+0x687/0x1110 kernel/workqueue.c:2751
 kthread+0x33a/0x430 kernel/kthread.c:389
 ret_from_fork+0x2c/0x70 arch/x86/kernel/process.c:145
 ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304
 </TASK>

Allocated by task 10317:
 kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
 kasan_set_track+0x25/0x30 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 __kasan_kmalloc+0xa2/0xb0 mm/kasan/common.c:383
 kmalloc include/linux/slab.h:582 [inline]
 kzalloc include/linux/slab.h:703 [inline]
 hiddev_connect+0x262/0x630 drivers/hid/usbhid/hiddev.c:893
 hid_connect+0x25e/0x18a0 drivers/hid/hid-core.c:2192
 hid_hw_start drivers/hid/hid-core.c:2302 [inline]
 hid_hw_start+0xa0/0x130 drivers/hid/hid-core.c:2293
 plantronics_probe+0x2f0/0x3f0 drivers/hid/hid-plantronics.c:191
 __hid_device_probe drivers/hid/hid-core.c:2626 [inline]
 hid_device_probe+0x2e4/0x480 drivers/hid/hid-core.c:2663
 call_driver_probe drivers/base/dd.c:579 [inline]
 really_probe+0x234/0xc90 drivers/base/dd.c:658
 __driver_probe_device+0x1de/0x4b0 drivers/base/dd.c:798
 driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:828
 __device_attach_driver+0x1d4/0x300 drivers/base/dd.c:956
 bus_for_each_drv+0x157/0x1d0 drivers/base/bus.c:457
 __device_attach+0x1e8/0x4b0 drivers/base/dd.c:1028
 bus_probe_device+0x17c/0x1c0 drivers/base/bus.c:532
 device_add+0x11f1/0x1b40 drivers/base/core.c:3625
 hid_add_device+0x371/0xa60 drivers/hid/hid-core.c:2809
 usbhid_probe+0xd0a/0x1360 drivers/hid/usbhid/hid-core.c:1429
 usb_probe_interface+0x307/0x930 drivers/usb/core/driver.c:396
 call_driver_probe drivers/base/dd.c:579 [inline]
 really_probe+0x234/0xc90 drivers/base/dd.c:658
 __driver_probe_device+0x1de/0x4b0 drivers/base/dd.c:798
 driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:828
 __device_attach_driver+0x1d4/0x300 drivers/base/dd.c:956
 bus_for_each_drv+0x157/0x1d0 drivers/base/bus.c:457
 __device_attach+0x1e8/0x4b0 drivers/base/dd.c:1028
 bus_probe_device+0x17c/0x1c0 drivers/base/bus.c:532
 device_add+0x11f1/0x1b40 drivers/base/core.c:3625
 usb_set_configuration+0x10cb/0x1c40 drivers/usb/core/message.c:2211
 usb_generic_driver_probe+0xca/0x130 drivers/usb/core/generic.c:238
 usb_probe_device+0xda/0x2c0 drivers/usb/core/driver.c:293
 call_driver_probe drivers/base/dd.c:579 [inline]
 really_probe+0x234/0xc90 drivers/base/dd.c:658
 __driver_probe_device+0x1de/0x4b0 drivers/base/dd.c:798
 driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:828
 __device_attach_driver+0x1d4/0x300 drivers/base/dd.c:956
 bus_for_each_drv+0x157/0x1d0 drivers/base/bus.c:457
 __device_attach+0x1e8/0x4b0 drivers/base/dd.c:1028
 bus_probe_device+0x17c/0x1c0 drivers/base/bus.c:532
 device_add+0x11f1/0x1b40 drivers/base/core.c:3625
 usb_new_device+0xd80/0x1960 drivers/usb/core/hub.c:2590
 hub_port_connect drivers/usb/core/hub.c:5422 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5566 [inline]
 port_event drivers/usb/core/hub.c:5726 [inline]
 hub_event+0x307f/0x5230 drivers/usb/core/hub.c:5808
 process_one_work+0xaa2/0x16f0 kernel/workqueue.c:2600
 worker_thread+0x687/0x1110 kernel/workqueue.c:2751
 kthread+0x33a/0x430 kernel/kthread.c:389
 ret_from_fork+0x2c/0x70 arch/x86/kernel/process.c:145
 ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304

Freed by task 12724:
 kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
 kasan_set_track+0x25/0x30 mm/kasan/common.c:52
 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:522
 ____kasan_slab_free mm/kasan/common.c:236 [inline]
 ____kasan_slab_free+0x15e/0x1b0 mm/kasan/common.c:200
 kasan_slab_free include/linux/kasan.h:162 [inline]
 slab_free_hook mm/slub.c:1792 [inline]
 slab_free_freelist_hook+0x10b/0x1e0 mm/slub.c:1818
 slab_free mm/slub.c:3801 [inline]
 __kmem_cache_free+0xb8/0x2f0 mm/slub.c:3814
 hiddev_release+0x408/0x520 drivers/hid/usbhid/hiddev.c:232
 __fput+0x3f7/0xac0 fs/file_table.c:384
 task_work_run+0x14d/0x240 kernel/task_work.c:179
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
 exit_to_user_mode_prepare+0x210/0x240 kernel/entry/common.c:204
 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline]
 syscall_exit_to_user_mode+0x1d/0x60 kernel/entry/common.c:297
 do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Last potentially related work creation:
 kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:492
 insert_work+0x4a/0x330 kernel/workqueue.c:1556
 __queue_work+0x5f5/0x1040 kernel/workqueue.c:1717
 call_timer_fn+0x1a0/0x580 kernel/time/timer.c:1700
 expire_timers kernel/time/timer.c:1746 [inline]
 __run_timers+0x585/0xb10 kernel/time/timer.c:2022
 run_timer_softirq+0x58/0xd0 kernel/time/timer.c:2035
 __do_softirq+0x218/0x965 kernel/softirq.c:553

Second to last potentially related work creation:
 kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:492
 __call_rcu_common.constprop.0+0x9a/0x790 kernel/rcu/tree.c:2649
 fib6_info_release include/net/ip6_fib.h:337 [inline]
 fib6_info_release include/net/ip6_fib.h:334 [inline]
 ip6_route_add+0x12f/0x150 net/ipv6/route.c:3846
 addrconf_prefix_route+0x300/0x510 net/ipv6/addrconf.c:2424
 add_v4_addrs+0x6b5/0x9c0 net/ipv6/addrconf.c:3174
 addrconf_sit_config net/ipv6/addrconf.c:3423 [inline]
 addrconf_init_auto_addrs+0x4e1/0x810 net/ipv6/addrconf.c:3460
 addrconf_notify+0xe77/0x1940 net/ipv6/addrconf.c:3647
 notifier_call_chain+0xb6/0x3b0 kernel/notifier.c:93
 call_netdevice_notifiers_info+0xb9/0x130 net/core/dev.c:1962
 call_netdevice_notifiers_extack net/core/dev.c:2000 [inline]
 call_netdevice_notifiers net/core/dev.c:2014 [inline]
 dev_open net/core/dev.c:1483 [inline]
 dev_open+0x13c/0x150 net/core/dev.c:1471
 addrconf_set_sit_dstaddr net/ipv6/addrconf.c:2868 [inline]
 addrconf_set_dstaddr+0x29e/0x300 net/ipv6/addrconf.c:2890
 inet6_ioctl+0x1f6/0x2a0 net/ipv6/af_inet6.c:576
 sock_do_ioctl+0x115/0x290 net/socket.c:1190
 sock_ioctl+0x205/0x6e0 net/socket.c:1307
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl fs/ioctl.c:856 [inline]
 __x64_sys_ioctl+0x18f/0x210 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff88804226e400
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 28 bytes inside of
 freed 512-byte region [ffff88804226e400, ffff88804226e600)

The buggy address belongs to the physical page:
page:ffffea0001089b00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x4226c
head:ffffea0001089b00 order:2 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000010200 ffff888012841c80 dead000000000100 dead000000000122
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5062, tgid 5062 (syz-executor.4), ts 150805289774, free_ts 10293997549
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x2d2/0x350 mm/page_alloc.c:1570
 prep_new_page mm/page_alloc.c:1577 [inline]
 get_page_from_freelist+0x10a9/0x31e0 mm/page_alloc.c:3221
 __alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4477
 alloc_pages+0x1a9/0x270 mm/mempolicy.c:2292
 alloc_slab_page mm/slub.c:1862 [inline]
 allocate_slab+0x24e/0x380 mm/slub.c:2009
 new_slab mm/slub.c:2062 [inline]
 ___slab_alloc+0x8bc/0x1570 mm/slub.c:3215
 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3314
 __slab_alloc_node mm/slub.c:3367 [inline]
 slab_alloc_node mm/slub.c:3460 [inline]
 __kmem_cache_alloc_node+0x137/0x350 mm/slub.c:3509
 kmalloc_trace+0x25/0xe0 mm/slab_common.c:1076
 kmalloc include/linux/slab.h:582 [inline]
 kzalloc include/linux/slab.h:703 [inline]
 device_private_init drivers/base/core.c:3471 [inline]
 device_add+0xd0c/0x1b40 drivers/base/core.c:3522
 netdev_register_kobject+0x183/0x3f0 net/core/net-sysfs.c:2043
 register_netdevice+0xd4c/0x1630 net/core/dev.c:10051
 register_vlan_dev+0x36a/0x930 net/8021q/vlan.c:179
 vlan_newlink+0x439/0x6d0 net/8021q/vlan_netlink.c:191
 rtnl_newlink_create net/core/rtnetlink.c:3472 [inline]
 __rtnl_newlink+0x115e/0x18c0 net/core/rtnetlink.c:3689
 rtnl_newlink+0x67/0xa0 net/core/rtnetlink.c:3702
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1161 [inline]
 free_unref_page_prepare+0x508/0xb90 mm/page_alloc.c:2348
 free_unref_page+0x33/0x3b0 mm/page_alloc.c:2443
 free_contig_range+0xb6/0x190 mm/page_alloc.c:6395
 destroy_args+0x686/0x940 mm/debug_vm_pgtable.c:1029
 debug_vm_pgtable+0x2339/0x3ff0 mm/debug_vm_pgtable.c:1410
 do_one_initcall+0x117/0x630 init/main.c:1232
 do_initcall_level init/main.c:1294 [inline]
 do_initcalls init/main.c:1310 [inline]
 do_basic_setup init/main.c:1329 [inline]
 kernel_init_freeable+0x5bd/0x8f0 init/main.c:1546
 kernel_init+0x1c/0x2a0 init/main.c:1437
 ret_from_fork+0x2c/0x70 arch/x86/kernel/process.c:145
 ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304

Memory state around the buggy address:
 ffff88804226e300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88804226e380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88804226e400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff88804226e480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88804226e500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/08/22 22:02 upstream 53663f4103ff b81ca3f6 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in hiddev_disconnect
2023/07/26 02:23 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 7713aaf46459 6756545c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: slab-use-after-free Read in hiddev_disconnect
* Struck through repros no longer work on HEAD.