[moderation] [input?] [usb?] KASAN: slab-use-after-free Read in hiddev_disconnect

5 views
Skip to first unread message

syzbot

unread,
Jul 29, 2023, 10:27:44 PM7/29/23
to syzkaller-upst...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 7713aaf46459 USB: document ioctl USBDEVFS_GET_SPEED
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
console output: https://syzkaller.appspot.com/x/log.txt?x=1611f086a80000
kernel config: https://syzkaller.appspot.com/x/.config?x=30cb3c1e780cdb62
dashboard link: https://syzkaller.appspot.com/bug?extid=2a00772c09d79651bd74
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
CC: [benjamin....@redhat.com ji...@kernel.org linux...@vger.kernel.org linux-...@vger.kernel.org linu...@vger.kernel.org]

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/329c03e8545c/disk-7713aaf4.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/fce5640a45e0/vmlinux-7713aaf4.xz
kernel image: https://storage.googleapis.com/syzbot-assets/cbcaf27c0325/bzImage-7713aaf4.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+2a0077...@syzkaller.appspotmail.com

==================================================================
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 ffff888107f9681c by task kworker/0:7/5822

CPU: 0 PID: 5822 Comm: kworker/0:7 Not tainted 6.5.0-rc3-syzkaller-00020-g7713aaf46459 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2023
Workqueue: events __usb_queue_reset_device
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
usb_driver_release_interface drivers/usb/core/driver.c:627 [inline]
usb_forced_unbind_intf+0x140/0x220 drivers/usb/core/driver.c:1118
unbind_marked_interfaces.isra.0+0x170/0x1e0 drivers/usb/core/driver.c:1141
usb_unbind_and_rebind_marked_interfaces+0x38/0x80 drivers/usb/core/driver.c:1202
usb_reset_device+0x85a/0xad0 drivers/usb/core/hub.c:6229
__usb_queue_reset_device+0x6c/0xa0 drivers/usb/core/message.c:1906
process_one_work+0xaa2/0x16f0 kernel/workqueue.c:2597
process_scheduled_works kernel/workqueue.c:2664 [inline]
worker_thread+0x896/0x1110 kernel/workqueue.c:2750
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:296
RIP: 0000:0x0
Code: Unable to access opcode bytes at 0xffffffffffffffd6.
RSP: 0000:0000000000000000 EFLAGS: 00000000 ORIG_RAX: 0000000000000000
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
</TASK>

Allocated by task 5287:
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+0x87/0x90 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:2212
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+0x30fd/0x5330 drivers/usb/core/hub.c:5808
process_one_work+0xaa2/0x16f0 kernel/workqueue.c:2597
worker_thread+0x687/0x1110 kernel/workqueue.c:2748
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:296

Freed by task 12437:
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+0x13f/0x190 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 mm/slub.c:1818 [inline]
slab_free mm/slub.c:3801 [inline]
__kmem_cache_free+0xff/0x340 mm/slub.c:3814
hiddev_release+0x408/0x520 drivers/hid/usbhid/hiddev.c:232
__fput+0x3fd/0xac0 fs/file_table.c:384
task_work_run+0x14d/0x240 kernel/task_work.c:179
exit_task_work include/linux/task_work.h:38 [inline]
do_exit+0xa99/0x2990 kernel/exit.c:874
do_group_exit+0xd4/0x2a0 kernel/exit.c:1024
get_signal+0x23f3/0x2770 kernel/signal.c:2877
arch_do_signal_or_restart+0x89/0x5f0 arch/x86/kernel/signal.c:308
exit_to_user_mode_loop kernel/entry/common.c:168 [inline]
exit_to_user_mode_prepare+0x116/0x1f0 kernel/entry/common.c:204
__syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline]
syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:297
do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd

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

The buggy address belongs to the physical page:
page:ffffea00041fe500 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888107f96c00 pfn:0x107f94
head:ffffea00041fe500 order:2 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x200000000010200(slab|head|node=0|zone=2)
page_type: 0xffffffff()
raw: 0200000000010200 ffff888100041c80 ffffea000458f710 ffff8881000407c8
raw: ffff888107f96c00 000000000010000e 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 841, tgid 841 (kworker/u4:1), ts 8034996772, free_ts 0
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+0x10e1/0x2fd0 mm/page_alloc.c:3221
__alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4477
alloc_pages+0x1a9/0x270 mm/mempolicy.c:2279
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+0x132/0x310 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]
alloc_bprm+0x51/0xaf0 fs/exec.c:1513
kernel_execve+0xaf/0x4e0 fs/exec.c:1988
call_usermodehelper_exec_async+0x256/0x4c0 kernel/umh.c:110
ret_from_fork+0x2c/0x70 arch/x86/kernel/process.c:145
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:296
page_owner free stack trace missing

Memory state around the buggy address:
ffff888107f96700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888107f96780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888107f96800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888107f96880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888107f96900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to change bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
Nov 20, 2023, 5:03:23 PM11/20/23
to syzkaller-upst...@googlegroups.com
Auto-closing this bug as obsolete.
Crashes did not happen for a while, no reproducer and no activity.
Reply all
Reply to author
Forward
0 new messages