================================================================== BUG: KASAN: slab-use-after-free in __bch2_write+0x4868/0x486c fs/bcachefs/io_write.c:1410 Read of size 2 at addr ffff0000dcb0183c by task syz.0.392/8621 CPU: 1 UID: 0 PID: 8621 Comm: syz.0.392 Not tainted 6.13.0-rc2-syzkaller-gfac04efc5c79 #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:378 [inline] print_report+0x198/0x538 mm/kasan/report.c:489 kasan_report+0xd8/0x138 mm/kasan/report.c:602 __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+0x22c/0x310 fs/bcachefs/fs-io-buffered.c:641 do_writepages+0x304/0x7d0 mm/page-writeback.c:2702 filemap_fdatawrite_wbc mm/filemap.c:397 [inline] __filemap_fdatawrite_range mm/filemap.c:430 [inline] file_write_and_wait_range+0x21c/0x330 mm/filemap.c:787 bch2_fsync+0x14c/0x44c fs/bcachefs/fs-io.c:199 vfs_fsync_range+0x160/0x19c fs/sync.c:187 generic_write_sync include/linux/fs.h:2904 [inline] bch2_write_iter+0x2024/0x2304 fs/bcachefs/fs-io-buffered.c:1061 iter_file_splice_write+0x898/0xfdc fs/splice.c:743 do_splice_from fs/splice.c:941 [inline] direct_splice_actor+0xec/0x1d8 fs/splice.c:1164 splice_direct_to_actor+0x438/0xa0c fs/splice.c:1108 do_splice_direct_actor fs/splice.c:1207 [inline] do_splice_direct+0x1e4/0x304 fs/splice.c:1233 do_sendfile+0x470/0x768 fs/read_write.c:1363 __do_sys_sendfile64 fs/read_write.c:1424 [inline] __se_sys_sendfile64 fs/read_write.c:1410 [inline] __arm64_sys_sendfile64+0x148/0x3a4 fs/read_write.c:1410 __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 8621: 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:568 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:250 [inline] slab_post_alloc_hook mm/slub.c:4104 [inline] slab_alloc_node mm/slub.c:4153 [inline] kmem_cache_alloc_noprof+0x254/0x410 mm/slub.c:4160 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+0xcfc/0x1c80 fs/bcachefs/fs-io-buffered.c:599 write_cache_pages+0xc8/0x20c mm/page-writeback.c:2659 bch2_writepages+0x144/0x310 fs/bcachefs/fs-io-buffered.c:639 do_writepages+0x304/0x7d0 mm/page-writeback.c:2702 filemap_fdatawrite_wbc mm/filemap.c:397 [inline] __filemap_fdatawrite_range mm/filemap.c:430 [inline] file_write_and_wait_range+0x21c/0x330 mm/filemap.c:787 bch2_fsync+0x14c/0x44c fs/bcachefs/fs-io.c:199 vfs_fsync_range+0x160/0x19c fs/sync.c:187 generic_write_sync include/linux/fs.h:2904 [inline] bch2_write_iter+0x2024/0x2304 fs/bcachefs/fs-io-buffered.c:1061 iter_file_splice_write+0x898/0xfdc fs/splice.c:743 do_splice_from fs/splice.c:941 [inline] direct_splice_actor+0xec/0x1d8 fs/splice.c:1164 splice_direct_to_actor+0x438/0xa0c fs/splice.c:1108 do_splice_direct_actor fs/splice.c:1207 [inline] do_splice_direct+0x1e4/0x304 fs/splice.c:1233 do_sendfile+0x470/0x768 fs/read_write.c:1363 __do_sys_sendfile64 fs/read_write.c:1424 [inline] __se_sys_sendfile64 fs/read_write.c:1410 [inline] __arm64_sys_sendfile64+0x148/0x3a4 fs/read_write.c:1410 __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 8616: 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:582 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:233 [inline] slab_free_hook mm/slub.c:2338 [inline] slab_free_after_rcu_debug+0x11c/0x2f8 mm/slub.c:4648 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+0x320/0xd34 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+0xb8/0xd0 mm/kasan/generic.c:544 kasan_record_aux_stack_noalloc+0x14/0x20 mm/kasan/generic.c:554 slab_free_hook mm/slub.c:2299 [inline] slab_free mm/slub.c:4598 [inline] kmem_cache_free+0x368/0x554 mm/slub.c:4700 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+0x7a8/0x15cc 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+0xb8/0xd0 mm/kasan/generic.c:544 kasan_record_aux_stack_noalloc+0x14/0x20 mm/kasan/generic.c:554 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+0x22c/0x310 fs/bcachefs/fs-io-buffered.c:641 do_writepages+0x304/0x7d0 mm/page-writeback.c:2702 filemap_fdatawrite_wbc mm/filemap.c:397 [inline] __filemap_fdatawrite_range mm/filemap.c:430 [inline] file_write_and_wait_range+0x21c/0x330 mm/filemap.c:787 bch2_fsync+0x14c/0x44c fs/bcachefs/fs-io.c:199 vfs_fsync_range+0x160/0x19c fs/sync.c:187 generic_write_sync include/linux/fs.h:2904 [inline] bch2_write_iter+0x2024/0x2304 fs/bcachefs/fs-io-buffered.c:1061 iter_file_splice_write+0x898/0xfdc fs/splice.c:743 do_splice_from fs/splice.c:941 [inline] direct_splice_actor+0xec/0x1d8 fs/splice.c:1164 splice_direct_to_actor+0x438/0xa0c fs/splice.c:1108 do_splice_direct_actor fs/splice.c:1207 [inline] do_splice_direct+0x1e4/0x304 fs/splice.c:1233 do_sendfile+0x470/0x768 fs/read_write.c:1363 __do_sys_sendfile64 fs/read_write.c:1424 [inline] __se_sys_sendfile64 fs/read_write.c:1410 [inline] __arm64_sys_sendfile64+0x148/0x3a4 fs/read_write.c:1410 __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 ffff0000dcb017c0 which belongs to the cache bio-106 of size 1064 The buggy address is located 124 bytes inside of freed 1064-byte region [ffff0000dcb017c0, ffff0000dcb01be8) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11cb00 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 ffff0000daffa640 dead000000000122 0000000000000000 raw: 0000000000000000 00000000800d000d 00000001f5000000 0000000000000000 head: 05ffc00000000040 ffff0000daffa640 dead000000000122 0000000000000000 head: 0000000000000000 00000000800d000d 00000001f5000000 0000000000000000 head: 05ffc00000000002 fffffdffc372c001 ffffffffffffffff 0000000000000000 head: ffff000000000004 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff0000dcb01700: fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc ffff0000dcb01780: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb >ffff0000dcb01800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff0000dcb01880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff0000dcb01900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================