[syzbot] [bcachefs?] KASAN: slab-out-of-bounds Read in __bch2_bkey_unpack_key

5 views
Skip to first unread message

syzbot

unread,
Mar 6, 2025, 8:57:40 PMMar 6
Hello,

syzbot found the following issue on:

HEAD commit: 99fa936e8e4f Merge tag 'affs-6.14-rc5-tag' of git://git.ke..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=11f08078580000
kernel config: https://syzkaller.appspot.com/x/.config?x=2040405600e83619
dashboard link: https://syzkaller.appspot.com/bug?extid=b9d9de2aa46b1bbe575a
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13b69464580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15f08078580000

Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/7feb34a89c2a/non_bootable_disk-99fa936e.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/ef04f83d96f6/vmlinux-99fa936e.xz
kernel image: https://storage.googleapis.com/syzbot-assets/583a7eea5c8e/bzImage-99fa936e.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/4d401321a7e1/mount_6.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq c6c25c03258c59c5 written 48 min_key 0:36028797018963968:0 durability: 1 ptr: 0:27:0 gen 0
node offset 8/48 bset u64s 2088 bset byte offset 360: bad k->u64s 0 (min 3 max 253), fixing
==================================================================
BUG: KASAN: slab-out-of-bounds in unpack_state_init fs/bcachefs/bkey.c:151 [inline]
BUG: KASAN: slab-out-of-bounds in __bch2_bkey_unpack_key+0x66/0xdd0 fs/bcachefs/bkey.c:269
Read of size 8 at addr ffff888053574140 by task kworker/0:1H/36

CPU: 0 UID: 0 PID: 36 Comm: kworker/0:1H Not tainted 6.14.0-rc5-syzkaller-00013-g99fa936e8e4f #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Workqueue: bcachefs_btree_read_complete btree_node_read_work
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
unpack_state_init fs/bcachefs/bkey.c:151 [inline]
__bch2_bkey_unpack_key+0x66/0xdd0 fs/bcachefs/bkey.c:269
__bkey_unpack_key_format_checked fs/bcachefs/bkey.h:407 [inline]
__bkey_unpack_key fs/bcachefs/bkey.h:426 [inline]
__bkey_disassemble fs/bcachefs/bkey.h:477 [inline]
bkey_packed_valid+0x21e/0x6c0 fs/bcachefs/btree_io.c:875
validate_bset_keys+0xeb5/0x1af0 fs/bcachefs/btree_io.c:987
bch2_btree_node_read_done+0x2298/0x6180 fs/bcachefs/btree_io.c:1164
btree_node_read_work+0x6dc/0x1380 fs/bcachefs/btree_io.c:1358
process_one_work kernel/workqueue.c:3238 [inline]
process_scheduled_works+0xabe/0x18e0 kernel/workqueue.c:3319
worker_thread+0x870/0xd30 kernel/workqueue.c:3400
kthread+0x7a9/0x920 kernel/kthread.c:464
ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:148
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
</TASK>

Last potentially related work creation:
------------[ cut here ]------------
pool index 16319 out of bounds (797) for stack id 9a6c3fc0
WARNING: CPU: 0 PID: 36 at lib/stackdepot.c:452 depot_fetch_stack+0x86/0xc0 lib/stackdepot.c:451
Modules linked in:
CPU: 0 UID: 0 PID: 36 Comm: kworker/0:1H Not tainted 6.14.0-rc5-syzkaller-00013-g99fa936e8e4f #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Workqueue: bcachefs_btree_read_complete btree_node_read_work
RIP: 0010:depot_fetch_stack+0x86/0xc0 lib/stackdepot.c:451
Code: 83 7c 18 1c 00 74 38 48 01 d8 eb 24 90 0f 0b 90 44 39 f5 72 ca 90 48 c7 c7 63 fc 3a 8e 89 ee 44 89 f2 89 d9 e8 ab e2 53 fc 90 <0f> 0b 90 90 31 c0 5b 41 5e 5d c3 cc cc cc cc 90 0f 0b 90 eb ef 90
RSP: 0000:ffffc90000576d08 EFLAGS: 00010046
RAX: a98b856e26fe2600 RBX: 000000009a6c3fc0 RCX: ffff88801e00c880
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000003fbf R08: ffffffff81817e32 R09: 1ffff11003f8519a
R10: dffffc0000000000 R11: ffffed1003f8519b R12: ffff888053574140
R13: ffffea00014d5d00 R14: 000000000000031d R15: ffffc90000576de0
FS: 0000000000000000(0000) GS:ffff88801fc00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fabca6ea000 CR3: 0000000012240000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
stack_depot_fetch lib/stackdepot.c:714 [inline]
stack_depot_print+0x16/0x50 lib/stackdepot.c:752
kasan_print_aux_stacks+0x38/0x70 mm/kasan/report_generic.c:199
describe_object_stacks mm/kasan/report.c:347 [inline]
describe_object mm/kasan/report.c:353 [inline]
print_address_description mm/kasan/report.c:412 [inline]
print_report+0x22b/0x5b0 mm/kasan/report.c:521
kasan_report+0x143/0x180 mm/kasan/report.c:634
unpack_state_init fs/bcachefs/bkey.c:151 [inline]
__bch2_bkey_unpack_key+0x66/0xdd0 fs/bcachefs/bkey.c:269
__bkey_unpack_key_format_checked fs/bcachefs/bkey.h:407 [inline]
__bkey_unpack_key fs/bcachefs/bkey.h:426 [inline]
__bkey_disassemble fs/bcachefs/bkey.h:477 [inline]
bkey_packed_valid+0x21e/0x6c0 fs/bcachefs/btree_io.c:875
validate_bset_keys+0xeb5/0x1af0 fs/bcachefs/btree_io.c:987
bch2_btree_node_read_done+0x2298/0x6180 fs/bcachefs/btree_io.c:1164
btree_node_read_work+0x6dc/0x1380 fs/bcachefs/btree_io.c:1358
process_one_work kernel/workqueue.c:3238 [inline]
process_scheduled_works+0xabe/0x18e0 kernel/workqueue.c:3319
worker_thread+0x870/0xd30 kernel/workqueue.c:3400
kthread+0x7a9/0x920 kernel/kthread.c:464
ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:148
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
</TASK>


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at [email protected].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

