syzbot


KASAN: use-after-free Write in enqueue_timer

Status: auto-obsoleted due to no activity on 2024/04/17 12:01
Reported-by: syzbot+e96ed549a4bf6c2b3a3d@syzkaller.appspotmail.com
First crash: 103d, last: 103d
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-54 KASAN: use-after-free Write in enqueue_timer C 3777 6h07m 443d 0/2 upstream: reported C repro on 2023/02/12 21:09
upstream KASAN: use-after-free Write in enqueue_timer net 1 533d 533d 22/26 fixed on 2023/02/24 13:50
upstream KASAN: slab-use-after-free Write in enqueue_timer net 18 351d 366d 0/26 auto-obsoleted due to no activity on 2023/08/22 15:17
upstream KASAN: invalid-access Write in enqueue_timer ext4 20 1148d 1170d 0/26 auto-closed as invalid on 2021/07/08 00:48

Sample crash report:
Bluetooth: hci1: sending frame failed (-49)
==================================================================
BUG: KASAN: use-after-free in hlist_add_head include/linux/list.h:902 [inline]
BUG: KASAN: use-after-free in enqueue_timer+0xad/0x4c0 kernel/time/timer.c:588
Write of size 8 at addr ffff8881162c48e0 by task kworker/u5:3/23785

CPU: 0 PID: 23785 Comm: kworker/u5:3 Not tainted 5.15.147-syzkaller-00327-g1c3a1f32bcbd #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
Workqueue: hci0 hci_cmd_work
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x151/0x1b7 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
 __asan_report_store8_noabort+0x17/0x20 mm/kasan/report_generic.c:314
 hlist_add_head include/linux/list.h:902 [inline]
 enqueue_timer+0xad/0x4c0 kernel/time/timer.c:588
 internal_add_timer kernel/time/timer.c:617 [inline]
 __mod_timer+0x8d3/0xcf0 kernel/time/timer.c:1068
 add_timer+0x68/0x80 kernel/time/timer.c:1150
 __queue_delayed_work+0x16d/0x1f0 kernel/workqueue.c:1697
 queue_delayed_work_on+0x10f/0x180 kernel/workqueue.c:1722
 queue_delayed_work include/linux/workqueue.h:525 [inline]
 schedule_delayed_work include/linux/workqueue.h:629 [inline]
 hci_cmd_work+0x22d/0x270 net/bluetooth/hci_core.c:5198
 process_one_work+0x6bb/0xc10 kernel/workqueue.c:2317
 worker_thread+0xad5/0x12a0 kernel/workqueue.c:2464
 kthread+0x421/0x510 kernel/kthread.c:337
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298
 </TASK>

Allocated by task 23782:
 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+0x13a/0x270 mm/slub.c:4427
 kmalloc include/linux/slab.h:608 [inline]
 kzalloc include/linux/slab.h:733 [inline]
 hci_alloc_dev_priv+0x27/0x1bd0 net/bluetooth/hci_core.c:3774
 hci_alloc_dev include/net/bluetooth/hci_core.h:1263 [inline]
 hci_uart_register_dev drivers/bluetooth/hci_ldisc.c:633 [inline]
 hci_uart_set_proto drivers/bluetooth/hci_ldisc.c:709 [inline]
 hci_uart_tty_ioctl+0x3c8/0xa10 drivers/bluetooth/hci_ldisc.c:763
 tty_ioctl+0x93b/0xc90 drivers/tty/tty_io.c:2816
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl+0x114/0x190 fs/ioctl.c:860
 __x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:860
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xd3/0xf0 mm/kasan/generic.c:348
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:358
 insert_work+0x56/0x320 kernel/workqueue.c:1373
 __queue_work+0x92a/0xcd0 kernel/workqueue.c:1539
 queue_work_on+0x105/0x170 kernel/workqueue.c:1566
 queue_work include/linux/workqueue.h:510 [inline]
 hci_cmd_timeout+0x199/0x200 net/bluetooth/hci_core.c:2787
 process_one_work+0x6bb/0xc10 kernel/workqueue.c:2317
 worker_thread+0xad5/0x12a0 kernel/workqueue.c:2464
 kthread+0x421/0x510 kernel/kthread.c:337
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

