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: 5326 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+0x214/0xb90 fs/bcachefs/alloc_foreground.c:472
 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_btree_node_alloc fs/bcachefs/btree_update_interior.c:319 [inline]
 bch2_btree_reserve_get+0x664/0x1a20 fs/bcachefs/btree_update_interior.c:529
 bch2_btree_update_start+0xfd2/0x16c0 fs/bcachefs/btree_update_interior.c:1229
 bch2_btree_split_leaf+0x12d/0x8a0 fs/bcachefs/btree_update_interior.c:1864
 bch2_trans_commit_error+0x1b3/0x1480 fs/bcachefs/btree_trans_commit.c:904
 __bch2_trans_commit+0x8886/0x9da0 fs/bcachefs/btree_trans_commit.c:1069
 bch2_trans_commit fs/bcachefs/btree_update.h:195 [inline]
 bch2_extent_update+0x4f4/0xba0 fs/bcachefs/io_write.c:332
 bch2_write_index_default fs/bcachefs/io_write.c:380 [inline]
 __bch2_write_index+0xf05/0x2080 fs/bcachefs/io_write.c:565
 bch2_write_data_inline fs/bcachefs/io_write.c:1597 [inline]
 bch2_write+0xea3/0x15d0 fs/bcachefs/io_write.c:1665
 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:479 [inline]
 bch2_writepages+0x286/0x390 fs/bcachefs/fs-io-buffered.c:662
 do_writepages+0x364/0x890 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+0x2cf/0x3e0 mm/filemap.c:794
 bch2_fsync+0x13a/0x350 fs/bcachefs/fs-io.c:228
 generic_write_sync include/linux/fs.h:2976 [inline]
 bch2_write_iter+0x2a08/0x2cd0 fs/bcachefs/fs-io-buffered.c:1082
 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:0x7f5087b8d169
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:00007f5088a91038 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f5087da5fa0 RCX: 00007f5087b8d169
RDX: 000000000000000b RSI: 00002000000000c0 RDI: 0000000000000005
RBP: 00007f5088a91090 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000002
R13: 0000000000000000 R14: 00007f5087da5fa0 R15: 00007ffcbd49a358
 </TASK>
==================================================================
BUG: KASAN: slab-out-of-bounds in memscan+0x61/0x80 lib/string.c:728
Read of size 1 at addr ffff888052b68e8b by task syz.0.0/5326

CPU: 0 UID: 0 PID: 5326 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+0x214/0xb90 fs/bcachefs/alloc_foreground.c:472
 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_btree_node_alloc fs/bcachefs/btree_update_interior.c:319 [inline]
 bch2_btree_reserve_get+0x664/0x1a20 fs/bcachefs/btree_update_interior.c:529
 bch2_btree_update_start+0xfd2/0x16c0 fs/bcachefs/btree_update_interior.c:1229
 bch2_btree_split_leaf+0x12d/0x8a0 fs/bcachefs/btree_update_interior.c:1864
 bch2_trans_commit_error+0x1b3/0x1480 fs/bcachefs/btree_trans_commit.c:904
 __bch2_trans_commit+0x8886/0x9da0 fs/bcachefs/btree_trans_commit.c:1069
 bch2_trans_commit fs/bcachefs/btree_update.h:195 [inline]
 bch2_extent_update+0x4f4/0xba0 fs/bcachefs/io_write.c:332
 bch2_write_index_default fs/bcachefs/io_write.c:380 [inline]
 __bch2_write_index+0xf05/0x2080 fs/bcachefs/io_write.c:565
 bch2_write_data_inline fs/bcachefs/io_write.c:1597 [inline]
 bch2_write+0xea3/0x15d0 fs/bcachefs/io_write.c:1665
 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:479 [inline]
 bch2_writepages+0x286/0x390 fs/bcachefs/fs-io-buffered.c:662
 do_writepages+0x364/0x890 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+0x2cf/0x3e0 mm/filemap.c:794
 bch2_fsync+0x13a/0x350 fs/bcachefs/fs-io.c:228
 generic_write_sync include/linux/fs.h:2976 [inline]
 bch2_write_iter+0x2a08/0x2cd0 fs/bcachefs/fs-io-buffered.c:1082
 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:0x7f5087b8d169
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:00007f5088a91038 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f5087da5fa0 RCX: 00007f5087b8d169
RDX: 000000000000000b RSI: 00002000000000c0 RDI: 0000000000000005
RBP: 00007f5088a91090 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000002
R13: 0000000000000000 R14: 00007f5087da5fa0 R15: 00007ffcbd49a358
 </TASK>

