loop0: detected capacity change from 0 to 32768 bcachefs (da441363-bb6a-4ab9-999b-c1f40db4fee2): Using encoding defined by superblock: utf8-12.1.0 bcachefs (loop0): starting version 1.7: mi_btree_bitmap opts=errors=continue,metadata_checksum=none,data_checksum=none,compression=lz4,nocow allowing incompatible features above 0.0: (unknown version) bcachefs (loop0): initializing new filesystem bcachefs (loop0): going read-write bcachefs (loop0): marking superblocks bcachefs (loop0): initializing freespace bcachefs (loop0): done initializing freespace bcachefs (loop0): reading snapshots table bcachefs (loop0): reading snapshots done bcachefs (loop0): done starting filesystem bcachefs (loop0 inum 4098 offset 0): data write error: I/O ================================================================== BUG: KASAN: slab-use-after-free in __bch2_write+0x39a3/0x39b0 fs/bcachefs/io_write.c:1488 Read of size 2 at addr ffff88805604b97c by task syz.0.0/5314 CPU: 0 UID: 0 PID: 5314 Comm: syz.0.0 Not tainted 6.15.0-rc6-syzkaller-00346-g5723cc3450bc #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+0xb4/0x290 mm/kasan/report.c:521 kasan_report+0x118/0x150 mm/kasan/report.c:634 __bch2_write+0x39a3/0x39b0 fs/bcachefs/io_write.c:1488 closure_queue include/linux/closure.h:270 [inline] closure_call include/linux/closure.h:432 [inline] bch2_writepage_do_io fs/bcachefs/fs-io-buffered.c:494 [inline] bch2_writepages+0x269/0x360 fs/bcachefs/fs-io-buffered.c:677 do_writepages+0x3b1/0x7b0 mm/page-writeback.c:2656 filemap_fdatawrite_wbc mm/filemap.c:386 [inline] __filemap_fdatawrite_range mm/filemap.c:419 [inline] file_write_and_wait_range+0x22c/0x330 mm/filemap.c:794 bch2_fsync+0x127/0x330 fs/bcachefs/fs-io.c:243 generic_write_sync include/linux/fs.h:2976 [inline] bch2_write_iter+0x2822/0x2b90 fs/bcachefs/fs-io-buffered.c:1097 do_iter_readv_writev+0x56e/0x7f0 fs/read_write.c:-1 vfs_writev+0x306/0x9a0 fs/read_write.c:1055 do_pwritev fs/read_write.c:1151 [inline] __do_sys_pwritev2 fs/read_write.c:1209 [inline] __se_sys_pwritev2+0x179/0x290 fs/read_write.c:1200 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f9cbef8e969 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:00007f9cbfea0038 EFLAGS: 00000246 ORIG_RAX: 0000000000000148 RAX: ffffffffffffffda RBX: 00007f9cbf1b5fa0 RCX: 00007f9cbef8e969 RDX: 0000000000000001 RSI: 0000200000000040 RDI: 0000000000000004 RBP: 00007f9cbf010ab1 R08: 000000000000000e R09: 0000000000000000 R10: 00000000000003ff R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f9cbf1b5fa0 R15: 00007ffde6c5f0b8 Allocated by task 5314: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3e/0x80 mm/kasan/common.c:68 unpoison_slab_object mm/kasan/common.c:319 [inline] __kasan_slab_alloc+0x6c/0x80 mm/kasan/common.c:345 kasan_slab_alloc include/linux/kasan.h:250 [inline] slab_post_alloc_hook mm/slub.c:4147 [inline] slab_alloc_node mm/slub.c:4196 [inline] kmem_cache_alloc_noprof+0x1c1/0x3c0 mm/slub.c:4203 mempool_alloc_noprof+0x1a7/0x510 mm/mempool.c:402 bio_alloc_bioset+0x241/0x1110 block/bio.c:554 bch2_writepage_io_alloc fs/bcachefs/fs-io-buffered.c:510 [inline] __bch2_writepage+0x1581/0x2790 fs/bcachefs/fs-io-buffered.c:644 write_cache_pages+0x61/0x100 mm/page-writeback.c:2613 bch2_writepages+0x154/0x360 fs/bcachefs/fs-io-buffered.c:675 do_writepages+0x3b1/0x7b0 mm/page-writeback.c:2656 filemap_fdatawrite_wbc mm/filemap.c:386 [inline] __filemap_fdatawrite_range mm/filemap.c:419 [inline] file_write_and_wait_range+0x22c/0x330 mm/filemap.c:794 bch2_fsync+0x127/0x330 fs/bcachefs/fs-io.c:243 generic_write_sync include/linux/fs.h:2976 [inline] bch2_write_iter+0x2822/0x2b90 fs/bcachefs/fs-io-buffered.c:1097 do_iter_readv_writev+0x56e/0x7f0 fs/read_write.c:-1 vfs_writev+0x306/0x9a0 fs/read_write.c:1055 do_pwritev fs/read_write.c:1151 [inline] __do_sys_pwritev2 fs/read_write.c:1209 [inline] __se_sys_pwritev2+0x179/0x290 fs/read_write.c:1200 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 5326: 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:2380 [inline] slab_free_after_rcu_debug+0x127/0x290 mm/slub.c:4692 rcu_do_batch kernel/rcu/tree.c:2568 [inline] rcu_core+0xca8/0x1710 kernel/rcu/tree.c:2824 handle_softirqs+0x286/0x870 kernel/softirq.c:579 __do_softirq kernel/softirq.c:613 [inline] invoke_softirq kernel/softirq.c:453 [inline] __irq_exit_rcu+0xca/0x1f0 kernel/softirq.c:680 irq_exit_rcu+0x9/0x30 kernel/softirq.c:696 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1049 [inline] sysvec_apic_timer_interrupt+0xa6/0xc0 arch/x86/kernel/apic/apic.c:1049 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:702 Last potentially related work creation: kasan_save_stack+0x3e/0x60 mm/kasan/common.c:47 kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:548 slab_free_hook mm/slub.c:2341 [inline] slab_free mm/slub.c:4642 [inline] kmem_cache_free+0x2ee/0x3f0 mm/slub.c:4744 process_one_work kernel/workqueue.c:3238 [inline] process_scheduled_works+0xadb/0x17a0 kernel/workqueue.c:3319 worker_thread+0x8a0/0xda0 kernel/workqueue.c:3400 kthread+0x70e/0x8a0 kernel/kthread.c:464 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:153 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 Second to last potentially related work creation: kasan_save_stack+0x3e/0x60 mm/kasan/common.c:47 kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:548 insert_work+0x3d/0x330 kernel/workqueue.c:2183 __queue_work+0xcfc/0xfe0 kernel/workqueue.c:2341 queue_work_on+0x181/0x270 kernel/workqueue.c:2392 queue_work include/linux/workqueue.h:662 [inline] closure_queue include/linux/closure.h:268 [inline] closure_put_after_sub+0x2ac/0x320 lib/closure.c:42 bch2_nocow_write+0x3b2f/0x3ef0 fs/bcachefs/io_write.c:1445 __bch2_write+0x37ca/0x39b0 fs/bcachefs/io_write.c:1487 closure_queue include/linux/closure.h:270 [inline] closure_call include/linux/closure.h:432 [inline] bch2_writepage_do_io fs/bcachefs/fs-io-buffered.c:494 [inline] bch2_writepages+0x269/0x360 fs/bcachefs/fs-io-buffered.c:677 do_writepages+0x3b1/0x7b0 mm/page-writeback.c:2656 filemap_fdatawrite_wbc mm/filemap.c:386 [inline] __filemap_fdatawrite_range mm/filemap.c:419 [inline] file_write_and_wait_range+0x22c/0x330 mm/filemap.c:794 bch2_fsync+0x127/0x330 fs/bcachefs/fs-io.c:243 generic_write_sync include/linux/fs.h:2976 [inline] bch2_write_iter+0x2822/0x2b90 fs/bcachefs/fs-io-buffered.c:1097 do_iter_readv_writev+0x56e/0x7f0 fs/read_write.c:-1 vfs_writev+0x306/0x9a0 fs/read_write.c:1055 do_pwritev fs/read_write.c:1151 [inline] __do_sys_pwritev2 fs/read_write.c:1209 [inline] __se_sys_pwritev2+0x179/0x290 fs/read_write.c:1200 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f The buggy address belongs to the object at ffff88805604b900 which belongs to the cache bio-1072 of size 1072 The buggy address is located 124 bytes inside of freed 1072-byte region [ffff88805604b900, ffff88805604bd30) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x56048 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 ffff88803faf0dc0 dead000000000122 0000000000000000 raw: 0000000000000000 00000000800d000d 00000000f5000000 0000000000000000 head: 04fff00000000040 ffff88803faf0dc0 dead000000000122 0000000000000000 head: 0000000000000000 00000000800d000d 00000000f5000000 0000000000000000 head: 04fff00000000002 ffffea0001581201 00000000ffffffff 00000000ffffffff head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000004 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd2880(GFP_NOWAIT|__GFP_FS|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5314, tgid 5313 (syz.0.0), ts 68583369433, free_ts 68572673571 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1d8/0x230 mm/page_alloc.c:1714 prep_new_page mm/page_alloc.c:1722 [inline] get_page_from_freelist+0x21ce/0x22b0 mm/page_alloc.c:3684 __alloc_frozen_pages_noprof+0x181/0x370 mm/page_alloc.c:4966 alloc_pages_mpol+0x232/0x4a0 mm/mempolicy.c:2301 alloc_slab_page mm/slub.c:2450 [inline] allocate_slab+0x8a/0x3b0 mm/slub.c:2618 new_slab mm/slub.c:2672 [inline] ___slab_alloc+0xbfc/0x1480 mm/slub.c:3858 __slab_alloc mm/slub.c:3948 [inline] __slab_alloc_node mm/slub.c:4023 [inline] slab_alloc_node mm/slub.c:4184 [inline] kmem_cache_alloc_noprof+0x283/0x3c0 mm/slub.c:4203 mempool_alloc_noprof+0x1a7/0x510 mm/mempool.c:402 bio_alloc_bioset+0x241/0x1110 block/bio.c:554 bch2_writepage_io_alloc fs/bcachefs/fs-io-buffered.c:510 [inline] __bch2_writepage+0x1581/0x2790 fs/bcachefs/fs-io-buffered.c:644 write_cache_pages+0x61/0x100 mm/page-writeback.c:2613 bch2_writepages+0x154/0x360 fs/bcachefs/fs-io-buffered.c:675 do_writepages+0x3b1/0x7b0 mm/page-writeback.c:2656 filemap_fdatawrite_wbc mm/filemap.c:386 [inline] __filemap_fdatawrite_range mm/filemap.c:419 [inline] file_write_and_wait_range+0x22c/0x330 mm/filemap.c:794 bch2_fsync+0x127/0x330 fs/bcachefs/fs-io.c:243 generic_write_sync include/linux/fs.h:2976 [inline] bch2_write_iter+0x2822/0x2b90 fs/bcachefs/fs-io-buffered.c:1097 page last free pid 49 tgid 49 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1258 [inline] __free_frozen_pages+0xb0e/0xcd0 mm/page_alloc.c:2721 __folio_put+0x21b/0x2c0 mm/swap.c:112 folio_put include/linux/mm.h:1580 [inline] free_large_kmalloc+0x145/0x200 mm/slub.c:4767 bch2_write_index_default fs/bcachefs/io_write.c:418 [inline] __bch2_write_index+0x10cb/0x19e0 fs/bcachefs/io_write.c:591 bch2_write_point_do_index_updates+0x43f/0x570 fs/bcachefs/io_write.c:703 process_one_work kernel/workqueue.c:3238 [inline] process_scheduled_works+0xadb/0x17a0 kernel/workqueue.c:3319 worker_thread+0x8a0/0xda0 kernel/workqueue.c:3400 kthread+0x70e/0x8a0 kernel/kthread.c:464 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:153 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 Memory state around the buggy address: ffff88805604b800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc ffff88805604b880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88805604b900: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88805604b980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88805604ba00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================