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,background_target=invalid device 79,nojournal_transaction_names
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
FAULT_INJECTION: forcing a failure.
name failslab, interval 1, probability 0, space 0, times 1
CPU: 0 UID: 0 PID: 5328 Comm: syz.0.0 Not tainted 6.14.0-syzkaller-12886-ga1b5bd45d4ee #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:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 fail_dump lib/fault-inject.c:73 [inline]
 should_fail_ex+0x424/0x570 lib/fault-inject.c:174
 should_failslab+0xac/0x100 mm/failslab.c:46
 slab_pre_alloc_hook mm/slub.c:4104 [inline]
 slab_alloc_node mm/slub.c:4180 [inline]
 __do_kmalloc_node mm/slub.c:4330 [inline]
 __kmalloc_node_track_caller_noprof+0xe2/0x4d0 mm/slub.c:4350
 __do_krealloc mm/slub.c:4908 [inline]
 krealloc_noprof+0x10f/0x300 mm/slub.c:4961
 bch2_printbuf_make_room+0x1f1/0x350 fs/bcachefs/printbuf.c:59
 printbuf_insert_spaces+0x56/0x530 fs/bcachefs/printbuf.c:81
 __printbuf_do_indent fs/bcachefs/printbuf.c:138 [inline]
 printbuf_do_indent+0x4ca/0xa10 fs/bcachefs/printbuf.c:155
 bch2_prt_printf+0x55b/0x6d0 fs/bcachefs/printbuf.c:190
 trace_bucket_alloc2+0x11b/0xb90 fs/bcachefs/alloc_foreground.c:468
 bch2_bucket_alloc_trans+0x2eaf/0x2ed0 fs/bcachefs/alloc_foreground.c:587
 bch2_bucket_alloc_set_trans+0x532/0xd00 fs/bcachefs/alloc_foreground.c:713
 __open_bucket_add_buckets+0x13fc/0x1e80 fs/bcachefs/alloc_foreground.c:956
 open_bucket_add_buckets+0x343/0x410 fs/bcachefs/alloc_foreground.c:1000
 bch2_alloc_sectors_start_trans+0xcf4/0x2050 fs/bcachefs/alloc_foreground.c:-1
 __bch2_write+0x677/0x46c0 fs/bcachefs/io_write.c:1482
 bch2_write+0x834/0x15d0 fs/bcachefs/io_write.c:1669
 closure_queue include/linux/closure.h:270 [inline]
 closure_call include/linux/closure.h:432 [inline]
 bch2_dio_write_loop fs/bcachefs/fs-io-direct.c:545 [inline]
 bch2_direct_write+0x1b0d/0x31a0 fs/bcachefs/fs-io-direct.c:668
 bch2_write_iter+0x195/0x2cd0 fs/bcachefs/fs-io-buffered.c:1057
 new_sync_write fs/read_write.c:591 [inline]
 vfs_write+0x70f/0xd10 fs/read_write.c:684
 ksys_write+0x19d/0x2d0 fs/read_write.c:736
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fd30998d169
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:00007fd30a765038 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007fd309ba5fa0 RCX: 00007fd30998d169
RDX: 000000000000f000 RSI: 0000200000000200 RDI: 0000000000000006
RBP: 00007fd30a765090 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000002
R13: 0000000000000000 R14: 00007fd309ba5fa0 R15: 00007ffe3ee11368
 </TASK>
==================================================================
BUG: KASAN: slab-out-of-bounds in memscan+0x61/0x80 lib/string.c:728
Read of size 1 at addr ffff8880408dba77 by task syz.0.0/5328

CPU: 0 UID: 0 PID: 5328 Comm: syz.0.0 Not tainted 6.14.0-syzkaller-12886-ga1b5bd45d4ee #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:
 <TASK>
 __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:408 [inline]
 print_report+0x16e/0x5b0 mm/kasan/report.c:521
 kasan_report+0x143/0x180 mm/kasan/report.c:634
 memscan+0x61/0x80 lib/string.c:728
 _Z7memscanPvU25pass_dynamic_object_size0im include/linux/fortify-string.h:708 [inline]
 __printbuf_do_indent fs/bcachefs/printbuf.c:101 [inline]
 printbuf_do_indent+0x110/0xa10 fs/bcachefs/printbuf.c:155
 bch2_prt_printf+0x55b/0x6d0 fs/bcachefs/printbuf.c:190
 trace_bucket_alloc2+0x11b/0xb90 fs/bcachefs/alloc_foreground.c:468
 bch2_bucket_alloc_trans+0x2eaf/0x2ed0 fs/bcachefs/alloc_foreground.c:587
 bch2_bucket_alloc_set_trans+0x532/0xd00 fs/bcachefs/alloc_foreground.c:713
 __open_bucket_add_buckets+0x13fc/0x1e80 fs/bcachefs/alloc_foreground.c:956
 open_bucket_add_buckets+0x343/0x410 fs/bcachefs/alloc_foreground.c:1000
 bch2_alloc_sectors_start_trans+0xcf4/0x2050 fs/bcachefs/alloc_foreground.c:-1
 __bch2_write+0x677/0x46c0 fs/bcachefs/io_write.c:1482
 bch2_write+0x834/0x15d0 fs/bcachefs/io_write.c:1669
 closure_queue include/linux/closure.h:270 [inline]
 closure_call include/linux/closure.h:432 [inline]
 bch2_dio_write_loop fs/bcachefs/fs-io-direct.c:545 [inline]
 bch2_direct_write+0x1b0d/0x31a0 fs/bcachefs/fs-io-direct.c:668
 bch2_write_iter+0x195/0x2cd0 fs/bcachefs/fs-io-buffered.c:1057
 new_sync_write fs/read_write.c:591 [inline]
 vfs_write+0x70f/0xd10 fs/read_write.c:684
 ksys_write+0x19d/0x2d0 fs/read_write.c:736
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fd30998d169
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:00007fd30a765038 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007fd309ba5fa0 RCX: 00007fd30998d169
RDX: 000000000000f000 RSI: 0000200000000200 RDI: 0000000000000006
RBP: 00007fd30a765090 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000002
R13: 0000000000000000 R14: 00007fd309ba5fa0 R15: 00007ffe3ee11368
 </TASK>

