syzbot


KASAN: use-after-free Write in steam_input_close

Status: upstream: reported C repro on 2024/09/08 05:16
Bug presence: origin:lts
[Documentation on labels]
Reported-by: syzbot+4f4d222f5194841fec03@syzkaller.appspotmail.com
First crash: 74d, last: 73d
Fix bisection: failed (error log, bisect log)
  
Bug presence (2)
Date Name Commit Repro Result
2024/09/08 lts (merge base) b925f60c6ee7 C [report] KASAN: use-after-free Write in steam_input_close
2024/09/08 upstream (ToT) d1f2d51b711a C Didn't crash
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-6-1 KASAN: use-after-free Write in steam_input_close 1 57d 57d 0/2 premoderation: reported on 2024/09/24 19:39
android-5-10 KASAN: use-after-free Write in steam_input_close C 4 27d 43d 0/2 upstream: reported C repro on 2024/10/08 20:27
linux-6.1 KASAN: use-after-free Read in steam_input_close 1 97d 97d 0/3 upstream: reported on 2024/08/15 18:33
Last patch testing requests (3)
Created Duration User Patch Repo Result
2024/09/23 13:47 35m retest repro android13-5.15-lts report log
2024/09/23 13:47 24m retest repro android13-5.15-lts report log
2024/09/23 13:47 1h01m retest repro android13-5.15-lts report log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
BUG: KASAN: use-after-free in atomic_long_try_cmpxchg_acquire include/linux/atomic/atomic-instrumented.h:1667 [inline]
BUG: KASAN: use-after-free in __mutex_trylock_fast kernel/locking/mutex.c:169 [inline]
BUG: KASAN: use-after-free in mutex_lock+0xa9/0x1e0 kernel/locking/mutex.c:288
Write of size 8 at addr ffff88810fa80850 by task acpid/85

CPU: 0 PID: 85 Comm: acpid Not tainted 5.15.157-syzkaller-00897-g53be7c8abe11 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x151/0x1c0 lib/dump_stack.c:106
 print_address_description+0x87/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:427 [inline]
 kasan_report+0x179/0x1c0 mm/kasan/report.c:444
 kasan_check_range+0x293/0x2a0 mm/kasan/generic.c:189
 __kasan_check_write+0x14/0x20 mm/kasan/shadow.c:37
 instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
 atomic_long_try_cmpxchg_acquire include/linux/atomic/atomic-instrumented.h:1667 [inline]
 __mutex_trylock_fast kernel/locking/mutex.c:169 [inline]
 mutex_lock+0xa9/0x1e0 kernel/locking/mutex.c:288
 steam_input_close+0x90/0x1e0 drivers/hid/hid-steam.c:308
 input_close_device+0x29e/0x350 drivers/input/input.c:698
 evdev_close_device drivers/input/evdev.c:418 [inline]
 evdev_release+0x7be/0x850 drivers/input/evdev.c:460
 __fput+0x3fe/0x910 fs/file_table.c:280
 ____fput+0x15/0x20 fs/file_table.c:308
 task_work_run+0x129/0x190 kernel/task_work.c:164
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop+0xc4/0xe0 kernel/entry/common.c:181
 exit_to_user_mode_prepare+0x5a/0xa0 kernel/entry/common.c:214
 __syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline]
 syscall_exit_to_user_mode+0x26/0x160 kernel/entry/common.c:307
 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7f38f31f40a8
Code: 48 8b 05 83 9d 0d 00 64 c7 00 16 00 00 00 83 c8 ff 48 83 c4 20 5b c3 64 8b 04 25 18 00 00 00 85 c0 75 20 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 76 5b 48 8b 15 51 9d 0d 00 f7 d8 64 89 02 48 83
RSP: 002b:00007ffec897e688 EFLAGS: 00000246 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 00007ffec897e8f8 RCX: 00007f38f31f40a8
RDX: 0000000000000000 RSI: 000000000000001e RDI: 000000000000000a
RBP: 000000000000000a R08: 0000000000000008 R09: 00007ffec897e7f8
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffec897e7f8
R13: 0000000000000020 R14: 00007ffec897e8f8 R15: 00007ffec897e7f8
 </TASK>

