syzbot


KASAN: slab-out-of-bounds Read in memscan (2)

Status: upstream: reported syz repro on 2025/03/25 04:45
Subsystems: bcachefs
[Documentation on labels]
Reported-by: syzbot+ca8a872d9fa7652522da@syzkaller.appspotmail.com
First crash: 117d, last: 84d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [bcachefs?] KASAN: slab-out-of-bounds Read in memscan (2) 0 (2) 2025/04/03 14:42
Similar bugs (1)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-out-of-bounds Read in memscan bcachefs 17 2 231d 225d 0/29 auto-obsoleted due to no activity on 2025/03/06 06:12
Last patch testing requests (2)
Created Duration User Patch Repo Result
2025/07/02 01:49 19m retest repro upstream OK log
2025/04/23 01:00 19m retest repro upstream report log

Sample crash report:
bcachefs (loop0): going read-only
bcachefs (loop0): finished waiting for writes to stop
bcachefs (loop0): flushing journal and stopping allocators, journal seq 2
FAULT_INJECTION: forcing a failure.
name failslab, interval 1, probability 0, space 0, times 1
CPU: 0 UID: 0 PID: 5325 Comm: syz.0.0 Not tainted 6.15.0-rc1-syzkaller-00025-gbec7dcbc242c #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+0x2e4b/0x2e60 fs/bcachefs/alloc_foreground.c:587
 bch2_bucket_alloc_set_trans+0x516/0xcb0 fs/bcachefs/alloc_foreground.c:749
 __open_bucket_add_buckets+0x13f5/0x1e70 fs/bcachefs/alloc_foreground.c:992
 open_bucket_add_buckets+0x343/0x410 fs/bcachefs/alloc_foreground.c:1036
 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
 wb_flush_one fs/bcachefs/btree_write_buffer.c:181 [inline]
 bch2_btree_write_buffer_flush_locked+0x292d/0x52a0 fs/bcachefs/btree_write_buffer.c:398
 btree_write_buffer_flush_seq+0x1af6/0x1ca0 fs/bcachefs/btree_write_buffer.c:570
 bch2_btree_write_buffer_flush_going_ro+0x13c/0x200 fs/bcachefs/btree_write_buffer.c:609
 __bch2_fs_read_only+0x11b/0x4b0 fs/bcachefs/super.c:273
 bch2_fs_read_only+0xd16/0x1400 fs/bcachefs/super.c:356
 bch2_fs_reconfigure+0x1d9/0x4e0 fs/bcachefs/fs.c:2356
 reconfigure_super+0x43a/0x870 fs/super.c:1083
 do_remount fs/namespace.c:3363 [inline]
 path_mount+0xc25/0xfa0 fs/namespace.c:4198
 do_mount fs/namespace.c:4219 [inline]
 __do_sys_mount fs/namespace.c:4430 [inline]
 __se_sys_mount+0x38c/0x400 fs/namespace.c:4407
 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:0x7f965bf8d169
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:00007f965ce21038 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007f965c1a6080 RCX: 00007f965bf8d169
RDX: 0000000000000000 RSI: 0000200000000100 RDI: 0000000000000000
RBP: 00007f965ce21090 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000021 R11: 0000000000000246 R12: 0000000000000002
R13: 0000000000000001 R14: 00007f965c1a6080 R15: 00007ffdb262c528
 </TASK>
==================================================================
BUG: KASAN: slab-out-of-bounds in memscan+0x61/0x80 lib/string.c:728
Read of size 1 at addr ffff88803523c057 by task syz.0.0/5325

CPU: 0 UID: 0 PID: 5325 Comm: syz.0.0 Not tainted 6.15.0-rc1-syzkaller-00025-gbec7dcbc242c #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+0x2e4b/0x2e60 fs/bcachefs/alloc_foreground.c:587
 bch2_bucket_alloc_set_trans+0x516/0xcb0 fs/bcachefs/alloc_foreground.c:749
 __open_bucket_add_buckets+0x13f5/0x1e70 fs/bcachefs/alloc_foreground.c:992
 open_bucket_add_buckets+0x343/0x410 fs/bcachefs/alloc_foreground.c:1036
 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
 wb_flush_one fs/bcachefs/btree_write_buffer.c:181 [inline]
 bch2_btree_write_buffer_flush_locked+0x292d/0x52a0 fs/bcachefs/btree_write_buffer.c:398
 btree_write_buffer_flush_seq+0x1af6/0x1ca0 fs/bcachefs/btree_write_buffer.c:570
 bch2_btree_write_buffer_flush_going_ro+0x13c/0x200 fs/bcachefs/btree_write_buffer.c:609
 __bch2_fs_read_only+0x11b/0x4b0 fs/bcachefs/super.c:273
 bch2_fs_read_only+0xd16/0x1400 fs/bcachefs/super.c:356
 bch2_fs_reconfigure+0x1d9/0x4e0 fs/bcachefs/fs.c:2356
 reconfigure_super+0x43a/0x870 fs/super.c:1083
 do_remount fs/namespace.c:3363 [inline]
 path_mount+0xc25/0xfa0 fs/namespace.c:4198
 do_mount fs/namespace.c:4219 [inline]
 __do_sys_mount fs/namespace.c:4430 [inline]
 __se_sys_mount+0x38c/0x400 fs/namespace.c:4407
 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:0x7f965bf8d169
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:00007f965ce21038 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007f965c1a6080 RCX: 00007f965bf8d169
RDX: 0000000000000000 RSI: 0000200000000100 RDI: 0000000000000000
RBP: 00007f965ce21090 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000021 R11: 0000000000000246 R12: 0000000000000002
R13: 0000000000000001 R14: 00007f965c1a6080 R15: 00007ffdb262c528
 </TASK>