Allocated by task 5328:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:377 [inline]
 __kasan_kmalloc+0x9d/0xb0 mm/kasan/common.c:394
 kasan_kmalloc include/linux/kasan.h:260 [inline]
 __do_kmalloc_node mm/slub.c:4331 [inline]
 __kmalloc_node_track_caller_noprof+0x295/0x4d0 mm/slub.c:4350
 __do_krealloc mm/slub.c:4908 [inline]
 krealloc_noprof+0x10f/0x300 mm/slub.c:4961
 bch2_printbuf_make_room+0x1f1/0x350 fs/bcachefs/printbuf.c:59
 bch2_prt_printf+0x269/0x6d0 fs/bcachefs/printbuf.c:186
 trace_bucket_alloc2+0x11b/0xb90 fs/bcachefs/alloc_foreground.c:468
 bch2_bucket_alloc_trans+0x2eaf/0x2ed0 fs/bcachefs/alloc_foreground.c:587
 bch2_bucket_alloc_set_trans+0x532/0xd00 fs/bcachefs/alloc_foreground.c:713
 __open_bucket_add_buckets+0x13fc/0x1e80 fs/bcachefs/alloc_foreground.c:956
 open_bucket_add_buckets+0x343/0x410 fs/bcachefs/alloc_foreground.c:1000
 bch2_alloc_sectors_start_trans+0xcf4/0x2050 fs/bcachefs/alloc_foreground.c:-1
 __bch2_write+0x677/0x46c0 fs/bcachefs/io_write.c:1482
 bch2_write+0x834/0x15d0 fs/bcachefs/io_write.c:1669
 closure_queue include/linux/closure.h:270 [inline]
 closure_call include/linux/closure.h:432 [inline]
 bch2_dio_write_loop fs/bcachefs/fs-io-direct.c:545 [inline]
 bch2_direct_write+0x1b0d/0x31a0 fs/bcachefs/fs-io-direct.c:668
 bch2_write_iter+0x195/0x2cd0 fs/bcachefs/fs-io-buffered.c:1057
 new_sync_write fs/read_write.c:591 [inline]
 vfs_write+0x70f/0xd10 fs/read_write.c:684
 ksys_write+0x19d/0x2d0 fs/read_write.c:736
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff8880408dba60
 which belongs to the cache kmalloc-16 of size 16
The buggy address is located 7 bytes to the right of
 allocated 16-byte region [ffff8880408dba60, ffff8880408dba70)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x408db
flags: 0x4fff00000000000(node=1|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 04fff00000000000 ffff88801b041640 dead000000000100 dead000000000122
raw: 0000000000000000 0000000080800080 00000000f5000000 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0xd2cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5029, tgid 5029 (dhcpcd), ts 40970668694, free_ts 40968686760
 create_dummy_stack mm/page_owner.c:94 [inline]
 register_dummy_stack+0x8e/0xe0 mm/page_owner.c:100
 init_page_owner+0x3e/0x790 mm/page_owner.c:118
 invoke_init_callbacks mm/page_ext.c:148 [inline]
 page_ext_init+0x731/0x790 mm/page_ext.c:497
 mm_core_init+0x5b/0x70 mm/mm_init.c:2783
page last free pid 15 tgid 15 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1262 [inline]
 __free_frozen_pages+0xde8/0x10a0 mm/page_alloc.c:2680
 pagetable_free include/linux/mm.h:3002 [inline]
 pagetable_dtor_free include/linux/mm.h:3100 [inline]
 __tlb_remove_table+0x36b/0x460 include/asm-generic/tlb.h:215
 __tlb_remove_table_free mm/mmu_gather.c:227 [inline]
 tlb_remove_table_rcu+0x79/0xf0 mm/mmu_gather.c:290
 rcu_do_batch kernel/rcu/tree.c:2568 [inline]
 rcu_core+0xaac/0x17a0 kernel/rcu/tree.c:2824
 handle_softirqs+0x2d6/0x9b0 kernel/softirq.c:579
 run_ksoftirqd+0xcf/0x130 kernel/softirq.c:968
 smpboot_thread_fn+0x576/0xaa0 kernel/smpboot.c:164
 kthread+0x7b7/0x940 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:
 ffff8880408db900: 00 00 fc fc 00 00 fc fc 00 00 fc fc 00 00 fc fc
 ffff8880408db980: fa fb fc fc 00 00 fc fc 00 00 fc fc 00 00 fc fc
>ffff8880408dba00: 00 00 fc fc 00 00 fc fc 00 00 fc fc 00 00 fc fc
                                                             ^
 ffff8880408dba80: fa fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880408dbb00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================