Allocated by task 60:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:433 [inline]
 ____kasan_kmalloc+0xdb/0x110 mm/kasan/common.c:512
 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:521
 kasan_kmalloc include/linux/kasan.h:227 [inline]
 __kmalloc_track_caller+0x139/0x260 mm/slub.c:4950
 alloc_dr drivers/base/devres.c:116 [inline]
 devm_kmalloc+0x4f/0x160 drivers/base/devres.c:823
 devm_kzalloc include/linux/device.h:209 [inline]
 steam_probe+0x11d/0xa80 drivers/hid/hid-steam.c:741
 hid_device_probe+0x261/0x390 drivers/hid/hid-core.c:2302
 really_probe+0x28d/0x970 drivers/base/dd.c:595
 __driver_probe_device+0x1a0/0x310 drivers/base/dd.c:755
 driver_probe_device+0x54/0x3d0 drivers/base/dd.c:785
 __device_attach_driver+0x2c5/0x470 drivers/base/dd.c:907
 bus_for_each_drv+0x183/0x200 drivers/base/bus.c:427
 __device_attach+0x312/0x510 drivers/base/dd.c:979
 device_initial_probe+0x1a/0x20 drivers/base/dd.c:1028
 bus_probe_device+0xbe/0x1e0 drivers/base/bus.c:487
 device_add+0xb60/0xf10 drivers/base/core.c:3419
 hid_add_device+0x39c/0x4e0 drivers/hid/hid-core.c:2452
 usbhid_probe+0xb0e/0xea0 drivers/hid/usbhid/hid-core.c:1424
 usb_probe_interface+0x5b6/0xa90 drivers/usb/core/driver.c:396
 really_probe+0x28d/0x970 drivers/base/dd.c:595
 __driver_probe_device+0x1a0/0x310 drivers/base/dd.c:755
 driver_probe_device+0x54/0x3d0 drivers/base/dd.c:785
 __device_attach_driver+0x2c5/0x470 drivers/base/dd.c:907
 bus_for_each_drv+0x183/0x200 drivers/base/bus.c:427
 __device_attach+0x312/0x510 drivers/base/dd.c:979
 device_initial_probe+0x1a/0x20 drivers/base/dd.c:1028
 bus_probe_device+0xbe/0x1e0 drivers/base/bus.c:487
 device_add+0xb60/0xf10 drivers/base/core.c:3419
 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:293
 really_probe+0x28d/0x970 drivers/base/dd.c:595
 __driver_probe_device+0x1a0/0x310 drivers/base/dd.c:755
 driver_probe_device+0x54/0x3d0 drivers/base/dd.c:785
 __device_attach_driver+0x2c5/0x470 drivers/base/dd.c:907
 bus_for_each_drv+0x183/0x200 drivers/base/bus.c:427
 __device_attach+0x312/0x510 drivers/base/dd.c:979
 device_initial_probe+0x1a/0x20 drivers/base/dd.c:1028
 bus_probe_device+0xbe/0x1e0 drivers/base/bus.c:487
 device_add+0xb60/0xf10 drivers/base/core.c:3419
 usb_new_device+0x1038/0x1c00 drivers/usb/core/hub.c:2599
 hub_port_connect drivers/usb/core/hub.c:5512 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5652 [inline]
 port_event drivers/usb/core/hub.c:5802 [inline]
 hub_event+0x2def/0x4770 drivers/usb/core/hub.c:5884
 process_one_work+0x6bb/0xc10 kernel/workqueue.c:2325
 worker_thread+0xad5/0x12a0 kernel/workqueue.c:2472
 kthread+0x421/0x510 kernel/kthread.c:337
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:300