Allocated by task 5326:
 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+0x1c6/0xb90 fs/bcachefs/alloc_foreground.c:470
 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_btree_node_alloc fs/bcachefs/btree_update_interior.c:319 [inline]
 bch2_btree_reserve_get+0x664/0x1a20 fs/bcachefs/btree_update_interior.c:529
 bch2_btree_update_start+0xfd2/0x16c0 fs/bcachefs/btree_update_interior.c:1229
 bch2_btree_split_leaf+0x12d/0x8a0 fs/bcachefs/btree_update_interior.c:1864
 bch2_trans_commit_error+0x1b3/0x1480 fs/bcachefs/btree_trans_commit.c:904
 __bch2_trans_commit+0x8886/0x9da0 fs/bcachefs/btree_trans_commit.c:1069
 bch2_trans_commit fs/bcachefs/btree_update.h:195 [inline]
 bch2_extent_update+0x4f4/0xba0 fs/bcachefs/io_write.c:332
 bch2_write_index_default fs/bcachefs/io_write.c:380 [inline]
 __bch2_write_index+0xf05/0x2080 fs/bcachefs/io_write.c:565
 bch2_write_data_inline fs/bcachefs/io_write.c:1597 [inline]
 bch2_write+0xea3/0x15d0 fs/bcachefs/io_write.c:1665
 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:479 [inline]
 bch2_writepages+0x286/0x390 fs/bcachefs/fs-io-buffered.c:662
 do_writepages+0x364/0x890 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+0x2cf/0x3e0 mm/filemap.c:794
 bch2_fsync+0x13a/0x350 fs/bcachefs/fs-io.c:228
 generic_write_sync include/linux/fs.h:2976 [inline]
 bch2_write_iter+0x2a08/0x2cd0 fs/bcachefs/fs-io-buffered.c:1082
 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 ffff888052b68e00
 which belongs to the cache kmalloc-128 of size 128
The buggy address is located 11 bytes to the right of
 allocated 128-byte region [ffff888052b68e00, ffff888052b68e80)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x52b68
flags: 0x4fff00000000000(node=1|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 04fff00000000000 ffff88801b041a00 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000100010 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 0x52cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 4733, tgid 4733 (udevd), ts 69311796596, free_ts 69230345235
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f4/0x240 mm/page_alloc.c:1717
 prep_new_page mm/page_alloc.c:1725 [inline]
 get_page_from_freelist+0x352b/0x36c0 mm/page_alloc.c:3652
 __alloc_frozen_pages_noprof+0x211/0x5b0 mm/page_alloc.c:4934
 alloc_pages_mpol+0x339/0x690 mm/mempolicy.c:2301
 alloc_slab_page mm/slub.c:2459 [inline]
 allocate_slab+0x8f/0x3a0 mm/slub.c:2623
 new_slab mm/slub.c:2676 [inline]
 ___slab_alloc+0xc3b/0x1500 mm/slub.c:3862
 __slab_alloc+0x58/0xa0 mm/slub.c:3952
 __slab_alloc_node mm/slub.c:4027 [inline]
 slab_alloc_node mm/slub.c:4188 [inline]
 __kmalloc_cache_noprof+0x26a/0x370 mm/slub.c:4357
 kmalloc_noprof include/linux/slab.h:905 [inline]
 kzalloc_noprof include/linux/slab.h:1039 [inline]
 kernfs_get_open_node fs/kernfs/file.c:525 [inline]
 kernfs_fop_open+0x8a0/0xdf0 fs/kernfs/file.c:700
 do_dentry_open+0xdec/0x1960 fs/open.c:956
 vfs_open+0x3b/0x370 fs/open.c:1086
 do_open fs/namei.c:3845 [inline]
 path_openat+0x2caf/0x35d0 fs/namei.c:4004
 do_filp_open+0x284/0x4e0 fs/namei.c:4031
 do_sys_openat2+0x12b/0x1d0 fs/open.c:1429
 do_sys_open fs/open.c:1444 [inline]
 __do_sys_openat fs/open.c:1460 [inline]
 __se_sys_openat fs/open.c:1455 [inline]
 __x64_sys_openat+0x249/0x2a0 fs/open.c:1455
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/syscall_64.c:94
page last free pid 5308 tgid 5308 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
 discard_slab mm/slub.c:2720 [inline]
 __put_partials+0x160/0x1c0 mm/slub.c:3189
 put_cpu_partial+0x17e/0x250 mm/slub.c:3264
 __slab_free+0x294/0x390 mm/slub.c:4516
 qlink_free mm/kasan/quarantine.c:163 [inline]
 qlist_free_all+0x9a/0x140 mm/kasan/quarantine.c:179
 kasan_quarantine_reduce+0x14f/0x170 mm/kasan/quarantine.c:286
 __kasan_slab_alloc+0x23/0x80 mm/kasan/common.c:329
 kasan_slab_alloc include/linux/kasan.h:250 [inline]
 slab_post_alloc_hook mm/slub.c:4151 [inline]
 slab_alloc_node mm/slub.c:4200 [inline]
 __kmalloc_cache_noprof+0x1c8/0x370 mm/slub.c:4357
 kmalloc_noprof include/linux/slab.h:905 [inline]
 kzalloc_noprof include/linux/slab.h:1039 [inline]
 kernfs_fop_open+0x3a3/0xdf0 fs/kernfs/file.c:623
 do_dentry_open+0xdec/0x1960 fs/open.c:956
 vfs_open+0x3b/0x370 fs/open.c:1086
 do_open fs/namei.c:3845 [inline]
 path_openat+0x2caf/0x35d0 fs/namei.c:4004
 do_filp_open+0x284/0x4e0 fs/namei.c:4031
 do_sys_openat2+0x12b/0x1d0 fs/open.c:1429
 do_sys_open fs/open.c:1444 [inline]
 __do_sys_openat fs/open.c:1460 [inline]
 __se_sys_openat fs/open.c:1455 [inline]
 __x64_sys_openat+0x249/0x2a0 fs/open.c:1455
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/syscall_64.c:94

Memory state around the buggy address:
 ffff888052b68d80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888052b68e00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888052b68e80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                      ^
 ffff888052b68f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc
 ffff888052b68f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================