BTRFS error (device loop0 state EMA): remounting read-write after error is not allowed ================================================================== BUG: KASAN: slab-use-after-free in rb_left_deepest_node lib/rbtree.c:595 [inline] BUG: KASAN: slab-use-after-free in rb_first_postorder+0x69/0x90 lib/rbtree.c:628 Read of size 8 at addr ffff88804ac11010 by task syz.0.0/5116 CPU: 0 UID: 0 PID: 5116 Comm: syz.0.0 Not tainted 6.11.0-syzkaller-02520-gadfc3ded5c33 #0 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:93 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:119 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 rb_left_deepest_node lib/rbtree.c:595 [inline] rb_first_postorder+0x69/0x90 lib/rbtree.c:628 btrfs_cleanup_defrag_inodes+0x2f/0x80 fs/btrfs/defrag.c:212 btrfs_remount_cleanup fs/btrfs/super.c:1263 [inline] btrfs_reconfigure+0x269c/0x2d40 fs/btrfs/super.c:1555 reconfigure_super+0x445/0x880 fs/super.c:1083 do_remount fs/namespace.c:3047 [inline] path_mount+0xc22/0xfa0 fs/namespace.c:3826 do_mount fs/namespace.c:3847 [inline] __do_sys_mount fs/namespace.c:4055 [inline] __se_sys_mount+0x2d6/0x3c0 fs/namespace.c:4032 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:0x7fe08017f69a Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 1a 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 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:00007fe080edde68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007fe080eddef0 RCX: 00007fe08017f69a RDX: 0000000020000f40 RSI: 0000000020000f00 RDI: 0000000000000000 RBP: 0000000020000f40 R08: 00007fe080eddef0 R09: 0000000001a4a438 R10: 0000000001a4a438 R11: 0000000000000246 R12: 0000000020000f00 R13: 00007fe080eddeb0 R14: 0000000000000000 R15: 00000000200008c0 Allocated by task 5115: 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:312 [inline] __kasan_slab_alloc+0x66/0x80 mm/kasan/common.c:338 kasan_slab_alloc include/linux/kasan.h:201 [inline] slab_post_alloc_hook mm/slub.c:3989 [inline] slab_alloc_node mm/slub.c:4038 [inline] kmem_cache_alloc_noprof+0x135/0x2a0 mm/slub.c:4045 btrfs_add_inode_defrag+0x15c/0x790 fs/btrfs/defrag.c:136 inode_should_defrag fs/btrfs/inode.c:888 [inline] cow_file_range+0x380/0x11f0 fs/btrfs/inode.c:1382 btrfs_run_delalloc_range+0x33d/0xf70 fs/btrfs/inode.c:2334 writepage_delalloc+0x482/0x7d0 fs/btrfs/extent_io.c:1192 extent_writepage fs/btrfs/extent_io.c:1454 [inline] extent_write_cache_pages fs/btrfs/extent_io.c:2130 [inline] btrfs_writepages+0x1157/0x2370 fs/btrfs/extent_io.c:2261 do_writepages+0x35d/0x870 mm/page-writeback.c:2683 filemap_fdatawrite_wbc+0x125/0x180 mm/filemap.c:397 __filemap_fdatawrite_range mm/filemap.c:430 [inline] filemap_fdatawrite_range+0x120/0x180 mm/filemap.c:448 btrfs_fdatawrite_range+0x53/0xe0 fs/btrfs/file.c:3799 btrfs_direct_write+0x565/0xa70 fs/btrfs/direct-io.c:961 btrfs_do_write_iter+0x2a0/0x760 fs/btrfs/file.c:1505 new_sync_write fs/read_write.c:590 [inline] vfs_write+0xa6d/0xc90 fs/read_write.c:683 ksys_pwrite64 fs/read_write.c:798 [inline] __do_sys_pwrite64 fs/read_write.c:808 [inline] __se_sys_pwrite64 fs/read_write.c:805 [inline] __x64_sys_pwrite64+0x1aa/0x230 fs/read_write.c:805 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 5115: 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+0xe0/0x150 mm/kasan/common.c:240 __kasan_slab_free+0x37/0x60 mm/kasan/common.c:256 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2250 [inline] slab_free mm/slub.c:4474 [inline] kmem_cache_free+0x145/0x350 mm/slub.c:4549 btrfs_cleanup_defrag_inodes+0x51/0x80 fs/btrfs/defrag.c:214 btrfs_remount_cleanup fs/btrfs/super.c:1263 [inline] btrfs_reconfigure+0x269c/0x2d40 fs/btrfs/super.c:1555 reconfigure_super+0x445/0x880 fs/super.c:1083 vfs_cmd_reconfigure fs/fsopen.c:263 [inline] vfs_fsconfig_locked fs/fsopen.c:292 [inline] __do_sys_fsconfig fs/fsopen.c:473 [inline] __se_sys_fsconfig+0xb68/0xf70 fs/fsopen.c:345 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 The buggy address belongs to the object at ffff88804ac11000 which belongs to the cache btrfs_inode_defrag of size 56 The buggy address is located 16 bytes inside of freed 56-byte region [ffff88804ac11000, ffff88804ac11038) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x4ac11 flags: 0x4fff00000000000(node=1|zone=1|lastcpupid=0x7ff) page_type: 0xfdffffff(slab) raw: 04fff00000000000 ffff88803d4c0a00 dead000000000122 0000000000000000 raw: 0000000000000000 00000000802e002e 00000001fdffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0x52c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 5115, tgid 5114 (syz.0.0), ts 91102950206, free_ts 90281627083 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1500 prep_new_page mm/page_alloc.c:1508 [inline] get_page_from_freelist+0x2e4c/0x2f10 mm/page_alloc.c:3446 __alloc_pages_noprof+0x256/0x6c0 mm/page_alloc.c:4702 __alloc_pages_node_noprof include/linux/gfp.h:269 [inline] alloc_pages_node_noprof include/linux/gfp.h:296 [inline] alloc_slab_page+0x5f/0x120 mm/slub.c:2319 allocate_slab+0x5a/0x2f0 mm/slub.c:2482 new_slab mm/slub.c:2535 [inline] ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3721 __slab_alloc+0x58/0xa0 mm/slub.c:3811 __slab_alloc_node mm/slub.c:3864 [inline] slab_alloc_node mm/slub.c:4026 [inline] kmem_cache_alloc_noprof+0x1c1/0x2a0 mm/slub.c:4045 btrfs_add_inode_defrag+0x15c/0x790 fs/btrfs/defrag.c:136 inode_should_defrag fs/btrfs/inode.c:888 [inline] cow_file_range+0x380/0x11f0 fs/btrfs/inode.c:1382 btrfs_run_delalloc_range+0x33d/0xf70 fs/btrfs/inode.c:2334 writepage_delalloc+0x482/0x7d0 fs/btrfs/extent_io.c:1192 extent_writepage fs/btrfs/extent_io.c:1454 [inline] extent_write_cache_pages fs/btrfs/extent_io.c:2130 [inline] btrfs_writepages+0x1157/0x2370 fs/btrfs/extent_io.c:2261 do_writepages+0x35d/0x870 mm/page-writeback.c:2683 filemap_fdatawrite_wbc+0x125/0x180 mm/filemap.c:397 __filemap_fdatawrite_range mm/filemap.c:430 [inline] filemap_fdatawrite_range+0x120/0x180 mm/filemap.c:448 page last free pid 5101 tgid 5101 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1101 [inline] free_unref_folios+0x103a/0x1b00 mm/page_alloc.c:2667 folios_put_refs+0x76e/0x860 mm/swap.c:1039 free_pages_and_swap_cache+0x5c8/0x690 mm/swap_state.c:335 __tlb_batch_free_encoded_pages mm/mmu_gather.c:136 [inline] tlb_batch_pages_flush mm/mmu_gather.c:149 [inline] tlb_flush_mmu_free mm/mmu_gather.c:366 [inline] tlb_flush_mmu+0x3a3/0x680 mm/mmu_gather.c:373 tlb_finish_mmu+0xd4/0x200 mm/mmu_gather.c:465 exit_mmap+0x44f/0xc80 mm/mmap.c:3425 __mmput+0x115/0x390 kernel/fork.c:1345 exit_mm+0x220/0x310 kernel/exit.c:571 do_exit+0x9b2/0x27f0 kernel/exit.c:869 do_group_exit+0x207/0x2c0 kernel/exit.c:1031 __do_sys_exit_group kernel/exit.c:1042 [inline] __se_sys_exit_group kernel/exit.c:1040 [inline] __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1040 x64_sys_call+0x2634/0x2640 arch/x86/include/generated/asm/syscalls_64.h:232 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: ffff88804ac10f00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88804ac10f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88804ac11000: fa fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc ^ ffff88804ac11080: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88804ac11100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================