Second to last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xd3/0xf0 mm/kasan/generic.c:348
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:358
 insert_work+0x56/0x320 kernel/workqueue.c:1373
 __queue_work+0x92a/0xcd0 kernel/workqueue.c:1539
 delayed_work_timer_fn+0x61/0x80 kernel/workqueue.c:1664
 call_timer_fn+0x3b/0x2d0 kernel/time/timer.c:1427
 expire_timers kernel/time/timer.c:1467 [inline]
 __run_timers+0x756/0xa10 kernel/time/timer.c:1743
 run_timer_softirq+0x69/0xf0 kernel/time/timer.c:1756
 __do_softirq+0x26d/0x5bf kernel/softirq.c:565

The buggy address belongs to the object at ffff8881162c4000
 which belongs to the cache kmalloc-8k of size 8192
The buggy address is located 2272 bytes inside of
 8192-byte region [ffff8881162c4000, ffff8881162c6000)
The buggy address belongs to the page:
page:ffffea000458b000 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8881162c4000 pfn:0x1162c0
head:ffffea000458b000 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x4000000000010200(slab|head|zone=1)
raw: 4000000000010200 ffffea0004404800 0000000300000003 ffff888100043500
raw: ffff8881162c4000 0000000080020001 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 22794, ts 1465204670634, free_ts 1464798052684
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x1a3/0x1b0 mm/page_alloc.c:2604
 prep_new_page+0x1b/0x110 mm/page_alloc.c:2610
 get_page_from_freelist+0x3550/0x35d0 mm/page_alloc.c:4484
 __alloc_pages+0x27e/0x8f0 mm/page_alloc.c:5776
 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]
 kmem_cache_alloc_trace+0x142/0x210 mm/slub.c:3265
 kmalloc include/linux/slab.h:603 [inline]
 kzalloc include/linux/slab.h:733 [inline]
 fat_fill_super+0x116/0x4f40 fs/fat/inode.c:1624
 vfat_fill_super+0x31/0x40 fs/fat/namei_vfat.c:1051
 mount_bdev+0x282/0x3b0 fs/super.c:1387
 vfat_mount+0x34/0x40 fs/fat/namei_vfat.c:1058
 legacy_get_tree+0xf1/0x190 fs/fs_context.c:611
 vfs_get_tree+0x88/0x290 fs/super.c:1517
 do_new_mount+0x28b/0xad0 fs/namespace.c:2994
 path_mount+0x671/0x1070 fs/namespace.c:3324
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 free_pages_prepare mm/page_alloc.c:1471 [inline]
 free_pcp_prepare mm/page_alloc.c:1543 [inline]
 free_unref_page_prepare+0x7c8/0x7d0 mm/page_alloc.c:3533
 free_unref_page+0xe8/0x750 mm/page_alloc.c:3615
 free_the_page mm/page_alloc.c:804 [inline]
 __free_pages+0x61/0xf0 mm/page_alloc.c:5852
 __free_slab+0xec/0x1d0 mm/slub.c:2020
 free_slab mm/slub.c:2035 [inline]
 discard_slab mm/slub.c:2041 [inline]
 __unfreeze_partials+0x165/0x1a0 mm/slub.c:2527
 put_cpu_partial+0xc4/0x120 mm/slub.c:2607
 __slab_free+0x1c8/0x290 mm/slub.c:3388
 do_slab_free mm/slub.c:3507 [inline]
 ___cache_free+0x109/0x120 mm/slub.c:3526
 qlink_free+0x4d/0x90 mm/kasan/quarantine.c:157
 qlist_free_all+0x44/0xb0 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x15a/0x180 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xe0 mm/kasan/common.c:443
 kasan_slab_alloc include/linux/kasan.h:217 [inline]
 slab_post_alloc_hook+0x53/0x2c0 mm/slab.h:550
 slab_alloc_node mm/slub.c:3240 [inline]
 slab_alloc mm/slub.c:3248 [inline]
 kmem_cache_alloc+0xf5/0x200 mm/slub.c:3253
 getname_flags+0xba/0x520 fs/namei.c:138
 getname+0x19/0x20 fs/namei.c:217

Memory state around the buggy address:
 ffff8881162c4780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881162c4800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8881162c4880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                       ^
 ffff8881162c4900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881162c4980: 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
2024/01/18 11:56 android13-5.15-lts 1c3a1f32bcbd 239abf84 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Write in enqueue_timer
* Struck through repros no longer work on HEAD.