syzbot


KASAN: slab-out-of-bounds Read in __bch2_checksum_bio

Status: moderation: reported on 2025/04/24 18:21
Subsystems: bcachefs
[Documentation on labels]
Reported-by: syzbot+c530d8b008015a573983@syzkaller.appspotmail.com
First crash: 23d, last: 23d

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in __bch2_checksum_bio+0x2df/0x1070 fs/bcachefs/checksum.c:232
Read of size 8 at addr ffff888040e0dd40 by task kworker/u4:1/14

CPU: 0 UID: 0 PID: 14 Comm: kworker/u4:1 Not tainted 6.15.0-rc3-syzkaller-00032-ga79be02bba5c #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
Workqueue: events_unbound __bch2_read_endio
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
 __bch2_checksum_bio+0x2df/0x1070 fs/bcachefs/checksum.c:232
 bch2_checksum_bio+0xbc/0x110 fs/bcachefs/checksum.c:252
 __bch2_read_endio+0x606/0x1840 fs/bcachefs/io_read.c:750
 process_one_work kernel/workqueue.c:3238 [inline]
 process_scheduled_works+0xac3/0x18e0 kernel/workqueue.c:3319
 worker_thread+0x870/0xd50 kernel/workqueue.c:3400
 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
 </TASK>

Allocated by task 5340:
 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:4341 [inline]
 __kmalloc_noprof+0x28e/0x4d0 mm/slub.c:4353
 kmalloc_noprof include/linux/slab.h:909 [inline]
 kmalloc_array_noprof include/linux/slab.h:948 [inline]
 bch2_data_update_bios_init+0x669/0xbe0 fs/bcachefs/data_update.c:672
 bch2_data_update_init+0x5d18/0x7950 fs/bcachefs/data_update.c:897
 bch2_move_extent+0x894/0x2680 fs/bcachefs/move.c:320
 bch2_move_data_btree fs/bcachefs/move.c:666 [inline]
 __bch2_move_data+0x2859/0x38e0 fs/bcachefs/move.c:713
 do_rebalance_scan fs/bcachefs/rebalance.c:480 [inline]
 do_rebalance fs/bcachefs/rebalance.c:546 [inline]
 bch2_rebalance_thread+0xcef/0x1fa0 fs/bcachefs/rebalance.c:588
 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

The buggy address belongs to the object at ffff888040e0dd00
 which belongs to the cache kmalloc-64 of size 64
The buggy address is located 0 bytes to the right of
 allocated 64-byte region [ffff888040e0dd00, ffff888040e0dd40)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x40e0d
flags: 0x4fff00000000000(node=1|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 04fff00000000000 ffff88801b0418c0 dead000000000122 0000000000000000
raw: 0000000000000000 0000000080200020 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 0x52c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 5329, tgid 5328 (syz.0.0), ts 76639627066, free_ts 76373181480
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f4/0x240 mm/page_alloc.c:1718
 prep_new_page mm/page_alloc.c:1726 [inline]
 get_page_from_freelist+0x360a/0x37a0 mm/page_alloc.c:3688
 __alloc_frozen_pages_noprof+0x211/0x5b0 mm/page_alloc.c:4970
 alloc_pages_mpol+0x339/0x690 mm/mempolicy.c:2301
 alloc_slab_page mm/slub.c:2468 [inline]
 allocate_slab+0x8f/0x3b0 mm/slub.c:2632
 new_slab mm/slub.c:2686 [inline]
 ___slab_alloc+0xc3b/0x1500 mm/slub.c:3872
 __slab_alloc+0x58/0xa0 mm/slub.c:3962
 __slab_alloc_node mm/slub.c:4037 [inline]
 slab_alloc_node mm/slub.c:4198 [inline]
 __do_kmalloc_node mm/slub.c:4340 [inline]
 __kmalloc_node_track_caller_noprof+0x2ef/0x4d0 mm/slub.c:4360
 __do_krealloc mm/slub.c:4918 [inline]
 krealloc_noprof+0x10f/0x300 mm/slub.c:4971
 bch2_printbuf_make_room+0x1f1/0x350 fs/bcachefs/printbuf.c:59
 prt_bytes fs/bcachefs/printbuf.h:219 [inline]
 prt_str+0x3e/0x7d0 fs/bcachefs/printbuf.h:231
 bch2_btree_id_level_to_text+0x24/0xa0 fs/bcachefs/btree_cache.c:1405
 bch2_btree_path_to_text_short+0x200/0xfb0 fs/bcachefs/btree_iter.c:1507
 __bch2_trans_paths_to_text+0xe5/0x180 fs/bcachefs/btree_iter.c:1575
 bch2_trans_update_max_paths+0x173/0x420 fs/bcachefs/btree_iter.c:1611
 btree_path_alloc+0x8d9/0xad0 fs/bcachefs/btree_iter.c:1708
page last free pid 40 tgid 40 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:2725
 __slab_free+0x2c6/0x390 mm/slub.c:4567
 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:4161 [inline]
 slab_alloc_node mm/slub.c:4210 [inline]
 __do_kmalloc_node mm/slub.c:4340 [inline]
 __kmalloc_noprof+0x238/0x4d0 mm/slub.c:4353
 kmalloc_noprof include/linux/slab.h:909 [inline]
 __bch2_trans_get+0x6ba/0xd40 fs/bcachefs/btree_iter.c:3373
 btree_node_write_work+0x78e/0xcc0 fs/bcachefs/btree_io.c:2107
 process_one_work kernel/workqueue.c:3238 [inline]
 process_scheduled_works+0xac3/0x18e0 kernel/workqueue.c:3319
 worker_thread+0x870/0xd50 kernel/workqueue.c:3400
 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:
 ffff888040e0dc00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff888040e0dc80: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
>ffff888040e0dd00: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
                                           ^
 ffff888040e0dd80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888040e0de00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/04/24 02:53 upstream a79be02bba5c 9882047a .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: slab-out-of-bounds Read in __bch2_checksum_bio
* Struck through repros no longer work on HEAD.