KASAN: use-after-free Read in usbhid_close

9 views
Skip to first unread message

syzbot

unread,
Apr 12, 2020, 12:51:13 PM4/12/20
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: fa41ab53 ANDROID: ABI/Whitelist: add display whitelist to ..
git tree: android-5.4
console output: https://syzkaller.appspot.com/x/log.txt?x=1538fb2be00000
kernel config: https://syzkaller.appspot.com/x/.config?x=79abcb8adfc6687b
dashboard link: https://syzkaller.appspot.com/bug?extid=95dcb1d370feec8af478
compiler: Android (6032204 based on r370808) clang version 10.0.1 (https://android.googlesource.com/toolchain/llvm-project 6e765c10313d15c02ab29977a82938f66742c3a9)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17bccbc7e00000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+95dcb1...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in atomic_read include/asm-generic/atomic-instrumented.h:26 [inline]
BUG: KASAN: use-after-free in usb_kill_urb+0x1c6/0x2e0 drivers/usb/core/urb.c:696
Read of size 4 at addr ffff8881d37af810 by task systemd-udevd/3114

CPU: 0 PID: 3114 Comm: systemd-udevd Not tainted 5.4.31-syzkaller-00073-gfa41ab5369c7 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x14a/0x1ce lib/dump_stack.c:118
print_address_description+0x93/0x620 mm/kasan/report.c:374
__kasan_report+0x16d/0x1e0 mm/kasan/report.c:506
kasan_report+0x34/0x60 mm/kasan/common.c:634
check_memory_region_inline mm/kasan/generic.c:182 [inline]
check_memory_region+0x2b5/0x2f0 mm/kasan/generic.c:192
atomic_read include/asm-generic/atomic-instrumented.h:26 [inline]
usb_kill_urb+0x1c6/0x2e0 drivers/usb/core/urb.c:696
usbhid_close+0x139/0x1d0 drivers/hid/usbhid/hid-core.c:750
hid_hw_close+0xa1/0xd0 drivers/hid/hid-core.c:2100
input_close_device+0x275/0x310 drivers/input/input.c:683
evdev_close_device drivers/input/evdev.c:428 [inline]
evdev_release+0x6aa/0x6f0 drivers/input/evdev.c:466
__fput+0x27d/0x6c0 fs/file_table.c:280
task_work_run+0x176/0x1a0 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:188 [inline]
exit_to_usermode_loop arch/x86/entry/common.c:163 [inline]
prepare_exit_to_usermode+0x286/0x2e0 arch/x86/entry/common.c:194
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7fe545389270
Code: 73 01 c3 48 8b 0d 38 7d 20 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 83 3d 59 c1 20 00 00 75 10 b8 03 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e8 ee fb ff ff 48 89 04 24
RSP: 002b:00007fff3b384228 EFLAGS: 00000246 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000007 RCX: 00007fe545389270
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000007
RBP: 00007fe546242710 R08: 0000555ca3d9a2a9 R09: 0000000000000078
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000016
R13: 0000000000000000 R14: 00007fff3b3842d4 R15: 0000000000000000

Allocated by task 115:
save_stack mm/kasan/common.c:69 [inline]
set_track mm/kasan/common.c:77 [inline]
__kasan_kmalloc+0x12c/0x1c0 mm/kasan/common.c:510
__kmalloc+0xf7/0x2c0 mm/slub.c:3821
kmalloc include/linux/slab.h:561 [inline]
usb_alloc_urb+0x3d/0x140 drivers/usb/core/urb.c:74
usbhid_start+0x102a/0x23f0 drivers/hid/usbhid/hid-core.c:1121
hid_hw_start+0x5c/0x100 drivers/hid/hid-core.c:2030
wacom_parse_and_register+0x5444/0x6e00 drivers/hid/wacom_sys.c:2365
wacom_probe+0x5f8/0x780 drivers/hid/wacom_sys.c:2748
hid_device_probe+0x274/0x410 drivers/hid/hid-core.c:2263
really_probe+0x6fe/0xf50 drivers/base/dd.c:551
driver_probe_device+0xe6/0x230 drivers/base/dd.c:724
bus_for_each_drv+0x17a/0x200 drivers/base/bus.c:430
__device_attach+0x275/0x410 drivers/base/dd.c:897
bus_probe_device+0xb8/0x1e0 drivers/base/bus.c:490
device_add+0x1054/0x1740 drivers/base/core.c:2507
hid_add_device+0xd7e/0xfd0 drivers/hid/hid-core.c:2419
usbhid_probe+0x94e/0xcc0 drivers/hid/usbhid/hid-core.c:1386
usb_probe_interface+0x621/0xac0 drivers/usb/core/driver.c:361
really_probe+0x75b/0xf50 drivers/base/dd.c:555
driver_probe_device+0xe6/0x230 drivers/base/dd.c:724
bus_for_each_drv+0x17a/0x200 drivers/base/bus.c:430
__device_attach+0x275/0x410 drivers/base/dd.c:897
bus_probe_device+0xb8/0x1e0 drivers/base/bus.c:490
device_add+0x1054/0x1740 drivers/base/core.c:2507
usb_set_configuration+0x184c/0x1dc0 drivers/usb/core/message.c:2023
generic_probe+0x82/0x140 drivers/usb/core/generic.c:210
really_probe+0x75b/0xf50 drivers/base/dd.c:555
driver_probe_device+0xe6/0x230 drivers/base/dd.c:724
bus_for_each_drv+0x17a/0x200 drivers/base/bus.c:430
__device_attach+0x275/0x410 drivers/base/dd.c:897
bus_probe_device+0xb8/0x1e0 drivers/base/bus.c:490
device_add+0x1054/0x1740 drivers/base/core.c:2507
usb_new_device+0x9ba/0xfc0 drivers/usb/core/hub.c:2548
hub_port_connect drivers/usb/core/hub.c:5110 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5225 [inline]
port_event drivers/usb/core/hub.c:5371 [inline]
hub_event+0x28eb/0x4fc0 drivers/usb/core/hub.c:5453
process_one_work+0x777/0xf90 kernel/workqueue.c:2274
process_scheduled_works kernel/workqueue.c:2336 [inline]
worker_thread+0xdb6/0x1430 kernel/workqueue.c:2422
kthread+0x2df/0x300 kernel/kthread.c:255
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352

Freed by task 246:
save_stack mm/kasan/common.c:69 [inline]
set_track mm/kasan/common.c:77 [inline]
kasan_set_free_info mm/kasan/common.c:332 [inline]
__kasan_slab_free+0x181/0x230 mm/kasan/common.c:471
slab_free_hook mm/slub.c:1424 [inline]
slab_free_freelist_hook+0xd0/0x140 mm/slub.c:1457
slab_free mm/slub.c:3014 [inline]
kfree+0x12b/0x5f0 mm/slub.c:3975
usbhid_stop+0x22c/0x570 drivers/hid/usbhid/hid-core.c:1217
wacom_remove+0x84/0x2e0 drivers/hid/wacom_sys.c:2772
hid_device_remove+0xd2/0x390 drivers/hid/hid-core.c:2296
__device_release_driver drivers/base/dd.c:1137 [inline]
device_release_driver_internal+0x505/0x790 drivers/base/dd.c:1168
bus_remove_device+0x2e0/0x350 drivers/base/bus.c:532
device_del+0x7a7/0x11f0 drivers/base/core.c:2684
hid_remove_device drivers/hid/hid-core.c:2467 [inline]
hid_destroy_device+0x66/0x100 drivers/hid/hid-core.c:2486
usbhid_disconnect+0x9a/0xc0 drivers/hid/usbhid/hid-core.c:1413
usb_unbind_interface+0x1cf/0x840 drivers/usb/core/driver.c:423
__device_release_driver drivers/base/dd.c:1137 [inline]
device_release_driver_internal+0x505/0x790 drivers/base/dd.c:1168
bus_remove_device+0x2e0/0x350 drivers/base/bus.c:532
device_del+0x7a7/0x11f0 drivers/base/core.c:2684
usb_disable_device+0x3f3/0xb80 drivers/usb/core/message.c:1237
usb_disconnect+0x341/0x880 drivers/usb/core/hub.c:2211
hub_port_connect drivers/usb/core/hub.c:4961 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5225 [inline]
port_event drivers/usb/core/hub.c:5371 [inline]
hub_event+0x1c44/0x4fc0 drivers/usb/core/hub.c:5453
process_one_work+0x777/0xf90 kernel/workqueue.c:2274
worker_thread+0xa8f/0x1430 kernel/workqueue.c:2420
kthread+0x2df/0x300 kernel/kthread.c:255
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352

The buggy address belongs to the object at ffff8881d37af800
which belongs to the cache kmalloc-256 of size 256
The buggy address is located 16 bytes inside of
256-byte region [ffff8881d37af800, ffff8881d37af900)
The buggy address belongs to the page:
page:ffffea00074deb80 refcount:1 mapcount:0 mapping:ffff8881da802e00 index:0x0 compound_mapcount: 0
flags: 0x8000000000010200(slab|head)
raw: 8000000000010200 dead000000000100 dead000000000122 ffff8881da802e00
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8881d37af700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8881d37af780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8881d37af800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8881d37af880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8881d37af900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================


---
This bug 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 bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches
Reply all
Reply to author
Forward
0 new messages