syzbot


KASAN: use-after-free Read in try_to_wake_up (2)

Status: upstream: reported on 2024/08/05 02:45
Reported-by: syzbot+1bb455796d70d7020ec3@syzkaller.appspotmail.com
First crash: 108d, last: 77d
Similar bugs (9)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 KASAN: use-after-free Read in try_to_wake_up C done 71 63d 518d 3/3 fixed on 2024/10/21 12:01
linux-4.14 KASAN: use-after-free Read in try_to_wake_up nilfs2 C 8 631d 753d 0/1 upstream: reported C repro on 2022/10/30 09:08
upstream general protection fault in try_to_wake_up (2) io-uring C done done 3588 126d 1364d 0/28 closed as invalid on 2024/07/25 16:29
upstream KASAN: use-after-free Read in try_to_wake_up fs C unreliable 82 1365d 1365d 0/28 closed as invalid on 2021/02/25 16:53
linux-6.1 KASAN: use-after-free Read in try_to_wake_up origin:upstream missing-backport C done 44 167d 599d 3/3 fixed on 2024/07/22 09:08
linux-4.14 general protection fault in try_to_wake_up C done 707 1315d 1344d 1/1 fixed on 2021/05/17 08:49
upstream WARNING: locking bug in try_to_wake_up kernel C error 157 9d11h 190d 28/28 fixed on 2024/11/12 23:31
linux-4.19 general protection fault in try_to_wake_up syz done 229 1257d 1344d 1/1 fixed on 2021/07/14 00:01
upstream BUG: unable to handle kernel paging request in try_to_wake_up (2) block 3 5h41m 4d16h 0/28 moderation: reported on 2024/11/17 02:46

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x77/0x1f80 kernel/locking/lockdep.c:4919
Read of size 8 at addr ffff888027b70a18 by task kworker/u4:7/3724

CPU: 1 PID: 3724 Comm: kworker/u4:7 Not tainted 6.1.103-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
Workqueue: btrfs-fixup btrfs_work_helper
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:284 [inline]
 print_report+0x15f/0x4f0 mm/kasan/report.c:395
 kasan_report+0x136/0x160 mm/kasan/report.c:495
 __lock_acquire+0x77/0x1f80 kernel/locking/lockdep.c:4919
 lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
 _raw_spin_lock_irqsave+0xd1/0x120 kernel/locking/spinlock.c:162
 try_to_wake_up+0xad/0x12e0 kernel/sched/core.c:4108
 btrfs_writepage_fixup_worker+0xa39/0xfe0 fs/btrfs/inode.c:2991
 btrfs_work_helper+0x396/0xcf0 fs/btrfs/async-thread.c:280
 process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292
 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
 </TASK>

