Re: [syzbot] [bcachefs?] kernel BUG in bch2_fs_initialize

Alan Huang
2025-04-12T06:58:33Z

On Apr 12, 2025, at 14:45, syzbot <syzbot+d10151bf01574a09a915@syzkaller.appspotmail.com> wrote:
>
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 29e7bf01ed80 Add linux-next specific files for 20250410
> git tree: linux-next
> console output: https://syzkaller.appspot.com/x/log.txt?x=1515f74c580000
> kernel config: https://syzkaller.appspot.com/x/.config?x=a554d15459e77547
> dashboard link: https://syzkaller.appspot.com/bug?extid=d10151bf01574a09a915
> 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=14634398580000
>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/bb76302efd6b/disk-29e7bf01.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/7da3c6b9e532/vmlinux-29e7bf01.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/4909c61270ed/bzImage-29e7bf01.xz
> mounted in repro: https://storage.googleapis.com/syzbot-assets/d99f7622732d/mount_0.gz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+d10151bf01574a09a915@syzkaller.appspotmail.com
>
> 0 pages HighMem/MovableOnly
> 428629 pages reserved
> 0 pages cma reserved
> bcachefs (loop0): error reallocating journal fifo (32768 open entries)
> ------------[ cut here ]------------
> kernel BUG at fs/bcachefs/journal.h:442!
> Oops: invalid opcode: 0000 [#1] SMP KASAN PTI
> CPU: 1 UID: 0 PID: 6987 Comm: syz.0.185 Not tainted 6.15.0-rc1-next-20250410-syzkaller #0 PREEMPT(full)
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
> RIP: 0010:bch2_journal_set_replay_done fs/bcachefs/journal.h:442 [inline]
> RIP: 0010:bch2_fs_initialize+0x15f9/0x1620 fs/bcachefs/recovery.c:1130
> Code: ff e8 eb a8 a8 07 44 89 f1 80 e1 07 80 c1 03 38 c1 0f 8c 04 fe ff ff 4c 89 f7 e8 32 7d a3 fd e9 f7 fd ff ff e8 08 51 39 fd 90 <0f> 0b e8 00 51 39 fd e8 7b 6f a3 fd 4c 89 ff 8b 74 24 38 e8 bf 3f
> RSP: 0018:ffffc90003c67420 EFLAGS: 00010293
> RAX: ffffffff848a29d8 RBX: 0000000000000000 RCX: ffff88802c799e00
> RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
> RBP: ffffc90003c67920 R08: ffffffff848a1dfe R09: 1ffff11009c792c0
> R10: dffffc0000000000 R11: ffffed1009c792c1 R12: ffff88804e380000
> R13: ffff88804e380820 R14: ffff88804e3c9600 R15: ffff88804e3c95c0
> FS: 00007fa3bfd836c0(0000) GS:ffff888125080000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 000000c00009bfc0 CR3: 000000003475c000 CR4: 00000000003526f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
> <TASK>
> bch2_fs_start+0x301/0x620 fs/bcachefs/super.c:1100
> bch2_fs_get_tree+0x1138/0x18e0 fs/bcachefs/fs.c:2253
> vfs_get_tree+0x90/0x2b0 fs/super.c:1809
> do_new_mount+0x2cf/0xb70 fs/namespace.c:3879
> 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:0x7fa3bef8e90a
> Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 1a 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 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:00007fa3bfd82e68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
> RAX: ffffffffffffffda RBX: 00007fa3bfd82ef0 RCX: 00007fa3bef8e90a
> RDX: 00002000000000c0 RSI: 0000200000000180 RDI: 00007fa3bfd82eb0
> RBP: 00002000000000c0 R08: 00007fa3bfd82ef0 R09: 0000000000000080
> R10: 0000000000000080 R11: 0000000000000246 R12: 0000200000000180
> R13: 00007fa3bfd82eb0 R14: 0000000000005a18 R15: 0000200000000440
> </TASK>
> Modules linked in:
> ---[ end trace 0000000000000000 ]---
> RIP: 0010:bch2_journal_set_replay_done fs/bcachefs/journal.h:442 [inline]
> RIP: 0010:bch2_fs_initialize+0x15f9/0x1620 fs/bcachefs/recovery.c:1130
> Code: ff e8 eb a8 a8 07 44 89 f1 80 e1 07 80 c1 03 38 c1 0f 8c 04 fe ff ff 4c 89 f7 e8 32 7d a3 fd e9 f7 fd ff ff e8 08 51 39 fd 90 <0f> 0b e8 00 51 39 fd e8 7b 6f a3 fd 4c 89 ff 8b 74 24 38 e8 bf 3f
> RSP: 0018:ffffc90003c67420 EFLAGS: 00010293
> RAX: ffffffff848a29d8 RBX: 0000000000000000 RCX: ffff88802c799e00
> RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
> RBP: ffffc90003c67920 R08: ffffffff848a1dfe R09: 1ffff11009c792c0
> R10: dffffc0000000000 R11: ffffed1009c792c1 R12: ffff88804e380000
> R13: ffff88804e380820 R14: ffff88804e3c9600 R15: ffff88804e3c95c0
> FS: 00007fa3bfd836c0(0000) GS:ffff888125080000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 000000c00009bfc0 CR3: 000000003475c000 CR4: 00000000003526f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
>
>
> ---
> 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 syzkaller@googlegroups.com.
>
> 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
>

#syz test

diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c
index d2b07f602da9..606d684e6f23 100644
--- a/fs/bcachefs/recovery.c
+++ b/fs/bcachefs/recovery.c
@@ -1125,7 +1125,10 @@ int bch2_fs_initialize(struct bch_fs *c)
* journal_res_get() will crash if called before this has
* set up the journal.pin FIFO and journal.cur pointer:
*/
- bch2_fs_journal_start(&c->journal, 1);
+ ret = bch2_fs_journal_start(&c->journal, 1);
+ if (ret)
+ goto err;
+
set_bit(BCH_FS_accounting_replay_done, &c->flags);
bch2_journal_set_replay_done(&c->journal);