Allocated by task 5325:
 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+0x2e4b/0x2e60 fs/bcachefs/alloc_foreground.c:587
 bch2_bucket_alloc_set_trans+0x516/0xcb0 fs/bcachefs/alloc_foreground.c:749
 __open_bucket_add_buckets+0x13f5/0x1e70 fs/bcachefs/alloc_foreground.c:992
 open_bucket_add_buckets+0x343/0x410 fs/bcachefs/alloc_foreground.c:1036
 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
 wb_flush_one fs/bcachefs/btree_write_buffer.c:181 [inline]
 bch2_btree_write_buffer_flush_locked+0x292d/0x52a0 fs/bcachefs/btree_write_buffer.c:398
 btree_write_buffer_flush_seq+0x1af6/0x1ca0 fs/bcachefs/btree_write_buffer.c:570
 bch2_btree_write_buffer_flush_going_ro+0x13c/0x200 fs/bcachefs/btree_write_buffer.c:609
 __bch2_fs_read_only+0x11b/0x4b0 fs/bcachefs/super.c:273
 bch2_fs_read_only+0xd16/0x1400 fs/bcachefs/super.c:356
 bch2_fs_reconfigure+0x1d9/0x4e0 fs/bcachefs/fs.c:2356
 reconfigure_super+0x43a/0x870 fs/super.c:1083
 do_remount fs/namespace.c:3363 [inline]
 path_mount+0xc25/0xfa0 fs/namespace.c:4198
 do_mount fs/namespace.c:4219 [inline]
 __do_sys_mount fs/namespace.c:4430 [inline]
 __se_sys_mount+0x38c/0x400 fs/namespace.c:4407
 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 ffff88803523c040
 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 [ffff88803523c040, ffff88803523c050)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x3523c
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 0x52cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 5200, tgid 5200 (dhcpcd), ts 49754550470, free_ts 46277938375
 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]
 bpf_prog_store_orig_filter net/core/filter.c:1148 [inline]
 bpf_prog_create_from_user+0x1fd/0x3f0 net/core/filter.c:1439
 seccomp_prepare_filter kernel/seccomp.c:701 [inline]
 seccomp_prepare_user_filter kernel/seccomp.c:738 [inline]
 seccomp_set_mode_filter kernel/seccomp.c:1974 [inline]
 do_seccomp+0x935/0x1000 kernel/seccomp.c:2094
 __do_sys_prctl kernel/sys.c:2555 [inline]
 __se_sys_prctl+0xce9/0x4190 kernel/sys.c:2473
 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
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:
 ffff88803523bf00: 00 00 00 00 00 00 fc fc fc fc 00 00 00 00 00 00
 ffff88803523bf80: 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88803523c000: 00 00 fc fc 00 00 fc fc 00 00 fc fc 00 00 fc fc
                                                 ^
 ffff88803523c080: 00 00 fc fc 00 00 fc fc 00 00 fc fc 00 00 fc fc
 ffff88803523c100: 00 00 fc fc 00 00 fc fc 00 00 fc fc 00 00 fc fc
==================================================================

Crashes (7):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/04/09 00:28 upstream bec7dcbc242c b133e63a .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: slab-out-of-bounds Read in memscan
2025/04/03 18:23 upstream a2cc6ff5ec8f d7ae3a11 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: slab-out-of-bounds Read in memscan
2025/04/03 14:41 upstream a1b5bd45d4ee 996a9618 .config console log report syz / log [disk image (non-bootable)] [vmlinux] [kernel image] [mounted in repro] ci-snapshot-upstream-root KASAN: slab-out-of-bounds Read in memscan
2025/04/03 13:25 upstream a1b5bd45d4ee 996a9618 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: slab-out-of-bounds Read in memscan
2025/04/03 13:24 upstream a1b5bd45d4ee 996a9618 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: slab-out-of-bounds Read in memscan
2025/03/22 12:05 upstream 88d324e69ea9 c6512ef7 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: slab-out-of-bounds Read in memscan
2025/03/21 03:20 upstream 5fc319360819 62330552 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: slab-out-of-bounds Read in memscan
* Struck through repros no longer work on HEAD.