Freed by task 60:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:45
 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:370
 ____kasan_slab_free+0x126/0x160 mm/kasan/common.c:365
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:373
 kasan_slab_free include/linux/kasan.h:193 [inline]
 slab_free_hook mm/slub.c:1723 [inline]
 slab_free_freelist_hook+0xbd/0x190 mm/slub.c:1749
 slab_free mm/slub.c:3519 [inline]
 kfree+0xc8/0x220 mm/slub.c:4579
 release_nodes+0xf1/0x230 drivers/base/devres.c:501
 devres_release_all+0x148/0x1a0 drivers/base/devres.c:530
 __device_release_driver drivers/base/dd.c:1231 [inline]
 device_release_driver_internal+0x51a/0x7d0 drivers/base/dd.c:1262
 device_release_driver+0x19/0x20 drivers/base/dd.c:1285
 bus_remove_device+0x2f8/0x360 drivers/base/bus.c:529
 device_del+0x663/0xe90 drivers/base/core.c:3607
 hid_remove_device drivers/hid/hid-core.c:2500 [inline]
 hid_destroy_device+0x68/0x110 drivers/hid/hid-core.c:2519
 usbhid_disconnect+0x9e/0xc0 drivers/hid/usbhid/hid-core.c:1451
 usb_unbind_interface+0x1fa/0x8c0 drivers/usb/core/driver.c:458
 __device_release_driver drivers/base/dd.c:1229 [inline]
 device_release_driver_internal+0x50b/0x7d0 drivers/base/dd.c:1262
 device_release_driver+0x19/0x20 drivers/base/dd.c:1285
 bus_remove_device+0x2f8/0x360 drivers/base/bus.c:529
 device_del+0x663/0xe90 drivers/base/core.c:3607
 usb_disable_device+0x380/0x720 drivers/usb/core/message.c:1414
 usb_disconnect+0x32a/0x890 drivers/usb/core/hub.c:2249
 hub_port_connect drivers/usb/core/hub.c:5351 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5652 [inline]
 port_event drivers/usb/core/hub.c:5802 [inline]
 hub_event+0x1d42/0x4770 drivers/usb/core/hub.c:5884
 process_one_work+0x6bb/0xc10 kernel/workqueue.c:2325
 process_scheduled_works kernel/workqueue.c:2388 [inline]
 worker_thread+0xe02/0x12a0 kernel/workqueue.c:2474
 kthread+0x421/0x510 kernel/kthread.c:337
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:300

The buggy address belongs to the object at ffff88810fa80800
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 80 bytes inside of
 512-byte region [ffff88810fa80800, ffff88810fa80a00)
