syzbot


KASAN: use-after-free Write in detach_if_pending (2)

Status: premoderation: reported on 2025/06/06 23:25
Reported-by: syzbot+7130f0814f3661965e91@syzkaller.appspotmail.com
First crash: 3d20h, last: 3d20h
Similar bugs (8)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-54 KASAN: use-after-free Write in detach_if_pending C 1618 15d 851d 0/2 upstream: reported C repro on 2023/02/10 18:19
upstream KASAN: use-after-free Write in detach_if_pending net C 4169 2788d 2783d 3/28 fixed on 2017/11/28 03:36
android-6-1 KASAN: use-after-free Write in detach_if_pending 5 112d 235d 0/2 auto-obsoleted due to no activity on 2025/05/18 23:57
upstream general protection fault in detach_if_pending (2) net 1 1185d 1185d 0/28 auto-closed as invalid on 2022/06/11 02:46
linux-4.14 general protection fault in detach_if_pending (2) 1 1495d 1495d 0/1 auto-closed as invalid on 2021/09/04 11:36
upstream general protection fault in detach_if_pending (3) bcachefs kvm 5 350d 350d 0/28 closed as invalid on 2024/08/16 18:25
upstream KASAN: invalid-access Write in detach_if_pending wireguard 2 1575d 1577d 0/28 auto-closed as invalid on 2021/05/17 08:51
upstream KASAN: slab-use-after-free Write in detach_if_pending wireguard batman 2 767d 776d 0/28 auto-obsoleted due to no activity on 2023/11/08 05:10

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __hlist_del include/linux/list.h:884 [inline]
BUG: KASAN: use-after-free in detach_timer kernel/time/timer.c:886 [inline]
BUG: KASAN: use-after-free in detach_if_pending+0x156/0x300 kernel/time/timer.c:905
Write of size 8 at addr ffff888118c449f8 by task syz.3.766/3181

CPU: 1 PID: 3181 Comm: syz.3.766 Not tainted 6.1.138-syzkaller-00056-g7af56ffc913d #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
Call Trace:
 <TASK>
 __dump_stack+0x21/0x24 lib/dump_stack.c:88
 dump_stack_lvl+0xee/0x150 lib/dump_stack.c:106
 print_address_description+0x71/0x210 mm/kasan/report.c:316
 print_report+0x4a/0x60 mm/kasan/report.c:427
 kasan_report+0x122/0x150 mm/kasan/report.c:531
 __asan_report_store8_noabort+0x17/0x20 mm/kasan/report_generic.c:356
 __hlist_del include/linux/list.h:884 [inline]
 detach_timer kernel/time/timer.c:886 [inline]
 detach_if_pending+0x156/0x300 kernel/time/timer.c:905
 try_to_del_timer_sync kernel/time/timer.c:1322 [inline]
 del_timer_sync+0x136/0x1a0 kernel/time/timer.c:1472
 tun_flow_uninit+0x2f/0x350 drivers/net/tun.c:1369
 tun_free_netdev+0x7d/0x1b0 drivers/net/tun.c:2313
 netdev_run_todo+0xa72/0xc00 net/core/dev.c:10462
 rtnl_unlock+0xe/0x10 net/core/rtnetlink.c:147
 tun_detach drivers/net/tun.c:704 [inline]
 tun_chr_close+0xc4/0x140 drivers/net/tun.c:3492
 __fput+0x1fc/0x8f0 fs/file_table.c:320
 ____fput+0x15/0x20 fs/file_table.c:348
 task_work_run+0x1db/0x240 kernel/task_work.c:203
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop+0x9b/0xb0 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+0x1a/0x30 kernel/entry/common.c:303
 do_syscall_64+0x58/0xa0 arch/x86/entry/common.c:87
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7fa64db8e929
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:00007fa64e980038 EFLAGS: 00000246 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 00007fa64ddb6160 RCX: 00007fa64db8e929
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000009
RBP: 00007fa64dc10b39 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fa64ddb6160 R15: 00007ffdab8e93f8
 </TASK>

