syzbot


KASAN: null-ptr-deref Write in btree_key_cache_fill

Status: moderation: reported on 2025/06/29 07:23
Subsystems: bcachefs
[Documentation on labels]
Reported-by: syzbot+5d4979c5112460e0c04a@syzkaller.appspotmail.com
First crash: 9d06h, last: 9d06h

Sample crash report:
SLUB: Unable to allocate memory on CPU 0 (of node 0) on node -1, gfp=0xcc0(GFP_KERNEL)
  cache: kmalloc-256, object size: 256, buffer size: 512, default order: 0, min order: 0
  node 0: slabs: 43, objs: 344, free: 0
  node 1: slabs: 676, objs: 5408, free: 2
SLUB: Unable to allocate memory on CPU 0 (of node 0) on node -1, gfp=0xcc0(GFP_KERNEL)
  cache: kmalloc-256, object size: 256, buffer size: 512, default order: 0, min order: 0
  node 0: slabs: 43, objs: 344, free: 0
  node 1: slabs: 690, objs: 5520, free: 2
bcachefs (loop0): error allocating memory for key cache key, btree inodes u64s 32
==================================================================
BUG: KASAN: null-ptr-deref in bkey_reassemble fs/bcachefs/bkey.h:505 [inline]
BUG: KASAN: null-ptr-deref in btree_key_cache_create fs/bcachefs/btree_key_cache.c:270 [inline]
BUG: KASAN: null-ptr-deref in btree_key_cache_fill+0x7c4/0x3010 fs/bcachefs/btree_key_cache.c:344
Write of size 40 at addr 0000000000000000 by task syz.0.0/5347

CPU: 0 UID: 0 PID: 5347 Comm: syz.0.0 Not tainted 6.16.0-rc3-syzkaller-00044-g7595b66ae9de #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_lvl+0x189/0x250 lib/dump_stack.c:120
 kasan_report+0x118/0x150 mm/kasan/report.c:634
 check_region_inline mm/kasan/generic.c:-1 [inline]
 kasan_check_range+0x2b0/0x2c0 mm/kasan/generic.c:189
 __asan_memcpy+0x40/0x70 mm/kasan/shadow.c:106
 bkey_reassemble fs/bcachefs/bkey.h:505 [inline]
 btree_key_cache_create fs/bcachefs/btree_key_cache.c:270 [inline]
 btree_key_cache_fill+0x7c4/0x3010 fs/bcachefs/btree_key_cache.c:344
 bch2_btree_path_traverse_cached+0xc5d/0x10d0 fs/bcachefs/btree_key_cache.c:399
 bch2_btree_path_traverse_one+0x372/0x21d0 fs/bcachefs/btree_iter.c:1179
 bch2_btree_path_traverse fs/bcachefs/btree_iter.h:250 [inline]
 bch2_btree_iter_peek_slot+0x74e/0x1fa0 fs/bcachefs/btree_iter.c:2781
 __bch2_bkey_get_iter fs/bcachefs/btree_iter.h:632 [inline]
 bch2_bkey_get_iter fs/bcachefs/btree_iter.h:646 [inline]
 __bch2_inode_peek+0x133/0x370 fs/bcachefs/inode.c:348
 bch2_inode_peek fs/bcachefs/inode.h:136 [inline]
 bch2_inode_find_by_inum_trans fs/bcachefs/inode.c:411 [inline]
 bch2_inode_find_by_inum+0xef/0x240 fs/bcachefs/inode.c:420
 bchfs_truncate+0x3a8/0xc20 fs/bcachefs/fs-io.c:458
 notify_change+0xb33/0xe40 fs/attr.c:552
 do_truncate+0x1a4/0x220 fs/open.c:68
 do_coredump+0x2ad3/0x3440 fs/coredump.c:790
 get_signal+0x1109/0x1340 kernel/signal.c:3019
 arch_do_signal_or_restart+0x9a/0x750 arch/x86/kernel/signal.c:337
 exit_to_user_mode_loop+0x75/0x110 kernel/entry/common.c:111
 exit_to_user_mode_prepare include/linux/entry-common.h:330 [inline]
 syscall_exit_to_user_mode_work include/linux/entry-common.h:414 [inline]
 syscall_exit_to_user_mode include/linux/entry-common.h:449 [inline]
 ret_from_fork+0x47f/0x770 arch/x86/kernel/process.c:157
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
 </TASK>
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/06/25 07:15 upstream 7595b66ae9de 26d77996 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: null-ptr-deref Write in btree_key_cache_fill
* Struck through repros no longer work on HEAD.