Allocated by task 2:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 __kasan_slab_alloc+0x65/0x70 mm/kasan/common.c:328
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook+0x52/0x3a0 mm/slab.h:737
 slab_alloc_node mm/slub.c:3398 [inline]
 kmem_cache_alloc_node+0x136/0x310 mm/slub.c:3443
 alloc_task_struct_node kernel/fork.c:171 [inline]
 dup_task_struct+0x57/0x6d0 kernel/fork.c:980
 copy_process+0x637/0x4060 kernel/fork.c:2098
 kernel_clone+0x222/0x920 kernel/fork.c:2682
 kernel_thread+0x152/0x1d0 kernel/fork.c:2742
 create_kthread kernel/kthread.c:399 [inline]
 kthreadd+0x596/0x760 kernel/kthread.c:746
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Freed by task 21:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:516
 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook mm/slub.c:1750 [inline]
 slab_free mm/slub.c:3661 [inline]
 kmem_cache_free+0x292/0x510 mm/slub.c:3683
 rcu_do_batch kernel/rcu/tree.c:2296 [inline]
 rcu_core+0xad5/0x1810 kernel/rcu/tree.c:2556
 handle_softirqs+0x2ee/0xa40 kernel/softirq.c:571
 run_ksoftirqd+0xc6/0x120 kernel/softirq.c:938
 smpboot_thread_fn+0x52c/0xa30 kernel/smpboot.c:164
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:486
 call_rcu+0x163/0xa10 kernel/rcu/tree.c:2844
 context_switch kernel/sched/core.c:5244 [inline]
 __schedule+0x1447/0x4570 kernel/sched/core.c:6558
 preempt_schedule_common+0x83/0xd0 kernel/sched/core.c:6727
 preempt_schedule+0xd9/0xe0 kernel/sched/core.c:6751
 preempt_schedule_thunk+0x16/0x18 arch/x86/entry/thunk_64.S:34
 unwind_next_frame+0x1a55/0x2220 arch/x86/kernel/unwind_orc.c:629
 __unwind_start+0x59d/0x720 arch/x86/kernel/unwind_orc.c:717
 unwind_start arch/x86/include/asm/unwind.h:64 [inline]
 arch_stack_walk+0xdb/0x140 arch/x86/kernel/stacktrace.c:24
 stack_trace_save+0x113/0x1c0 kernel/stacktrace.c:122
 save_stack+0xf6/0x1e0 mm/page_owner.c:127
 __set_page_owner+0x26/0x390 mm/page_owner.c:190
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2517
 prep_new_page mm/page_alloc.c:2524 [inline]
 get_page_from_freelist+0x322e/0x33b0 mm/page_alloc.c:4283
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5551
 __folio_alloc+0xf/0x30 mm/page_alloc.c:5583
 vma_alloc_folio+0x486/0x990 mm/mempolicy.c:2243
 shmem_alloc_folio mm/shmem.c:1589 [inline]
 shmem_alloc_and_acct_folio+0x5a8/0xd50 mm/shmem.c:1613
 shmem_get_folio_gfp+0x13f0/0x3470 mm/shmem.c:1941
 shmem_get_folio mm/shmem.c:2072 [inline]
 shmem_write_begin+0x16e/0x4e0 mm/shmem.c:2559
 generic_perform_write+0x2fc/0x5e0 mm/filemap.c:3817
 __generic_file_write_iter+0x176/0x400 mm/filemap.c:3945
 generic_file_write_iter+0xab/0x310 mm/filemap.c:3977
 call_write_iter include/linux/fs.h:2265 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x857/0xbc0 fs/read_write.c:584
 ksys_write+0x19c/0x2c0 fs/read_write.c:637
 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+0xb0/0xc0 mm/kasan/generic.c:486
 call_rcu+0x163/0xa10 kernel/rcu/tree.c:2844
 context_switch kernel/sched/core.c:5244 [inline]
 __schedule+0x1447/0x4570 kernel/sched/core.c:6558
 schedule+0xbf/0x180 kernel/sched/core.c:6634
 futex_wait_queue+0x149/0x1d0 kernel/futex/waitwake.c:355
 futex_wait+0x203/0x5c0 kernel/futex/waitwake.c:656
 do_futex+0x3b5/0x490 kernel/futex/syscalls.c:106
 __do_sys_futex kernel/futex/syscalls.c:183 [inline]
 __se_sys_futex+0x3d7/0x460 kernel/futex/syscalls.c:164
 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 ffff888027b70000
 which belongs to the cache task_struct of size 7360
The buggy address is located 2584 bytes inside of
 7360-byte region [ffff888027b70000, ffff888027b71cc0)

The buggy address belongs to the physical page:
page:ffffea00009edc00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x27b70
head:ffffea00009edc00 order:3 compound_mapcount:0 compound_pincount:0
memcg:ffff88801b37b081
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea000081c000 dead000000000002 ffff888140008500
raw: 0000000000000000 0000000000040004 00000001ffffffff ffff88801b37b081
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 11, tgid 11 (kworker/u4:1), ts 8962296365, free_ts 0
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2517
 prep_new_page mm/page_alloc.c:2524 [inline]
 get_page_from_freelist+0x322e/0x33b0 mm/page_alloc.c:4283
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5551
 alloc_slab_page+0x6a/0x150 mm/slub.c:1794
 allocate_slab mm/slub.c:1939 [inline]
 new_slab+0x84/0x2d0 mm/slub.c:1992
 ___slab_alloc+0xc20/0x1270 mm/slub.c:3180
 __slab_alloc mm/slub.c:3279 [inline]
 slab_alloc_node mm/slub.c:3364 [inline]
 kmem_cache_alloc_node+0x1cf/0x310 mm/slub.c:3443
 alloc_task_struct_node kernel/fork.c:171 [inline]
 dup_task_struct+0x57/0x6d0 kernel/fork.c:980
 copy_process+0x637/0x4060 kernel/fork.c:2098
 kernel_clone+0x222/0x920 kernel/fork.c:2682
 user_mode_thread+0x12e/0x190 kernel/fork.c:2758
 call_usermodehelper_exec_work+0x58/0x220 kernel/umh.c:175
 process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292
 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
page_owner free stack trace missing

Memory state around the buggy address:
 ffff888027b70900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888027b70980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888027b70a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff888027b70a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888027b70b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/08/05 02:44 linux-6.1.y 48d525b0e463 1786a2a8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in try_to_wake_up
2024/09/05 10:21 linux-6.1.y 699506173494 464ac2ed .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in try_to_wake_up
* Struck through repros no longer work on HEAD.