Allocated by task 3158:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_alloc_info+0x25/0x30 mm/kasan/generic.c:505
 ____kasan_kmalloc mm/kasan/common.c:379 [inline]
 __kasan_kmalloc+0x95/0xb0 mm/kasan/common.c:388
 kasan_kmalloc include/linux/kasan.h:212 [inline]
 __do_kmalloc_node mm/slab_common.c:938 [inline]
 __kmalloc+0xb1/0x1e0 mm/slab_common.c:951
 kmalloc include/linux/slab.h:568 [inline]
 kzalloc include/linux/slab.h:699 [inline]
 hci_alloc_dev_priv+0x27/0x1bd0 net/bluetooth/hci_core.c:2435
 hci_alloc_dev include/net/bluetooth/hci_core.h:1484 [inline]
 hci_uart_register_dev drivers/bluetooth/hci_ldisc.c:641 [inline]
 hci_uart_set_proto drivers/bluetooth/hci_ldisc.c:719 [inline]
 hci_uart_tty_ioctl+0x3d6/0xa20 drivers/bluetooth/hci_ldisc.c:774
 tty_ioctl+0x8ef/0xc60 drivers/tty/tty_io.c:2785
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0x12f/0x1b0 fs/ioctl.c:856
 __x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:856
 x64_sys_call+0x58b/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:17
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Freed by task 3158:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x31/0x50 mm/kasan/generic.c:516
 ____kasan_slab_free+0x132/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+0xc2/0x190 mm/slub.c:1771
 slab_free mm/slub.c:3686 [inline]
 __kmem_cache_free+0xb7/0x1b0 mm/slub.c:3702
 kfree+0x6f/0xf0 mm/slab_common.c:990
 hci_release_dev+0x13ad/0x1500 net/bluetooth/hci_core.c:2763
 bt_host_release+0x82/0x90 net/bluetooth/hci_sysfs.c:85
 device_release+0xa4/0x1d0 drivers/base/core.c:-1
 kobject_cleanup lib/kobject.c:681 [inline]
 kobject_release lib/kobject.c:712 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x19d/0x280 lib/kobject.c:729
 put_device+0x1f/0x30 drivers/base/core.c:3806
 hci_dev_put include/net/bluetooth/hci_core.h:1444 [inline]
 hci_dev_cmd+0x265/0x720 net/bluetooth/hci_core.c:795
 hci_sock_ioctl+0x41e/0x7f0 net/bluetooth/hci_sock.c:1096
 sock_do_ioctl+0x101/0x310 net/socket.c:1194
 sock_ioctl+0x4d8/0x6e0 net/socket.c:1311
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0x12f/0x1b0 fs/ioctl.c:856
 __x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:856
 x64_sys_call+0x58b/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:17
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Last potentially related work creation:
 kasan_save_stack+0x3a/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb6/0xc0 mm/kasan/generic.c:486
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:496
 insert_work+0x51/0x300 kernel/workqueue.c:1368
 __queue_work+0x9b1/0xd30 kernel/workqueue.c:1527
 queue_work_on+0xd2/0x140 kernel/workqueue.c:1555
 queue_work include/linux/workqueue.h:510 [inline]
 hci_cmd_sync_run net/bluetooth/hci_sync.c:140 [inline]
 __hci_cmd_sync_sk+0xa3e/0xcf0 net/bluetooth/hci_sync.c:162
 __hci_cmd_sync_status_sk net/bluetooth/hci_sync.c:253 [inline]
 __hci_cmd_sync_status net/bluetooth/hci_sync.c:277 [inline]
 hci_cmd_sync_status+0x53/0x120 net/bluetooth/hci_sync.c:288
 hci_dev_cmd+0x628/0x720 net/bluetooth/hci_core.c:-1
 hci_sock_ioctl+0x41e/0x7f0 net/bluetooth/hci_sock.c:1096
 sock_do_ioctl+0x101/0x310 net/socket.c:1194
 sock_ioctl+0x4d8/0x6e0 net/socket.c:1311
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0x12f/0x1b0 fs/ioctl.c:856
 __x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:856
 x64_sys_call+0x58b/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:17
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Second to last potentially related work creation:
 kasan_save_stack+0x3a/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb6/0xc0 mm/kasan/generic.c:486
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:496
 insert_work+0x51/0x300 kernel/workqueue.c:1368
 __queue_work+0x9b1/0xd30 kernel/workqueue.c:1527
 queue_work_on+0xd2/0x140 kernel/workqueue.c:1555
 queue_work include/linux/workqueue.h:510 [inline]
 hci_cmd_timeout+0x191/0x200 net/bluetooth/hci_core.c:1468
 process_one_work+0x71f/0xc40 kernel/workqueue.c:2299
 worker_thread+0xa29/0x11f0 kernel/workqueue.c:2446
 kthread+0x281/0x320 kernel/kthread.c:386
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

