loop0: detected capacity change from 0 to 32768 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) features: lz4,new_siphash,inline_data,new_extent_overwrite,btree_ptr_v2,new_varint,journal_no_flush,alloc_v2,extents_across_btree_nodes bcachefs (loop0): Using encoding defined by superblock: utf8-12.1.0 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): loop0: Superblock write was silently dropped! (seq 0 expected 42) bcachefs (loop0): done starting filesystem bcachefs (loop0 inum 4098 offset 4096): data write error: I/O ================================================================== BUG: KASAN: slab-use-after-free in __bch2_write+0x38f8/0x3900 fs/bcachefs/io_write.c:1506 Read of size 2 at addr ffff888052afb97c by task syz.0.0/5323 CPU: 0 UID: 0 PID: 5323 Comm: syz.0.0 Not tainted 6.16.0-rc3-syzkaller-00042-g78f4e737a53e #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_write+0x38f8/0x3900 fs/bcachefs/io_write.c:1506 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:486 [inline] bch2_writepages+0x211/0x2d0 fs/bcachefs/fs-io-buffered.c:668 do_writepages+0x32e/0x550 mm/page-writeback.c:2636 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:245 generic_write_sync include/linux/fs.h:3031 [inline] bch2_write_iter+0x2822/0x2b90 fs/bcachefs/fs-io-buffered.c:1089 iter_file_splice_write+0x93a/0x1000 fs/splice.c:738 do_splice_from fs/splice.c:935 [inline] direct_splice_actor+0x101/0x160 fs/splice.c:1158 splice_direct_to_actor+0x5a5/0xcc0 fs/splice.c:1102 do_splice_direct_actor fs/splice.c:1201 [inline] do_splice_direct+0x181/0x270 fs/splice.c:1227 do_sendfile+0x4da/0x7e0 fs/read_write.c:1370 __do_sys_sendfile64 fs/read_write.c:1431 [inline] __se_sys_sendfile64+0x13e/0x190 fs/read_write.c:1417 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:0x7f26ba58e929 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:00007f26bb394038 EFLAGS: 00000246 ORIG_RAX: 0000000000000028 RAX: ffffffffffffffda RBX: 00007f26ba7b5fa0 RCX: 00007f26ba58e929 RDX: 0000000000000000 RSI: 0000000000000006 RDI: 0000000000000005 RBP: 00007f26ba610b39 R08: 0000000000000000 R09: 0000000000000000 R10: 000000000000f800 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f26ba7b5fa0 R15: 00007ffd5296e1e8 Allocated by task 5323: 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:4148 [inline] slab_alloc_node mm/slub.c:4197 [inline] kmem_cache_alloc_noprof+0x1c1/0x3c0 mm/slub.c:4204 mempool_alloc_noprof+0x1a7/0x510 mm/mempool.c:402 bio_alloc_bioset+0x241/0x1110 block/bio.c:555 bch2_writepage_io_alloc fs/bcachefs/fs-io-buffered.c:502 [inline] __bch2_writepage+0x1581/0x2790 fs/bcachefs/fs-io-buffered.c:636 write_cache_pages+0x61/0x100 mm/page-writeback.c:2614 bch2_writepages+0xf9/0x2d0 fs/bcachefs/fs-io-buffered.c:666 do_writepages+0x32e/0x550 mm/page-writeback.c:2636 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:245 generic_write_sync include/linux/fs.h:3031 [inline] bch2_write_iter+0x2822/0x2b90 fs/bcachefs/fs-io-buffered.c:1089 iter_file_splice_write+0x93a/0x1000 fs/splice.c:738 do_splice_from fs/splice.c:935 [inline] direct_splice_actor+0x101/0x160 fs/splice.c:1158 splice_direct_to_actor+0x5a5/0xcc0 fs/splice.c:1102 do_splice_direct_actor fs/splice.c:1201 [inline] do_splice_direct+0x181/0x270 fs/splice.c:1227 do_sendfile+0x4da/0x7e0 fs/read_write.c:1370 __do_sys_sendfile64 fs/read_write.c:1431 [inline] __se_sys_sendfile64+0x13e/0x190 fs/read_write.c:1417 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 15: 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_after_rcu_debug+0x129/0x2a0 mm/slub.c:4693 rcu_do_batch kernel/rcu/tree.c:2576 [inline] rcu_core+0xca8/0x1710 kernel/rcu/tree.c:2832 handle_softirqs+0x286/0x870 kernel/softirq.c:579 run_ksoftirqd+0x9b/0x100 kernel/softirq.c:968 smpboot_thread_fn+0x53f/0xa60 kernel/smpboot.c:164 kthread+0x70e/0x8a0 kernel/kthread.c:464 ret_from_fork+0x3fc/0x770 arch/x86/kernel/process.c:148 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 Last potentially related work creation: kasan_save_stack+0x3e/0x60 mm/kasan/common.c:47 kasan_record_aux_stack+0xbd/0xd0 mm/kasan/generic.c:548 slab_free_hook mm/slub.c:2342 [inline] slab_free mm/slub.c:4643 [inline] kmem_cache_free+0x2f6/0x400 mm/slub.c:4745 process_one_work kernel/workqueue.c:3238 [inline] process_scheduled_works+0xae1/0x17b0 kernel/workqueue.c:3321 worker_thread+0x8a0/0xda0 kernel/workqueue.c:3402 kthread+0x70e/0x8a0 kernel/kthread.c:464 ret_from_fork+0x3fc/0x770 arch/x86/kernel/process.c:148 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+0xbd/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+0x3ab2/0x3e90 fs/bcachefs/io_write.c:1462 __bch2_write+0x371c/0x3900 fs/bcachefs/io_write.c:1505 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:486 [inline] bch2_writepages+0x211/0x2d0 fs/bcachefs/fs-io-buffered.c:668 do_writepages+0x32e/0x550 mm/page-writeback.c:2636 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:245 generic_write_sync include/linux/fs.h:3031 [inline] bch2_write_iter+0x2822/0x2b90 fs/bcachefs/fs-io-buffered.c:1089 iter_file_splice_write+0x93a/0x1000 fs/splice.c:738 do_splice_from fs/splice.c:935 [inline] direct_splice_actor+0x101/0x160 fs/splice.c:1158 splice_direct_to_actor+0x5a5/0xcc0 fs/splice.c:1102 do_splice_direct_actor fs/splice.c:1201 [inline] do_splice_direct+0x181/0x270 fs/splice.c:1227 do_sendfile+0x4da/0x7e0 fs/read_write.c:1370 __do_sys_sendfile64 fs/read_write.c:1431 [inline] __se_sys_sendfile64+0x13e/0x190 fs/read_write.c:1417 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 ffff888052afb900 which belongs to the cache bio-1072 of size 1072 The buggy address is located 124 bytes inside of freed 1072-byte region [ffff888052afb900, ffff888052afbd30) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x52af8 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 ffff888043383640 dead000000000122 0000000000000000 raw: 0000000000000000 00000000800d000d 00000000f5000000 0000000000000000 head: 04fff00000000040 ffff888043383640 dead000000000122 0000000000000000 head: 0000000000000000 00000000800d000d 00000000f5000000 0000000000000000 head: 04fff00000000002 ffffea00014abe01 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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5323, tgid 5322 (syz.0.0), ts 69616800451, free_ts 69616779937 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] kmem_cache_alloc_noprof+0x283/0x3c0 mm/slub.c:4204 mempool_init_node+0x1e5/0x4d0 mm/mempool.c:217 mempool_init_noprof+0x3a/0x50 mm/mempool.c:246 bioset_init+0x2eb/0x790 block/bio.c:1803 bch2_fs_fs_io_buffered_init+0x2b/0x50 fs/bcachefs/fs-io-buffered.c:1101 bch2_fs_init_rw fs/bcachefs/super.c:816 [inline] __bch2_fs_read_write+0x6cf/0x830 fs/bcachefs/super.c:489 bch2_fs_read_write_early+0x26/0x40 fs/bcachefs/super.c:576 bch2_fs_initialize+0xae2/0x1550 fs/bcachefs/recovery.c:1188 bch2_fs_start+0xa88/0xd90 fs/bcachefs/super.c:1204 bch2_fs_get_tree+0xb02/0x14f0 fs/bcachefs/fs.c:2489 page last free pid 5323 tgid 5322 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1248 [inline] __free_frozen_pages+0xc71/0xe70 mm/page_alloc.c:2706 stack_depot_save_flags+0x445/0x900 lib/stackdepot.c:678 kasan_save_stack mm/kasan/common.c:48 [inline] kasan_save_track+0x4f/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_noprof+0x276/0x4e0 mm/slub.c:4334 kmalloc_array_node_noprof include/linux/slab.h:1020 [inline] mempool_init_node+0x124/0x4d0 mm/mempool.c:206 mempool_init_noprof+0x3a/0x50 mm/mempool.c:246 bioset_init+0x2eb/0x790 block/bio.c:1803 bch2_fs_fs_io_buffered_init+0x2b/0x50 fs/bcachefs/fs-io-buffered.c:1101 bch2_fs_init_rw fs/bcachefs/super.c:816 [inline] __bch2_fs_read_write+0x6cf/0x830 fs/bcachefs/super.c:489 bch2_fs_read_write_early+0x26/0x40 fs/bcachefs/super.c:576 bch2_fs_initialize+0xae2/0x1550 fs/bcachefs/recovery.c:1188 bch2_fs_start+0xa88/0xd90 fs/bcachefs/super.c:1204 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:3885 Memory state around the buggy address: ffff888052afb800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc ffff888052afb880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff888052afb900: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888052afb980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888052afba00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================