syzbot


KASAN: use-after-free Write in enqueue_timer

Status: upstream: reported C repro on 2024/07/25 13:16
Bug presence: origin:lts
[Documentation on labels]
Reported-by: syzbot+092cf816f02f1a8a8f2e@syzkaller.appspotmail.com
First crash: 172d, last: 3d14h
Bug presence (2)
Date Name Commit Repro Result
2024/12/01 lts (merge base) 0d968ced7330 C [report] KASAN: use-after-free Write in enqueue_timer
2024/12/01 upstream (ToT) bcc8eda6d349 C Didn't crash
Similar bugs (5)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-54 KASAN: use-after-free Write in enqueue_timer C 4288 155d 662d 0/2 auto-obsoleted due to no activity on 2024/09/11 16:22
upstream KASAN: use-after-free Write in enqueue_timer net 1 752d 752d 22/28 fixed on 2023/02/24 13:50
android-5-15 KASAN: use-after-free Write in enqueue_timer 1 322d 322d 0/2 auto-obsoleted due to no activity on 2024/04/17 12:01
upstream KASAN: slab-use-after-free Write in enqueue_timer net 18 570d 585d 0/28 auto-obsoleted due to no activity on 2023/08/22 15:17
upstream KASAN: invalid-access Write in enqueue_timer ext4 20 1367d 1389d 0/28 auto-closed as invalid on 2021/07/08 00:48

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in hlist_add_head include/linux/list.h:930 [inline]
BUG: KASAN: use-after-free in enqueue_timer+0xa6/0x480 kernel/time/timer.c:611
Write of size 8 at addr ffff88810a438a00 by task kworker/u5:5/307

CPU: 1 PID: 307 Comm: kworker/u5:5 Not tainted 6.1.115-syzkaller-00041-ga887a44ace2a #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Workqueue: hci0 hci_power_on
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:316 [inline]
 print_report+0x158/0x4e0 mm/kasan/report.c:427
 kasan_report+0x13c/0x170 mm/kasan/report.c:531
 __asan_report_store8_noabort+0x17/0x20 mm/kasan/report_generic.c:356
 hlist_add_head include/linux/list.h:930 [inline]
 enqueue_timer+0xa6/0x480 kernel/time/timer.c:611
 internal_add_timer kernel/time/timer.c:640 [inline]
 __mod_timer+0x8d3/0xcf0 kernel/time/timer.c:1121
 schedule_timeout+0x187/0x380 kernel/time/timer.c:1970
 __hci_cmd_sync_sk+0x2ad/0xf70 net/bluetooth/hci_sync.c:166
 __hci_cmd_sync_status_sk net/bluetooth/hci_sync.c:253 [inline]
 __hci_cmd_sync_status net/bluetooth/hci_sync.c:277 [inline]
 hci_read_local_features_sync net/bluetooth/hci_sync.c:3450 [inline]
 hci_init_stage_sync net/bluetooth/hci_sync.c:3361 [inline]
 hci_init1_sync net/bluetooth/hci_sync.c:3545 [inline]
 hci_init_sync net/bluetooth/hci_sync.c:4627 [inline]
 hci_dev_init_sync net/bluetooth/hci_sync.c:4818 [inline]
 hci_dev_open_sync+0x1314/0x30a0 net/bluetooth/hci_sync.c:4898
 hci_dev_do_open net/bluetooth/hci_core.c:439 [inline]
 hci_power_on+0x1a7/0x5e0 net/bluetooth/hci_core.c:945
 process_one_work+0x73d/0xcb0 kernel/workqueue.c:2299
 worker_thread+0xa60/0x1260 kernel/workqueue.c:2446
 kthread+0x26d/0x300 kernel/kthread.c:386
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
 </TASK>

