bcachefs (loop3): done starting filesystem ================================================================== BUG: KASAN: slab-use-after-free in __bch2_write+0x4868/0x486c fs/bcachefs/io_write.c:1410 Read of size 2 at addr ffff0000f6f5183c by task syz.3.206/7669 CPU: 1 UID: 0 PID: 7669 Comm: syz.3.206 Not tainted 6.12.0-syzkaller-g7b1d1d4cfac0 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 Call trace: show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:484 (C) __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0xe4/0x150 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:377 [inline] print_report+0x198/0x538 mm/kasan/report.c:488 kasan_report+0xd8/0x138 mm/kasan/report.c:601 __asan_report_load2_noabort+0x20/0x2c mm/kasan/report_generic.c:379 __bch2_write+0x4868/0x486c fs/bcachefs/io_write.c:1410 bch2_write+0x908/0x15c8 fs/bcachefs/io_write.c:1631 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:449 [inline] bch2_writepages+0x224/0x304 fs/bcachefs/fs-io-buffered.c:641 do_writepages+0x304/0x7cc mm/page-writeback.c:2683 filemap_fdatawrite_wbc+0x124/0x174 mm/filemap.c:398 __filemap_fdatawrite_range mm/filemap.c:431 [inline] file_write_and_wait_range+0x170/0x254 mm/filemap.c:788 bch2_fsync+0x14c/0x44c fs/bcachefs/fs-io.c:199 vfs_fsync_range+0x160/0x19c fs/sync.c:188 generic_write_sync include/linux/fs.h:2871 [inline] bch2_write_iter+0x24fc/0x282c fs/bcachefs/fs-io-buffered.c:1061 new_sync_write fs/read_write.c:590 [inline] vfs_write+0x920/0xcf4 fs/read_write.c:683 ksys_write+0x15c/0x26c fs/read_write.c:736 __do_sys_write fs/read_write.c:748 [inline] __se_sys_write fs/read_write.c:745 [inline] __arm64_sys_write+0x7c/0x90 fs/read_write.c:745 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:49 el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:132 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:151 el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:744 el0t_64_sync_handler+0x84/0x108 arch/arm64/kernel/entry-common.c:762 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:600 Allocated by task 7669: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x40/0x78 mm/kasan/common.c:68 kasan_save_alloc_info+0x40/0x50 mm/kasan/generic.c:565 unpoison_slab_object mm/kasan/common.c:319 [inline] __kasan_slab_alloc+0x74/0x8c mm/kasan/common.c:345 kasan_slab_alloc include/linux/kasan.h:247 [inline] slab_post_alloc_hook mm/slub.c:4085 [inline] slab_alloc_node mm/slub.c:4134 [inline] kmem_cache_alloc_noprof+0x1c0/0x354 mm/slub.c:4141 mempool_alloc_slab+0x58/0x74 mm/mempool.c:559 mempool_alloc_noprof+0x150/0x48c mm/mempool.c:402 bio_alloc_bioset+0x20c/0x1018 block/bio.c:554 bch2_writepage_io_alloc fs/bcachefs/fs-io-buffered.c:465 [inline] __bch2_writepage+0xcf8/0x1e80 fs/bcachefs/fs-io-buffered.c:599 write_cache_pages+0xc8/0x20c mm/page-writeback.c:2640 bch2_writepages+0x13c/0x304 fs/bcachefs/fs-io-buffered.c:639 do_writepages+0x304/0x7cc mm/page-writeback.c:2683 filemap_fdatawrite_wbc+0x124/0x174 mm/filemap.c:398 __filemap_fdatawrite_range mm/filemap.c:431 [inline] file_write_and_wait_range+0x170/0x254 mm/filemap.c:788 bch2_fsync+0x14c/0x44c fs/bcachefs/fs-io.c:199 vfs_fsync_range+0x160/0x19c fs/sync.c:188 generic_write_sync include/linux/fs.h:2871 [inline] bch2_write_iter+0x24fc/0x282c fs/bcachefs/fs-io-buffered.c:1061 new_sync_write fs/read_write.c:590 [inline] vfs_write+0x920/0xcf4 fs/read_write.c:683 ksys_write+0x15c/0x26c fs/read_write.c:736 __do_sys_write fs/read_write.c:748 [inline] __se_sys_write fs/read_write.c:745 [inline] __arm64_sys_write+0x7c/0x90 fs/read_write.c:745 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:49 el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:132 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:151 el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:744 el0t_64_sync_handler+0x84/0x108 arch/arm64/kernel/entry-common.c:762 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:600 Freed by task 7747: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x40/0x78 mm/kasan/common.c:68 kasan_save_free_info+0x54/0x6c mm/kasan/generic.c:579 poison_slab_object mm/kasan/common.c:247 [inline] __kasan_slab_free+0x64/0x8c mm/kasan/common.c:264 kasan_slab_free include/linux/kasan.h:230 [inline] slab_free_hook mm/slub.c:2342 [inline] slab_free_after_rcu_debug+0x120/0x308 mm/slub.c:4629 rcu_do_batch kernel/rcu/tree.c:2567 [inline] rcu_core+0x898/0x1b5c kernel/rcu/tree.c:2823 rcu_core_si+0x10/0x1c kernel/rcu/tree.c:2840 handle_softirqs+0x2e0/0xbf8 kernel/softirq.c:554 __do_softirq+0x14/0x20 kernel/softirq.c:588 Last potentially related work creation: kasan_save_stack+0x40/0x6c mm/kasan/common.c:47 __kasan_record_aux_stack+0xd0/0xec mm/kasan/generic.c:541 kasan_record_aux_stack_noalloc+0x14/0x20 mm/kasan/generic.c:551 slab_free_hook mm/slub.c:2303 [inline] slab_free mm/slub.c:4579 [inline] kmem_cache_free+0x340/0x560 mm/slub.c:4681 mempool_free_slab+0x28/0x38 mm/mempool.c:566 mempool_free+0xbc/0x2e8 mm/mempool.c:548 bio_free+0x200/0x27c block/bio.c:237 bio_put+0x1b8/0x9dc bch2_writepage_io_done+0xeb0/0x1308 fs/bcachefs/fs-io-buffered.c:441 bch2_write_done+0x2b8/0x8a8 fs/bcachefs/io_write.c:477 bch2_nocow_write_done+0x74/0xf0 fs/bcachefs/io_write.c:1207 process_one_work+0x7bc/0x1600 kernel/workqueue.c:3229 process_scheduled_works kernel/workqueue.c:3310 [inline] worker_thread+0x97c/0xeec kernel/workqueue.c:3391 kthread+0x288/0x310 kernel/kthread.c:389 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:862 Second to last potentially related work creation: kasan_save_stack+0x40/0x6c mm/kasan/common.c:47 __kasan_record_aux_stack+0xd0/0xec mm/kasan/generic.c:541 kasan_record_aux_stack_noalloc+0x14/0x20 mm/kasan/generic.c:551 insert_work+0x54/0x2d4 kernel/workqueue.c:2183 __queue_work+0xe20/0x1308 kernel/workqueue.c:2339 queue_work_on+0xe0/0x1a0 kernel/workqueue.c:2390 queue_work include/linux/workqueue.h:662 [inline] closure_queue include/linux/closure.h:268 [inline] closure_put_after_sub+0x1e0/0x304 lib/closure.c:42 closure_sub+0x4c/0x80 lib/closure.c:61 bch2_nocow_write+0x31b0/0x353c fs/bcachefs/io_write.c:1367 __bch2_write+0x469c/0x486c fs/bcachefs/io_write.c:1409 bch2_write+0x908/0x15c8 fs/bcachefs/io_write.c:1631 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:449 [inline] bch2_writepages+0x224/0x304 fs/bcachefs/fs-io-buffered.c:641 do_writepages+0x304/0x7cc mm/page-writeback.c:2683 filemap_fdatawrite_wbc+0x124/0x174 mm/filemap.c:398 __filemap_fdatawrite_range mm/filemap.c:431 [inline] file_write_and_wait_range+0x170/0x254 mm/filemap.c:788 bch2_fsync+0x14c/0x44c fs/bcachefs/fs-io.c:199 vfs_fsync_range+0x160/0x19c fs/sync.c:188 generic_write_sync include/linux/fs.h:2871 [inline] bch2_write_iter+0x24fc/0x282c fs/bcachefs/fs-io-buffered.c:1061 new_sync_write fs/read_write.c:590 [inline] vfs_write+0x920/0xcf4 fs/read_write.c:683 ksys_write+0x15c/0x26c fs/read_write.c:736 __do_sys_write fs/read_write.c:748 [inline] __se_sys_write fs/read_write.c:745 [inline] __arm64_sys_write+0x7c/0x90 fs/read_write.c:745 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:49 el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:132 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:151 el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:744 el0t_64_sync_handler+0x84/0x108 arch/arm64/kernel/entry-common.c:762 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:600 The buggy address belongs to the object at ffff0000f6f517c0 which belongs to the cache bio-106 of size 1064 The buggy address is located 124 bytes inside of freed 1064-byte region [ffff0000f6f517c0, ffff0000f6f51be8) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x136f50 head: order:2 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0x5ffc00000000040(head|node=0|zone=2|lastcpupid=0x7ff) page_type: f5(slab) raw: 05ffc00000000040 ffff0000c9bd7000 dead000000000122 0000000000000000 raw: 0000000000000000 00000000800d000d 00000001f5000000 0000000000000000 head: 05ffc00000000040 ffff0000c9bd7000 dead000000000122 0000000000000000 head: 0000000000000000 00000000800d000d 00000001f5000000 0000000000000000 head: 05ffc00000000002 fffffdffc3dbd401 ffffffffffffffff 0000000000000000 head: 0000000000000004 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff0000f6f51700: fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc ffff0000f6f51780: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb >ffff0000f6f51800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff0000f6f51880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff0000f6f51900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================