The buggy address belongs to the object at ffff888118c44000
 which belongs to the cache kmalloc-8k of size 8192
The buggy address is located 2552 bytes inside of
 8192-byte region [ffff888118c44000, ffff888118c46000)

The buggy address belongs to the physical page:
page:ffffea0004631000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x118c40
head:ffffea0004631000 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x4000000000010200(slab|head|zone=1)
raw: 4000000000010200 ffffea000453d200 dead000000000005 ffff888100043500
raw: 0000000000000000 0000000000020002 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 1353, tgid 1347 (syz.1.277), ts 104670916019, free_ts 104670132976
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x1f5/0x210 mm/page_alloc.c:2637
 prep_new_page+0x1c/0x110 mm/page_alloc.c:2644
 get_page_from_freelist+0x2c6e/0x2ce0 mm/page_alloc.c:4539
 __alloc_pages+0x19e/0x3a0 mm/page_alloc.c:5842
 alloc_slab_page+0x6e/0xf0 include/linux/gfp.h:-1
 allocate_slab mm/slub.c:1962 [inline]
 new_slab+0x98/0x3d0 mm/slub.c:2015
 ___slab_alloc+0x6f6/0xb50 mm/slub.c:3203
 __slab_alloc+0x5e/0xa0 mm/slub.c:3302
 slab_alloc_node mm/slub.c:3387 [inline]
 __kmem_cache_alloc_node+0x203/0x2c0 mm/slub.c:3462
 __do_kmalloc_node mm/slab_common.c:937 [inline]
 __kmalloc_node+0xa1/0x1e0 mm/slab_common.c:945
 kmalloc_node include/linux/slab.h:589 [inline]
 __bpf_map_area_alloc kernel/bpf/syscall.c:328 [inline]
 bpf_map_area_alloc+0x4b/0xe0 kernel/bpf/syscall.c:341
 prealloc_init+0x146/0x8f0 kernel/bpf/hashtab.c:316
 htab_map_alloc+0xb24/0xfd0 kernel/bpf/hashtab.c:568
 find_and_alloc_map kernel/bpf/syscall.c:133 [inline]
 map_create+0x49c/0xd80 kernel/bpf/syscall.c:1126
 __sys_bpf+0x30b/0x780 kernel/bpf/syscall.c:4984
 __do_sys_bpf kernel/bpf/syscall.c:5106 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:5104 [inline]
 __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5104
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 free_pages_prepare mm/page_alloc.c:1545 [inline]
 free_pcp_prepare mm/page_alloc.c:1619 [inline]
 free_unref_page_prepare+0x742/0x750 mm/page_alloc.c:3581
 free_unref_page+0x8f/0x530 mm/page_alloc.c:3677
 free_the_page mm/page_alloc.c:830 [inline]
 __free_pages+0x67/0x100 mm/page_alloc.c:5931
 free_large_kmalloc+0xae/0xf0 mm/slab_common.c:915
 kfree+0x8b/0xf0 mm/slab_common.c:984
 kvfree mm/util.c:639 [inline]
 kvfree_sensitive+0x4d/0x60 mm/util.c:656
 __do_sys_add_key security/keys/keyctl.c:147 [inline]
 __se_sys_add_key+0x393/0x3f0 security/keys/keyctl.c:74
 __x64_sys_add_key+0xbf/0xd0 security/keys/keyctl.c:74
 x64_sys_call+0x6aa/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:249
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Memory state around the buggy address:
 ffff888118c44880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888118c44900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888118c44980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                                ^
 ffff888118c44a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888118c44a80: fb 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
2025/06/06 23:24 android14-6.1 7af56ffc913d 9fa58bba .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in detach_if_pending
* Struck through repros no longer work on HEAD.