Allocated by task 342:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_alloc_info+0x1f/0x30 mm/kasan/generic.c:505
 ____kasan_kmalloc mm/kasan/common.c:379 [inline]
 __kasan_kmalloc+0x9c/0xb0 mm/kasan/common.c:388
 kasan_kmalloc include/linux/kasan.h:212 [inline]
 __do_kmalloc_node mm/slab_common.c:938 [inline]
 __kmalloc+0xb4/0x1e0 mm/slab_common.c:951
 kmalloc include/linux/slab.h:562 [inline]
 kzalloc include/linux/slab.h:693 [inline]
 hci_alloc_dev_priv+0x27/0x1c00 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:636 [inline]
 hci_uart_set_proto drivers/bluetooth/hci_ldisc.c:712 [inline]
 hci_uart_tty_ioctl+0x401/0xa70 drivers/bluetooth/hci_ldisc.c:765
 tty_ioctl+0x903/0xc50 drivers/tty/tty_io.c:2785
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0x114/0x190 fs/ioctl.c:856
 __x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:856
 x64_sys_call+0x98/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:17
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Freed by task 348:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:516
 ____kasan_slab_free+0x131/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 mm/slub.c:1771 [inline]
 slab_free mm/slub.c:3686 [inline]
 __kmem_cache_free+0x21d/0x410 mm/slub.c:3702
 kfree+0x7a/0xf0 mm/slab_common.c:990
 hci_release_dev+0x14d3/0x1640 net/bluetooth/hci_core.c:2763
 bt_host_release+0x83/0xa0 net/bluetooth/hci_sysfs.c:92
 device_release+0x95/0x1c0
 kobject_cleanup lib/kobject.c:681 [inline]
 kobject_release lib/kobject.c:712 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x178/0x260 lib/kobject.c:729
 put_device+0x1f/0x30 drivers/base/core.c:3797
 hci_dev_put include/net/bluetooth/hci_core.h:1444 [inline]
 hci_dev_cmd+0x2be/0x9b0 net/bluetooth/hci_core.c:795
 hci_sock_ioctl+0x415/0x7f0 net/bluetooth/hci_sock.c:1096
 sock_do_ioctl+0x152/0x450 net/socket.c:1194
 sock_ioctl+0x455/0x740 net/socket.c:1311
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0x114/0x190 fs/ioctl.c:856
 __x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:856
 x64_sys_call+0x98/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:17
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb4/0xc0 mm/kasan/generic.c:486
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:496
 insert_work+0x56/0x310 kernel/workqueue.c:1368
 __queue_work+0x9b6/0xd70 kernel/workqueue.c:1527
 queue_work_on+0x105/0x170 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+0xc2a/0xf70 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+0x52/0x130 net/bluetooth/hci_sync.c:288
 hci_dev_cmd+0x771/0x9b0
 hci_sock_ioctl+0x415/0x7f0 net/bluetooth/hci_sock.c:1096
 sock_do_ioctl+0x152/0x450 net/socket.c:1194
 sock_ioctl+0x455/0x740 net/socket.c:1311
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0x114/0x190 fs/ioctl.c:856
 __x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:856
 x64_sys_call+0x98/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:17
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Second to last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb4/0xc0 mm/kasan/generic.c:486
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:496
 insert_work+0x56/0x310 kernel/workqueue.c:1368
 __queue_work+0x9b6/0xd70 kernel/workqueue.c:1527
 queue_work_on+0x105/0x170 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+0xc2a/0xf70 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+0x52/0x130 net/bluetooth/hci_sync.c:288
 hci_dev_cmd+0x771/0x9b0
 hci_sock_ioctl+0x415/0x7f0 net/bluetooth/hci_sock.c:1096
 sock_do_ioctl+0x152/0x450 net/socket.c:1194
 sock_ioctl+0x455/0x740 net/socket.c:1311
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0x114/0x190 fs/ioctl.c:856
 __x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:856
 x64_sys_call+0x98/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:17
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

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