Alan Huang

unread,
Mar 7, 2025, 8:06:19 PMMar 7
#syz test: https://github.com/alanskind/bcachefs 47e4e14a59ecffbec0025733f1980d23b1a7c7ef


syzbot

unread,
Mar 7, 2025, 8:28:04 PMMar 7
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
WARNING in bch2_trans_put

------------[ cut here ]------------
btree trans held srcu lock (delaying memory reclaim) for 11 seconds
WARNING: CPU: 0 PID: 37 at fs/bcachefs/btree_iter.c:3202 check_srcu_held_too_long fs/bcachefs/btree_iter.c:3200 [inline]
WARNING: CPU: 0 PID: 37 at fs/bcachefs/btree_iter.c:3202 bch2_trans_put+0xe36/0x1020 fs/bcachefs/btree_iter.c:3457
Modules linked in:
CPU: 0 UID: 0 PID: 37 Comm: kworker/0:1H Not tainted 6.14.0-rc1-syzkaller-g47e4e14a59ec #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Workqueue: bcachefs_btree_io btree_node_write_work
RIP: 0010:check_srcu_held_too_long fs/bcachefs/btree_iter.c:3200 [inline]
RIP: 0010:bch2_trans_put+0xe36/0x1020 fs/bcachefs/btree_iter.c:3457
Code: 1c 24 48 c1 eb 02 48 b9 c3 f5 28 5c 8f c2 f5 28 48 89 d8 48 f7 e1 48 c1 ea 02 48 c7 c7 40 3f 72 8c 48 89 d6 e8 6b 71 32 fd 90 <0f> 0b 90 90 e9 63 f8 ff ff e8 fc a9 72 fd 90 0f 0b 90 e9 a6 f8 ff
RSP: 0018:ffffc90000587910 EFLAGS: 00010246
RAX: f68e1852cb63db00 RBX: 0000000000000121 RCX: ffff88801e220000
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000000
RBP: 00000000ffffce37 R08: ffffffff81817d12 R09: 1ffff11003f8519a
R10: dffffc0000000000 R11: ffffed1003f8519b R12: ffff88804f04c088
R13: 1ffff11009e09811 R14: ffff88804f04c042 R15: 1ffff11009e09808
FS: 0000000000000000(0000) GS:ffff88801fc00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fd96e77d538 CR3: 0000000012314000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
btree_node_write_work+0xa91/0xbb0 fs/bcachefs/btree_io.c:2098
process_one_work kernel/workqueue.c:3236 [inline]
process_scheduled_works+0xabe/0x18e0 kernel/workqueue.c:3317
worker_thread+0x870/0xd30 kernel/workqueue.c:3398
kthread+0x7a9/0x920 kernel/kthread.c:464
ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:148
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
</TASK>


Tested on:

commit: 47e4e14a bcachefs: Fix b->written overflow
git tree: https://github.com/alanskind/bcachefs
console output: https://syzkaller.appspot.com/x/log.txt?x=16b843a8580000
kernel config: https://syzkaller.appspot.com/x/.config?x=9a4389e017863e2
dashboard link: https://syzkaller.appspot.com/bug?extid=b9d9de2aa46b1bbe575a
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Note: no patches were applied.
Reply all
Reply to author
Forward
0 new messages