================================================================== BUG: KASAN: slab-use-after-free in __lock_acquire+0x77/0x1fd0 kernel/locking/lockdep.c:5005 Read of size 8 at addr ffff8880183c27b8 by task kworker/u4:3/10078 CPU: 0 PID: 10078 Comm: kworker/u4:3 Not tainted 6.7.0-rc5-syzkaller-00230-g3b8a9b2e6809 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023 Workqueue: btrfs-delalloc btrfs_work_helper Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:364 [inline] print_report+0x163/0x540 mm/kasan/report.c:475 kasan_report+0x142/0x170 mm/kasan/report.c:588 __lock_acquire+0x77/0x1fd0 kernel/locking/lockdep.c:5005 lock_acquire+0x1e3/0x530 kernel/locking/lockdep.c:5754 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0xd5/0x120 kernel/locking/spinlock.c:162 class_raw_spinlock_irqsave_constructor include/linux/spinlock.h:518 [inline] try_to_wake_up+0xb5/0x1440 kernel/sched/core.c:4226 submit_compressed_extents+0xde/0x1a50 fs/btrfs/inode.c:1587 run_ordered_work fs/btrfs/async-thread.c:289 [inline] btrfs_work_helper+0x923/0xbe0 fs/btrfs/async-thread.c:325 process_one_work kernel/workqueue.c:2627 [inline] process_scheduled_works+0x90f/0x1420 kernel/workqueue.c:2700 worker_thread+0xa5f/0x1000 kernel/workqueue.c:2781 kthread+0x2d3/0x370 kernel/kthread.c:388 ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:242 Allocated by task 2: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4f/0x70 mm/kasan/common.c:52 __kasan_slab_alloc+0x66/0x70 mm/kasan/common.c:328 kasan_slab_alloc include/linux/kasan.h:188 [inline] slab_post_alloc_hook+0x6c/0x3c0 mm/slab.h:763 slab_alloc_node mm/slub.c:3478 [inline] kmem_cache_alloc_node+0x1dd/0x310 mm/slub.c:3523 alloc_task_struct_node kernel/fork.c:173 [inline] dup_task_struct+0x57/0x7d0 kernel/fork.c:1110 copy_process+0x5d1/0x3fb0 kernel/fork.c:2332 kernel_clone+0x222/0x840 kernel/fork.c:2907 kernel_thread+0x1bc/0x230 kernel/fork.c:2969 create_kthread kernel/kthread.c:411 [inline] kthreadd+0x60c/0x810 kernel/kthread.c:764 ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:242 Freed by task 10077: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4f/0x70 mm/kasan/common.c:52 kasan_save_free_info+0x28/0x40 mm/kasan/generic.c:522 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236 kasan_slab_free include/linux/kasan.h:164 [inline] slab_free_hook mm/slub.c:1800 [inline] slab_free_freelist_hook mm/slub.c:1826 [inline] slab_free mm/slub.c:3809 [inline] kmem_cache_free+0x299/0x470 mm/slub.c:3831 put_task_struct include/linux/sched/task.h:136 [inline] delayed_put_task_struct+0x115/0x2c0 kernel/exit.c:227 rcu_do_batch kernel/rcu/tree.c:2158 [inline] rcu_core+0xad8/0x17c0 kernel/rcu/tree.c:2431 __do_softirq+0x2b8/0x939 kernel/softirq.c:553 Last potentially related work creation: kasan_save_stack+0x3f/0x60 mm/kasan/common.c:45 __kasan_record_aux_stack+0xad/0xc0 mm/kasan/generic.c:492 __call_rcu_common kernel/rcu/tree.c:2681 [inline] call_rcu+0x167/0xa80 kernel/rcu/tree.c:2795 context_switch kernel/sched/core.c:5379 [inline] __schedule+0x1969/0x4ab0 kernel/sched/core.c:6688 preempt_schedule_common+0x83/0xc0 kernel/sched/core.c:6865 preempt_schedule+0xdd/0xf0 kernel/sched/core.c:6889 preempt_schedule_thunk+0x1a/0x30 arch/x86/entry/thunk_64.S:45 class_preempt_destructor include/linux/preempt.h:478 [inline] try_to_wake_up+0x994/0x1440 kernel/sched/core.c:4349 kthread_stop+0x16a/0x5e0 kernel/kthread.c:706 close_ctree+0x4d1/0xd40 fs/btrfs/disk-io.c:4342 generic_shutdown_super+0x13a/0x2c0 fs/super.c:696 kill_anon_super+0x3b/0x70 fs/super.c:1295 btrfs_kill_super+0x41/0x50 fs/btrfs/super.c:2100 deactivate_locked_super+0xc1/0x130 fs/super.c:484 cleanup_mnt+0x426/0x4c0 fs/namespace.c:1256 task_work_run+0x24a/0x300 kernel/task_work.c:180 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop+0xde/0x100 kernel/entry/common.c:171 exit_to_user_mode_prepare+0xb1/0x150 kernel/entry/common.c:204 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x69/0x2a0 kernel/entry/common.c:296 do_syscall_64+0x52/0x110 arch/x86/entry/common.c:89 entry_SYSCALL_64_after_hwframe+0x63/0x6b The buggy address belongs to the object at ffff8880183c1dc0 which belongs to the cache task_struct of size 7360 The buggy address is located 2552 bytes inside of freed 7360-byte region [ffff8880183c1dc0, ffff8880183c3a80) The buggy address belongs to the physical page: page:ffffea000060f000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x183c0 head:ffffea000060f000 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0 memcg:ffff8880255e9c41 flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000000840 ffff888014e51500 dead000000000122 0000000000000000 raw: 0000000000000000 0000000000040004 00000001ffffffff ffff8880255e9c41 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 2, tgid 2 (kthreadd), ts 2168634018580, free_ts 2168176112001 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x1e6/0x210 mm/page_alloc.c:1537 prep_new_page mm/page_alloc.c:1544 [inline] get_page_from_freelist+0x33ea/0x3570 mm/page_alloc.c:3312 __alloc_pages+0x255/0x680 mm/page_alloc.c:4568 alloc_pages_mpol+0x3de/0x640 mm/mempolicy.c:2133 alloc_slab_page+0x6a/0x170 mm/slub.c:1870 allocate_slab mm/slub.c:2017 [inline] new_slab+0x84/0x2f0 mm/slub.c:2070 ___slab_alloc+0xc8a/0x1330 mm/slub.c:3223 __slab_alloc mm/slub.c:3322 [inline] __slab_alloc_node mm/slub.c:3375 [inline] slab_alloc_node mm/slub.c:3468 [inline] kmem_cache_alloc_node+0x22b/0x310 mm/slub.c:3523 alloc_task_struct_node kernel/fork.c:173 [inline] dup_task_struct+0x57/0x7d0 kernel/fork.c:1110 copy_process+0x5d1/0x3fb0 kernel/fork.c:2332 kernel_clone+0x222/0x840 kernel/fork.c:2907 kernel_thread+0x1bc/0x230 kernel/fork.c:2969 create_kthread kernel/kthread.c:411 [inline] kthreadd+0x60c/0x810 kernel/kthread.c:764 ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:242 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1137 [inline] free_unref_page_prepare+0x931/0xa60 mm/page_alloc.c:2347 free_unref_page+0x37/0x3f0 mm/page_alloc.c:2487 __slab_free+0x2f6/0x390 mm/slub.c:3715 qlink_free mm/kasan/quarantine.c:168 [inline] qlist_free_all+0x75/0xe0 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x14b/0x160 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0x23/0x70 mm/kasan/common.c:305 kasan_slab_alloc include/linux/kasan.h:188 [inline] slab_post_alloc_hook+0x6c/0x3c0 mm/slab.h:763 slab_alloc_node mm/slub.c:3478 [inline] __kmem_cache_alloc_node+0x1d0/0x300 mm/slub.c:3517 __do_kmalloc_node mm/slab_common.c:1006 [inline] __kmalloc+0xa2/0x1a0 mm/slab_common.c:1020 kmalloc include/linux/slab.h:604 [inline] tomoyo_realpath_from_path+0xcf/0x5e0 security/tomoyo/realpath.c:251 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_path_perm+0x2b7/0x730 security/tomoyo/file.c:822 security_inode_getattr+0xd3/0x120 security/security.c:2153 vfs_getattr+0x46/0x430 fs/stat.c:173 vfs_fstat fs/stat.c:198 [inline] vfs_fstatat+0xd6/0x190 fs/stat.c:295 __do_sys_newfstatat fs/stat.c:463 [inline] __se_sys_newfstatat fs/stat.c:457 [inline] __x64_sys_newfstatat+0x117/0x190 fs/stat.c:457 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0x45/0x110 arch/x86/entry/common.c:83 Memory state around the buggy address: ffff8880183c2680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880183c2700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8880183c2780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8880183c2800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880183c2880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================