loop0: detected capacity change from 0 to 32768 bcachefs (loop0): starting version 1.7: mi_btree_bitmap opts=errors=continue,compression=lz4,degraded,nojournal_transaction_names,nocow bcachefs (loop0): recovering from clean shutdown, journal seq 7 bcachefs (loop0): Doing compatible version upgrade from 1.7: mi_btree_bitmap to 1.12: rebalance_work_acct_fix running recovery passes: check_allocations invalid bkey u64s 11 type alloc_v4 0:14:0 len 0 ver 0: gen 0 oldest_gen 0 data_type journal journal_seq 1 need_discard 1 need_inc_gen 1 dirty_sectors 256 stripe_sectors 0 cached_sectors 0 stripe 67108864 stripe_redundancy 0 io_time[READ] 1 io_time[WRITE] 1 fragmentation 0 bp_start 8 invalid data type (got 2 should be 7): delete?, fixing bcachefs (loop0): accounting_read... done bcachefs (loop0): alloc_read... done bcachefs (loop0): stripes_read... done bcachefs (loop0): snapshots_read... done bcachefs (loop0): check_allocations... btree ptr not marked in member info btree allocated bitmap u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq 75277f57b0c8c24 written 32 min_key POS_MIN durability: 1 ptr: 0:26:0 gen 0, fixing btree ptr not marked in member info btree allocated bitmap u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq 19bc58a6c09b6540 written 24 min_key POS_MIN durability: 1 ptr: 0:38:0 gen 0, fixing btree ptr not marked in member info btree allocated bitmap u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq c18f4a4face03c6 written 24 min_key POS_MIN durability: 1 ptr: 0:41:0 gen 0, fixing btree ptr not marked in member info btree allocated bitmap u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq 7675f41d391e5d36 written 16 min_key POS_MIN durability: 1 ptr: 0:35:0 gen 0, fixing btree ptr not marked in member info btree allocated bitmap u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq bcb9905dfb2993d5 written 16 min_key POS_MIN durability: 1 ptr: 0:32:0 gen 0, fixing btree ptr not marked in member info btree allocated bitmap u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq 9a831b4a3f983356 written 32 min_key POS_MIN durability: 1 ptr: 0:29:0 gen 0, fixing bucket 0:14 gen 0 has wrong data_type: got free, should be journal, fixing bucket 0:14 gen 0 data type journal has wrong dirty_sectors: got 0, should be 256, fixing done bcachefs (loop0): going read-write bcachefs (loop0): journal_replay... done bcachefs (loop0): resume_logged_ops... done bcachefs (loop0): delete_dead_inodes... done bcachefs (loop0): Fixed errors, running fsck a second time to verify fs is clean bcachefs (loop0): resume_logged_ops... done bcachefs (loop0): delete_dead_inodes... done bcachefs (loop0): done starting filesystem ================================================================== BUG: KASAN: slab-use-after-free in bch2_dio_write_done fs/bcachefs/fs-io-direct.c:390 [inline] BUG: KASAN: slab-use-after-free in bch2_dio_write_loop fs/bcachefs/fs-io-direct.c:544 [inline] BUG: KASAN: slab-use-after-free in bch2_direct_write+0x2a70/0x3160 fs/bcachefs/fs-io-direct.c:654 Read of size 8 at addr ffff88804d5c10a0 by task syz.0.0/5105 CPU: 0 UID: 0 PID: 5105 Comm: syz.0.0 Not tainted 6.11.0-syzkaller-08829-gaf9c191ac2a0 #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:94 [inline] dump_stack_lvl+0x241/0x360 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 bch2_dio_write_done fs/bcachefs/fs-io-direct.c:390 [inline] bch2_dio_write_loop fs/bcachefs/fs-io-direct.c:544 [inline] bch2_direct_write+0x2a70/0x3160 fs/bcachefs/fs-io-direct.c:654 bch2_write_iter+0x194/0x2480 fs/bcachefs/fs-io-buffered.c:1041 do_iter_readv_writev+0x600/0x880 vfs_writev+0x376/0xba0 fs/read_write.c:1064 do_writev+0x1b1/0x350 fs/read_write.c:1111 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:0x7f2bf397def9 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:00007f2bf4786038 EFLAGS: 00000246 ORIG_RAX: 0000000000000014 RAX: ffffffffffffffda RBX: 00007f2bf3b35f80 RCX: 00007f2bf397def9 RDX: 0000000000000001 RSI: 0000000020000140 RDI: 0000000000000004 RBP: 00007f2bf4786090 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001 R13: 0000000000000000 R14: 00007f2bf3b35f80 R15: 00007fffe9671508 Allocated by task 5105: 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_mempool_unpoison_object+0x9e/0x160 mm/kasan/common.c:547 remove_element+0x129/0x1a0 mm/mempool.c:150 mempool_alloc_noprof+0x54e/0x5a0 mm/mempool.c:408 bio_alloc_bioset+0x26f/0x1130 block/bio.c:554 bch2_direct_write+0x5a3/0x3160 fs/bcachefs/fs-io-direct.c:626 bch2_write_iter+0x194/0x2480 fs/bcachefs/fs-io-buffered.c:1041 do_iter_readv_writev+0x600/0x880 vfs_writev+0x376/0xba0 fs/read_write.c:1064 do_writev+0x1b1/0x350 fs/read_write.c:1111 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 5105: 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_mempool_poison_object+0xaa/0x120 mm/kasan/common.c:522 kasan_mempool_poison_object include/linux/kasan.h:357 [inline] kasan_poison_element mm/mempool.c:118 [inline] add_element mm/mempool.c:141 [inline] mempool_free+0x1c8/0x390 mm/mempool.c:541 bch2_dio_write_done fs/bcachefs/fs-io-direct.c:388 [inline] bch2_dio_write_loop fs/bcachefs/fs-io-direct.c:544 [inline] bch2_direct_write+0x2a59/0x3160 fs/bcachefs/fs-io-direct.c:654 bch2_write_iter+0x194/0x2480 fs/bcachefs/fs-io-buffered.c:1041 do_iter_readv_writev+0x600/0x880 vfs_writev+0x376/0xba0 fs/read_write.c:1064 do_writev+0x1b1/0x350 fs/read_write.c:1111 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 ffff88804d5c0fc0 which belongs to the cache bio-119 of size 1192 The buggy address is located 224 bytes inside of freed 1192-byte region [ffff88804d5c0fc0, ffff88804d5c1468) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x4d5c0 head: order:2 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0x4fff00000000040(head|node=1|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 04fff00000000040 ffff88804e05a000 dead000000000122 0000000000000000 raw: 0000000000000000 00000000800c000c 00000001f5000000 0000000000000000 head: 04fff00000000040 ffff88804e05a000 dead000000000122 0000000000000000 head: 0000000000000000 00000000800c000c 00000001f5000000 0000000000000000 head: 04fff00000000002 ffffea0001357001 ffffffffffffffff 0000000000000000 head: 0000000000000004 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5105, tgid 5104 (syz.0.0), ts 77838198089, free_ts 0 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+0x3e8/0x680 mm/mempolicy.c:2265 alloc_slab_page+0x6a/0x120 mm/slub.c:2413 allocate_slab+0x5a/0x2f0 mm/slub.c:2579 new_slab mm/slub.c:2632 [inline] ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3819 __slab_alloc+0x58/0xa0 mm/slub.c:3909 __slab_alloc_node mm/slub.c:3962 [inline] slab_alloc_node mm/slub.c:4123 [inline] kmem_cache_alloc_noprof+0x1c1/0x2a0 mm/slub.c:4142 mempool_init_node+0x1ee/0x4e0 mm/mempool.c:217 mempool_init_noprof+0x3a/0x50 mm/mempool.c:246 bioset_init+0x2e8/0x820 block/bio.c:1857 bch2_fs_fs_io_direct_init+0x67/0x90 fs/bcachefs/fs-io-direct.c:681 bch2_fs_alloc+0x1eab/0x20b0 fs/bcachefs/super.c:931 bch2_fs_open+0x8cc/0xdf0 fs/bcachefs/super.c:2115 bch2_fs_get_tree+0x731/0x1700 fs/bcachefs/fs.c:1943 page_owner free stack trace missing Memory state around the buggy address: ffff88804d5c0f80: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb ffff88804d5c1000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88804d5c1080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88804d5c1100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88804d5c1180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================