stripe_sectors 0 cached_sectors 0 stripe 0 stripe_redundancy 0 io_time[READ] 0 io_time[WRITE] 0 fragmentation 134217728 bp_start 8 , fixing done bcachefs (loop0): check_snapshot_trees... done bcachefs (loop0): check_snapshots... done bcachefs (loop0): check_subvols... bcachefs (loop0): running recovery pass reconstruct_snapshots (21), currently at check_subvols (24) - rewinding bcachefs (loop0): bch2_check_subvols(): error restart_recovery bcachefs (loop0): reconstruct_snapshots... bcachefs (loop0): snapshot node 4294967295 from tree 4294967295 missing, recreating done bcachefs (loop0): check_snapshot_trees... done bcachefs (loop0): check_snapshots... done bcachefs (loop0): check_subvols... bcachefs (loop0): subvolume 1 points to missing subvolume root 4096:4294967295, fixing bcachefs (loop0): subvolume 1 is not set as snapshot but is not master subvolume, fixing done bcachefs (loop0): check_subvol_children... done bcachefs (loop0): delete_dead_snapshots... done bcachefs (loop0): check_inodes... done bcachefs (loop0): check_extents... done bcachefs (loop0): check_indirect_extents... done bcachefs (loop0): check_dirents... bcachefs (loop0): hash table key at wrong offset: should be at 6405876619929963955 u64s 8 type dirent 4096:1859603997870691834:U32_MAX len 0 ver 0: lost+found -> 4097 type dir, fixing bcachefs (loop0): hash table key at wrong offset: should be at 5756173401789250933 u64s 7 type dirent 4096:3784119180373593407:U32_MAX len 0 ver 0: file3 -> 1073741825 type reg, fixing bcachefs (loop0): hash table key at wrong offset: should be at 3391627682668465244 u64s 7 type dirent 4096:5682031293254759865:U32_MAX len 0 ver 0: file0 -> 4098 type dir, fixing bcachefs (loop0): hash table key at wrong offset: should be at 4067584848891989127 u64s 7 type dirent 4096:6229884513039707068:U32_MAX len 0 ver 0: file2 -> 1073741825 type reg, fixing bcachefs (loop0): hash table key at wrong offset: should be at 4510631498733243714 u64s 7 type dirent 4096:7012347908543992434:U32_MAX len 0 ver 0: file1 -> 1073741824 type reg, fixing bcachefs (loop0): hash table key at wrong offset: should be at 7845111814738718671 u64s 8 type dirent 4096:8117119959317756843:U32_MAX len 0 ver 0: file.cold -> 1073741826 type reg, fixing bcachefs (loop0): fsck counted subdirectories wrong for inum 4096:4294967295: got 1 should be 2 bcachefs (loop0): directory 4096:4294967295 with wrong i_nlink: got 0, should be 2, fixing bcachefs (loop0): check_dirents requires second pass done bcachefs (loop0): check_xattrs... bcachefs (loop0): hash table key at wrong offset: should be at 5972088504617275890 u64s 7 type xattr 1073741824:945502502804528484:U32_MAX len 0 ver 0: user.xattr2:xattr2, fixing ================================================================== BUG: KASAN: slab-use-after-free in bch2_str_hash_repair_key+0x2d42/0x3fa0 fs/bcachefs/str_hash.c:335 Read of size 8 at addr ffff888054e09c28 by task syz.0.0/5325 CPU: 0 UID: 0 PID: 5325 Comm: syz.0.0 Not tainted 6.16.0-rc3-syzkaller-00121-gf02769e7f272 #0 PREEMPT(full) 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_lvl+0x189/0x250 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:408 [inline] print_report+0xd2/0x2b0 mm/kasan/report.c:521 kasan_report+0x118/0x150 mm/kasan/report.c:634 bch2_str_hash_repair_key+0x2d42/0x3fa0 fs/bcachefs/str_hash.c:335 __bch2_str_hash_check_key+0xa65/0xd40 fs/bcachefs/str_hash.c:394 bch2_str_hash_check_key fs/bcachefs/str_hash.h:429 [inline] check_xattr fs/bcachefs/fsck.c:2383 [inline] bch2_check_xattrs+0x933/0xcc0 fs/bcachefs/fsck.c:2396 bch2_run_recovery_pass fs/bcachefs/recovery_passes.c:485 [inline] __bch2_run_recovery_passes+0x392/0x1010 fs/bcachefs/recovery_passes.c:540 bch2_run_recovery_passes+0x184/0x210 fs/bcachefs/recovery_passes.c:611 bch2_fs_recovery+0x25fd/0x3950 fs/bcachefs/recovery.c:989 bch2_fs_start+0xa99/0xd90 fs/bcachefs/super.c:1203 bch2_fs_get_tree+0xb02/0x14f0 fs/bcachefs/fs.c:2489 vfs_get_tree+0x92/0x2b0 fs/super.c:1804 do_new_mount+0x24a/0xa40 fs/namespace.c:3902 do_mount fs/namespace.c:4239 [inline] __do_sys_mount fs/namespace.c:4450 [inline] __se_sys_mount+0x317/0x410 fs/namespace.c:4427 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f491c9900ca 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:00007f491d80ee68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007f491d80eef0 RCX: 00007f491c9900ca RDX: 000020000000f640 RSI: 000020000000f680 RDI: 00007f491d80eeb0 RBP: 000020000000f640 R08: 00007f491d80eef0 R09: 0000000002810190 R10: 0000000002810190 R11: 0000000000000246 R12: 000020000000f680 R13: 00007f491d80eeb0 R14: 000000000000f636 R15: 0000200000000380 Allocated by task 5325: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3e/0x80 mm/kasan/common.c:68 poison_kmalloc_redzone mm/kasan/common.c:377 [inline] __kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:394 kasan_kmalloc include/linux/kasan.h:260 [inline] __do_kmalloc_node mm/slub.c:4328 [inline] __kmalloc_node_track_caller_noprof+0x271/0x4e0 mm/slub.c:4347 __do_krealloc mm/slub.c:4905 [inline] krealloc_noprof+0x124/0x340 mm/slub.c:4958 __bch2_trans_kmalloc+0x26c/0xc80 fs/bcachefs/btree_iter.c:3187 bch2_trans_kmalloc_ip fs/bcachefs/btree_iter.h:604 [inline] bch2_trans_kmalloc fs/bcachefs/btree_iter.h:616 [inline] bch2_str_hash_repair_key+0x2a65/0x3fa0 fs/bcachefs/str_hash.c:251 __bch2_str_hash_check_key+0xa65/0xd40 fs/bcachefs/str_hash.c:394 bch2_str_hash_check_key fs/bcachefs/str_hash.h:429 [inline] check_xattr fs/bcachefs/fsck.c:2383 [inline] bch2_check_xattrs+0x933/0xcc0 fs/bcachefs/fsck.c:2396 bch2_run_recovery_pass fs/bcachefs/recovery_passes.c:485 [inline] __bch2_run_recovery_passes+0x392/0x1010 fs/bcachefs/recovery_passes.c:540 bch2_run_recovery_passes+0x184/0x210 fs/bcachefs/recovery_passes.c:611 bch2_fs_recovery+0x25fd/0x3950 fs/bcachefs/recovery.c:989 bch2_fs_start+0xa99/0xd90 fs/bcachefs/super.c:1203 bch2_fs_get_tree+0xb02/0x14f0 fs/bcachefs/fs.c:2489 vfs_get_tree+0x92/0x2b0 fs/super.c:1804 do_new_mount+0x24a/0xa40 fs/namespace.c:3902 do_mount fs/namespace.c:4239 [inline] __do_sys_mount fs/namespace.c:4450 [inline] __se_sys_mount+0x317/0x410 fs/namespace.c:4427 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 5325: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3e/0x80 mm/kasan/common.c:68 kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:576 poison_slab_object mm/kasan/common.c:247 [inline] __kasan_slab_free+0x62/0x70 mm/kasan/common.c:264 kasan_slab_free include/linux/kasan.h:233 [inline] slab_free_hook mm/slub.c:2381 [inline] slab_free mm/slub.c:4643 [inline] kfree+0x18e/0x440 mm/slub.c:4842 krealloc_noprof+0x1cd/0x340 mm/slub.c:-1 __bch2_trans_kmalloc+0x26c/0xc80 fs/bcachefs/btree_iter.c:3187 bch2_trans_kmalloc_ip fs/bcachefs/btree_iter.h:604 [inline] bch2_trans_kmalloc fs/bcachefs/btree_iter.h:616 [inline] bch2_hash_delete_at fs/bcachefs/str_hash.h:364 [inline] bch2_str_hash_repair_key+0x2fde/0x3fa0 fs/bcachefs/str_hash.c:289 __bch2_str_hash_check_key+0xa65/0xd40 fs/bcachefs/str_hash.c:394 bch2_str_hash_check_key fs/bcachefs/str_hash.h:429 [inline] check_xattr fs/bcachefs/fsck.c:2383 [inline] bch2_check_xattrs+0x933/0xcc0 fs/bcachefs/fsck.c:2396 bch2_run_recovery_pass fs/bcachefs/recovery_passes.c:485 [inline] __bch2_run_recovery_passes+0x392/0x1010 fs/bcachefs/recovery_passes.c:540 bch2_run_recovery_passes+0x184/0x210 fs/bcachefs/recovery_passes.c:611 bch2_fs_recovery+0x25fd/0x3950 fs/bcachefs/recovery.c:989 bch2_fs_start+0xa99/0xd90 fs/bcachefs/super.c:1203 bch2_fs_get_tree+0xb02/0x14f0 fs/bcachefs/fs.c:2489 vfs_get_tree+0x92/0x2b0 fs/super.c:1804 do_new_mount+0x24a/0xa40 fs/namespace.c:3902 do_mount fs/namespace.c:4239 [inline] __do_sys_mount fs/namespace.c:4450 [inline] __se_sys_mount+0x317/0x410 fs/namespace.c:4427 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f The buggy address belongs to the object at ffff888054e09c00 which belongs to the cache kmalloc-128 of size 128 The buggy address is located 40 bytes inside of freed 128-byte region [ffff888054e09c00, ffff888054e09c80) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x54e09 flags: 0x4fff00000000000(node=1|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 04fff00000000000 ffff88801a441a00 dead000000000122 0000000000000000 raw: 0000000000000000 0000000080100010 00000000f5000000 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 5325, tgid 5324 (syz.0.0), ts 75671270374, free_ts 75400471116 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x240/0x2a0 mm/page_alloc.c:1704 prep_new_page mm/page_alloc.c:1712 [inline] get_page_from_freelist+0x21e4/0x22c0 mm/page_alloc.c:3669 __alloc_frozen_pages_noprof+0x181/0x370 mm/page_alloc.c:4959 alloc_pages_mpol+0x232/0x4a0 mm/mempolicy.c:2419 alloc_slab_page mm/slub.c:2451 [inline] allocate_slab+0x8a/0x3b0 mm/slub.c:2619 new_slab mm/slub.c:2673 [inline] ___slab_alloc+0xbfc/0x1480 mm/slub.c:3859 __slab_alloc mm/slub.c:3949 [inline] __slab_alloc_node mm/slub.c:4024 [inline] slab_alloc_node mm/slub.c:4185 [inline] __do_kmalloc_node mm/slub.c:4327 [inline] __kmalloc_node_track_caller_noprof+0x2f8/0x4e0 mm/slub.c:4347 __do_krealloc mm/slub.c:4905 [inline] krealloc_noprof+0x124/0x340 mm/slub.c:4958 bch2_printbuf_make_room+0x1f5/0x360 fs/bcachefs/printbuf.c:59 bch2_prt_printf+0x282/0x740 fs/bcachefs/printbuf.c:186 bch2_bpos_to_text+0x2c9/0x3d0 fs/bcachefs/bkey_methods.c:-1 bch2_btree_path_to_text_short+0x529/0xde0 fs/bcachefs/btree_iter.c:1528 __bch2_trans_paths_to_text+0xe5/0x190 fs/bcachefs/btree_iter.c:1589 bch2_trans_update_max_paths+0x14e/0x340 fs/bcachefs/btree_iter.c:1625 btree_path_alloc+0x89a/0xa70 fs/bcachefs/btree_iter.c:1722 btree_path_clone fs/bcachefs/btree_iter.c:1262 [inline] __bch2_btree_path_make_mut+0x1cc/0x520 fs/bcachefs/btree_iter.c:1277 page last free pid 5325 tgid 5324 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1248 [inline] __free_pages_ok+0xa44/0xc20 mm/page_alloc.c:1424 __folio_put+0x21b/0x2c0 mm/swap.c:112 folio_put include/linux/mm.h:1356 [inline] free_large_kmalloc+0x145/0x200 mm/slub.c:4768 btree_bounce_free fs/bcachefs/btree_io.c:115 [inline] btree_node_sort+0x117f/0x1760 fs/bcachefs/btree_io.c:383 bch2_btree_post_write_cleanup+0x11f/0xad0 fs/bcachefs/btree_io.c:2594 bch2_btree_node_write_trans+0x17b/0x760 fs/bcachefs/btree_io.c:2663 btree_node_write_if_need fs/bcachefs/btree_io.h:167 [inline] __btree_node_flush+0x323/0x430 fs/bcachefs/btree_trans_commit.c:255 bch2_btree_node_flush0+0x27/0x40 fs/bcachefs/btree_trans_commit.c:264 journal_flush_pins+0x8e3/0xe90 fs/bcachefs/journal_reclaim.c:598 journal_flush_pins_or_still_flushing fs/bcachefs/journal_reclaim.c:865 [inline] journal_flush_done+0x112/0x810 fs/bcachefs/journal_reclaim.c:883 bch2_journal_flush_pins+0xdc/0x250 fs/bcachefs/journal_reclaim.c:915 bch2_journal_flush_all_pins fs/bcachefs/journal_reclaim.h:76 [inline] bch2_journal_replay+0x2323/0x2620 fs/bcachefs/recovery.c:465 bch2_run_recovery_pass fs/bcachefs/recovery_passes.c:485 [inline] __bch2_run_recovery_passes+0x392/0x1010 fs/bcachefs/recovery_passes.c:540 bch2_run_recovery_passes+0x184/0x210 fs/bcachefs/recovery_passes.c:611 bch2_fs_recovery+0x25fd/0x3950 fs/bcachefs/recovery.c:989 bch2_fs_start+0xa99/0xd90 fs/bcachefs/super.c:1203 Memory state around the buggy address: ffff888054e09b00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888054e09b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff888054e09c00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888054e09c80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888054e09d00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ==================================================================