The buggy address belongs to the page:
page:ffffea00043ea000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10fa80
head:ffffea00043ea000 order:2 compound_mapcount:0 compound_pincount:0
flags: 0x4000000000010200(slab|head|zone=1)
raw: 4000000000010200 0000000000000000 0000000100000001 ffff888100042f00
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 1, ts 451098462666, free_ts 447310123453
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x1a3/0x1b0 mm/page_alloc.c:2605
 prep_new_page+0x1b/0x110 mm/page_alloc.c:2611
 get_page_from_freelist+0x3550/0x35d0 mm/page_alloc.c:4485
 __alloc_pages+0x27e/0x8f0 mm/page_alloc.c:5779
 allocate_slab mm/slub.c:1932 [inline]
 new_slab+0x9a/0x4e0 mm/slub.c:1995
 ___slab_alloc+0x39e/0x830 mm/slub.c:3028
 __slab_alloc+0x4a/0x90 mm/slub.c:3115
 slab_alloc_node mm/slub.c:3206 [inline]
 slab_alloc mm/slub.c:3248 [inline]
 __kmalloc_track_caller+0x16c/0x260 mm/slub.c:4945
 kmalloc_reserve net/core/skbuff.c:357 [inline]
 __alloc_skb+0x10c/0x550 net/core/skbuff.c:428
 alloc_skb include/linux/skbuff.h:1183 [inline]
 alloc_skb_with_frags+0xa6/0x680 net/core/skbuff.c:6159
 sock_alloc_send_pskb+0x915/0xa50 net/core/sock.c:2536
 unix_dgram_sendmsg+0x6fd/0x2090 net/unix/af_unix.c:1810
 sock_sendmsg_nosec net/socket.c:704 [inline]
 __sock_sendmsg net/socket.c:716 [inline]
 __sys_sendto+0x564/0x720 net/socket.c:2058
 __do_sys_sendto net/socket.c:2070 [inline]
 __se_sys_sendto net/socket.c:2066 [inline]
 __x64_sys_sendto+0xe5/0x100 net/socket.c:2066
 x64_sys_call+0x15c/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:45
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 free_pages_prepare mm/page_alloc.c:1472 [inline]
 free_pcp_prepare mm/page_alloc.c:1544 [inline]
 free_unref_page_prepare+0x7c8/0x7d0 mm/page_alloc.c:3534
 free_unref_page+0xe8/0x750 mm/page_alloc.c:3616
 free_the_page mm/page_alloc.c:805 [inline]
 __free_pages+0x61/0xf0 mm/page_alloc.c:5855
 free_nonslab_page+0x82/0xc0 mm/slub.c:3555
 kfree+0x19e/0x220 mm/slub.c:4576
 hcd_buffer_free+0xd3/0x1f0 drivers/usb/core/buffer.c:163
 usb_free_coherent+0x67/0x80 drivers/usb/core/usb.c:1073
 hid_free_buffers drivers/hid/usbhid/hid-core.c:974 [inline]
 usbhid_stop+0x5fe/0x7b0 drivers/hid/usbhid/hid-core.c:1251
 hid_hw_stop+0x156/0x1e0 drivers/hid/hid-core.c:2095
 steam_remove+0x113/0x180 drivers/hid/hid-steam.c:830
 hid_device_remove+0x250/0x370
 __device_release_driver drivers/base/dd.c:1227 [inline]
 device_release_driver_internal+0x4c8/0x7d0 drivers/base/dd.c:1262
 device_release_driver+0x19/0x20 drivers/base/dd.c:1285
 bus_remove_device+0x2f8/0x360 drivers/base/bus.c:529
 device_del+0x663/0xe90 drivers/base/core.c:3607
 hid_remove_device drivers/hid/hid-core.c:2500 [inline]
 hid_destroy_device+0x68/0x110 drivers/hid/hid-core.c:2519

Memory state around the buggy address:
 ffff88810fa80700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88810fa80780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88810fa80800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                 ^
 ffff88810fa80880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88810fa80900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
hid 0003:28DE:1102.0683: No HID_FEATURE_REPORT submitted -  nothing to read
hid 0003:28DE:1102.0683: No HID_FEATURE_REPORT submitted -  nothing to read
hid 0003:28DE:1102.0683: No HID_FEATURE_REPORT submitted -  nothing to read
hid 0003:28DE:1102.0683: No HID_FEATURE_REPORT submitted -  nothing to read
hid 0003:28DE:1102.0683: No HID_FEATURE_REPORT submitted -  nothing to read
hid 0003:28DE:1102.0683: No HID_FEATURE_REPORT submitted -  nothing to read
hid 0003:28DE:1102.0683: No HID_FEATURE_REPORT submitted -  nothing to read
hid 0003:28DE:1102.0683: No HID_FEATURE_REPORT submitted -  nothing to read

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/09/08 21:34 android13-5.15-lts 53be7c8abe11 9750182a .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Write in steam_input_close
2024/09/08 05:14 android13-5.15-lts 53be7c8abe11 9750182a .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Write in steam_input_close
2024/09/09 10:42 android13-5.15-lts 53be7c8abe11 9750182a .config console log report syz / log [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Write in steam_input_close
* Struck through repros no longer work on HEAD.