BTRFS info (device loop0): first mount of filesystem 395ef67a-297e-477c-816d-cd80a5b93e5d BTRFS info (device loop0): using sha256 (sha256-avx2) checksum algorithm BTRFS info (device loop0): using free-space-tree ================================================================== BUG: KASAN: slab-use-after-free in add_delayed_ref+0xf45/0x1930 fs/btrfs/delayed-ref.c:1077 Read of size 8 at addr ffff88801eaacf50 by task syz.0.26/4232 CPU: 0 UID: 0 PID: 4232 Comm: syz.0.26 Not tainted 6.12.0-rc2-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x198/0x250 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:377 [inline] print_report+0x169/0x550 mm/kasan/report.c:488 kasan_report+0x143/0x180 mm/kasan/report.c:601 add_delayed_ref+0xf45/0x1930 fs/btrfs/delayed-ref.c:1077 btrfs_alloc_tree_block+0xe03/0x1530 fs/btrfs/extent-tree.c:5201 btrfs_force_cow_block+0x4bd/0x19a0 fs/btrfs/ctree.c:573 btrfs_cow_block+0x39a/0x940 fs/btrfs/ctree.c:754 btrfs_search_slot+0x98a/0x28f0 btrfs_insert_empty_items+0x97/0x140 fs/btrfs/ctree.c:4314 btrfs_create_new_inode+0xd07/0x1c20 fs/btrfs/inode.c:6320 btrfs_create_common+0x362/0x490 fs/btrfs/inode.c:6554 vfs_mkdir+0x24d/0x3d0 fs/namei.c:4257 do_mkdirat+0x234/0x330 fs/namei.c:4280 __do_sys_mkdirat fs/namei.c:4295 [inline] __se_sys_mkdirat fs/namei.c:4293 [inline] __x64_sys_mkdirat+0x82/0x90 fs/namei.c:4293 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f8aacf7dff9 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:00007f8aade0d038 EFLAGS: 00000246 ORIG_RAX: 0000000000000102 RAX: ffffffffffffffda RBX: 00007f8aad135f80 RCX: 00007f8aacf7dff9 RDX: 0000000000000000 RSI: 0000000020000200 RDI: 0000000000000005 RBP: 00007f8aacff0296 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f8aad135f80 R15: 00007fff4f527bf8 Allocated by task 4232: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 unpoison_slab_object mm/kasan/common.c:319 [inline] __kasan_slab_alloc+0x66/0x80 mm/kasan/common.c:345 kasan_slab_alloc include/linux/kasan.h:247 [inline] slab_post_alloc_hook mm/slub.c:4085 [inline] slab_alloc_node mm/slub.c:4134 [inline] kmem_cache_alloc_noprof+0x135/0x2a0 mm/slub.c:4141 add_delayed_ref+0x130/0x1930 fs/btrfs/delayed-ref.c:1020 btrfs_alloc_tree_block+0xe03/0x1530 fs/btrfs/extent-tree.c:5201 btrfs_force_cow_block+0x4bd/0x19a0 fs/btrfs/ctree.c:573 btrfs_cow_block+0x39a/0x940 fs/btrfs/ctree.c:754 btrfs_search_slot+0x98a/0x28f0 btrfs_insert_empty_items+0x97/0x140 fs/btrfs/ctree.c:4314 btrfs_create_new_inode+0xd07/0x1c20 fs/btrfs/inode.c:6320 btrfs_create_common+0x362/0x490 fs/btrfs/inode.c:6554 vfs_mkdir+0x24d/0x3d0 fs/namei.c:4257 do_mkdirat+0x234/0x330 fs/namei.c:4280 __do_sys_mkdirat fs/namei.c:4295 [inline] __se_sys_mkdirat fs/namei.c:4293 [inline] __x64_sys_mkdirat+0x82/0x90 fs/namei.c:4293 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 1562: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579 poison_slab_object mm/kasan/common.c:247 [inline] __kasan_slab_free+0x59/0x70 mm/kasan/common.c:264 kasan_slab_free include/linux/kasan.h:230 [inline] slab_free_hook mm/slub.c:2342 [inline] slab_free mm/slub.c:4579 [inline] kmem_cache_free+0x1a2/0x420 mm/slub.c:4681 btrfs_put_delayed_ref_head fs/btrfs/delayed-ref.h:358 [inline] cleanup_ref_head fs/btrfs/extent-tree.c:1932 [inline] __btrfs_run_delayed_refs+0x32d8/0x3c60 fs/btrfs/extent-tree.c:2113 btrfs_run_delayed_refs+0xcd/0x230 fs/btrfs/extent-tree.c:2213 btrfs_commit_transaction+0x3b8/0x30f0 fs/btrfs/transaction.c:2197 btrfs_qgroup_rescan_worker+0x16f5/0x1ab0 fs/btrfs/qgroup.c:3868 btrfs_work_helper+0x2ee/0xa20 fs/btrfs/async-thread.c:314 process_one_work kernel/workqueue.c:3229 [inline] process_scheduled_works+0x96c/0x1540 kernel/workqueue.c:3310 worker_thread+0x727/0xb10 kernel/workqueue.c:3391 kthread+0x2e0/0x380 kernel/kthread.c:389 ret_from_fork+0x32/0x60 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 The buggy address belongs to the object at ffff88801eaacf50 which belongs to the cache btrfs_delayed_ref_head of size 328 The buggy address is located 0 bytes inside of freed 328-byte region [ffff88801eaacf50, ffff88801eaad098) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1eaac head: order:1 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 00fff00000000040 ffff88801e40da00 dead000000000122 0000000000000000 raw: 0000000000000000 0000000080140014 00000001f5000000 0000000000000000 head: 00fff00000000040 ffff88801e40da00 dead000000000122 0000000000000000 head: 0000000000000000 0000000080140014 00000001f5000000 0000000000000000 head: 00fff00000000001 ffffea00007aab01 ffffffffffffffff 0000000000000000 head: ffff888000000002 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 1, migratetype Unmovable, gfp_mask 0xd2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3658, tgid 3658 (syz-executor), ts 95450239207, free_ts 95358632189 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1537 prep_new_page mm/page_alloc.c:1545 [inline] get_page_from_freelist+0x3045/0x3190 mm/page_alloc.c:3457 __alloc_pages_noprof+0x256/0x6c0 mm/page_alloc.c:4733 alloc_pages_mpol_noprof+0x284/0x4d0 mm/mempolicy.c:2265 alloc_slab_page+0x6a/0x120 mm/slub.c:2412 allocate_slab+0x5a/0x2f0 mm/slub.c:2578 new_slab mm/slub.c:2631 [inline] ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3818 __slab_alloc+0x58/0xa0 mm/slub.c:3908 __slab_alloc_node mm/slub.c:3961 [inline] slab_alloc_node mm/slub.c:4122 [inline] kmem_cache_alloc_noprof+0x1c1/0x2a0 mm/slub.c:4141 add_delayed_ref+0x130/0x1930 fs/btrfs/delayed-ref.c:1020 btrfs_free_tree_block+0x332/0xc70 fs/btrfs/extent-tree.c:3455 btrfs_force_cow_block+0xbcd/0x19a0 fs/btrfs/ctree.c:650 btrfs_cow_block+0x39a/0x940 fs/btrfs/ctree.c:754 btrfs_search_slot+0x98a/0x28f0 btrfs_update_root+0xe7/0xac0 fs/btrfs/root-tree.c:144 update_cowonly_root fs/btrfs/transaction.c:1301 [inline] commit_cowonly_roots+0x564/0x740 fs/btrfs/transaction.c:1368 page last free pid 4024 tgid 4024 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1108 [inline] free_unref_page+0xcfb/0xf20 mm/page_alloc.c:2638 __slab_free+0x31b/0x3d0 mm/slub.c:4490 qlink_free mm/kasan/quarantine.c:163 [inline] qlist_free_all+0x9a/0x140 mm/kasan/quarantine.c:179 kasan_quarantine_reduce+0x14f/0x170 mm/kasan/quarantine.c:286 __kasan_slab_alloc+0x23/0x80 mm/kasan/common.c:329 kasan_slab_alloc include/linux/kasan.h:247 [inline] slab_post_alloc_hook mm/slub.c:4085 [inline] slab_alloc_node mm/slub.c:4134 [inline] __do_kmalloc_node mm/slub.c:4263 [inline] __kmalloc_node_noprof+0x1d2/0x440 mm/slub.c:4270 kmalloc_array_node_noprof include/linux/slab.h:995 [inline] alloc_slab_obj_exts mm/slub.c:1968 [inline] account_slab mm/slub.c:2541 [inline] allocate_slab+0xb6/0x2f0 mm/slub.c:2596 new_slab mm/slub.c:2631 [inline] ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3818 __slab_alloc+0x58/0xa0 mm/slub.c:3908 __slab_alloc_node mm/slub.c:3961 [inline] slab_alloc_node mm/slub.c:4122 [inline] kmem_cache_alloc_noprof+0x1c1/0x2a0 mm/slub.c:4141 inotify_new_watch fs/notify/inotify/inotify_user.c:599 [inline] inotify_update_watch fs/notify/inotify/inotify_user.c:647 [inline] __do_sys_inotify_add_watch fs/notify/inotify/inotify_user.c:786 [inline] __se_sys_inotify_add_watch+0x5b7/0xce0 fs/notify/inotify/inotify_user.c:729 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Memory state around the buggy address: ffff88801eaace00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88801eaace80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88801eaacf00: fb fb fc fc fc fc fc fc fc fc fa fb fb fb fb fb ^ ffff88801eaacf80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88801eaad000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================