The buggy address belongs to the physical page:
page:ffffea0004290e00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10a438
head:ffffea0004290e00 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x4000000000010200(slab|head|zone=1)
raw: 4000000000010200 ffffea0004291200 dead000000000002 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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1, tgid 1 (swapper/0), ts 2130354213, free_ts 0
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x213/0x220 mm/page_alloc.c:2590
 prep_new_page+0x1b/0x110 mm/page_alloc.c:2597
 get_page_from_freelist+0x2980/0x2a10 mm/page_alloc.c:4439
 __alloc_pages+0x234/0x610 mm/page_alloc.c:5728
 alloc_slab_page+0x6c/0xf0
 allocate_slab mm/slub.c:1962 [inline]
 new_slab+0x90/0x3e0 mm/slub.c:2015
 ___slab_alloc+0x6f9/0xb80 mm/slub.c:3203
 __slab_alloc+0x5d/0xa0 mm/slub.c:3302
 slab_alloc_node mm/slub.c:3387 [inline]
 __kmem_cache_alloc_node+0x207/0x2a0 mm/slub.c:3462
 __do_kmalloc_node mm/slab_common.c:937 [inline]
 __kmalloc_node+0xa3/0x1e0 mm/slab_common.c:945
 kmalloc_node include/linux/slab.h:583 [inline]
 kvmalloc_node+0x221/0x640 mm/util.c:592
 kvzalloc_node include/linux/slab.h:714 [inline]
 sbitmap_init_node+0x48b/0x5f0 lib/sbitmap.c:113
 scsi_realloc_sdev_budget_map+0x2a3/0x450 drivers/scsi/scsi_scan.c:246
 scsi_alloc_sdev+0x86c/0xb30 drivers/scsi/scsi_scan.c:357
 scsi_probe_and_add_lun+0x17f/0x4070 drivers/scsi/scsi_scan.c:1188
 __scsi_scan_target+0x20a/0xea0 drivers/scsi/scsi_scan.c:1724
page_owner free stack trace missing

Memory state around the buggy address:
 ffff88810a438900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88810a438980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88810a438a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88810a438a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88810a438b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (34):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/12/02 01:46 android14-6.1 a887a44ace2a 68914665 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/12/01 21:59 android14-6.1 a887a44ace2a 68914665 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/12/01 20:12 android14-6.1 a887a44ace2a 68914665 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/12/01 16:27 android14-6.1 a887a44ace2a 68914665 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/12/01 13:55 android14-6.1 a887a44ace2a 68914665 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/12/01 08:46 android14-6.1 a887a44ace2a 68914665 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/12/01 04:38 android14-6.1 a887a44ace2a 68914665 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/12/02 19:32 android14-6.1 cdea241bf6f9 b499ea68 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/12/02 11:52 android14-6.1 a887a44ace2a b499ea68 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/11/16 18:11 android14-6.1 defe0024cfb0 cfe3a04a .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/11/11 06:44 android14-6.1 eef3d33656ce 6b856513 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/11/06 13:42 android14-6.1 976b055754d7 3a465482 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/10/27 07:49 android14-6.1 a874ed06eb34 65e8686b .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/09/24 09:03 android14-6.1 2cd8ac816de5 89298aad .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/08/20 17:39 android14-6.1 edca080b95df 9f0ab3fb .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/08/16 06:56 android14-6.1 d6a513a78492 e4bacdaf .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/08/15 06:36 android14-6.1 64b0e0b28508 e4bacdaf .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/08/14 08:03 android14-6.1 660e1a26952b 07a4d4ad .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/08/13 13:36 android14-6.1 79436849ef1d f21a18ca .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/08/08 02:22 android14-6.1 1bb38f786569 de12cf65 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/08/08 02:22 android14-6.1 1bb38f786569 de12cf65 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/08/07 12:20 android14-6.1 1bb38f786569 1ef9fe42 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/08/06 17:57 android14-6.1 1bb38f786569 1ef9fe42 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/08/06 14:48 android14-6.1 37391192a93a 1ef9fe42 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/08/06 09:22 android14-6.1 37391192a93a e1bdb00a .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/08/06 09:16 android14-6.1 37391192a93a e1bdb00a .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/08/06 08:58 android14-6.1 37391192a93a e1bdb00a .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/08/05 05:32 android14-6.1 6aafd06a463b 1786a2a8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/08/03 23:59 android14-6.1 6aafd06a463b 1786a2a8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/07/20 07:38 android14-6.1 6d6afa9d3f8f b88348e9 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/07/18 13:19 android14-6.1 fc94b39f6687 71884c12 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/07/16 17:19 android14-6.1 4965ad067b76 b66b37bd .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/06/17 10:01 android14-6.1 c0618d182a9c 88722c0f .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
2024/06/16 14:57 android14-6.1 25216be1ac5e f429ab00 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in enqueue_timer
* Struck through repros no longer work on HEAD.