Re: [syzbot] [nilfs?] kernel BUG in nilfs_btnode_create_block (2)

From: Ryusuke Konishi
Date: Sat Jun 15 2024 - 19:36:36 EST


On Sun, Jun 16, 2024 at 1:32 AM syzbot wrote:
>
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 83a7eefedc9b Linux 6.10-rc3
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=13ab3d96980000
> kernel config: https://syzkaller.appspot.com/x/.config?x=c79815c08cc14227
> dashboard link: https://syzkaller.appspot.com/bug?extid=89cc4f2324ed37988b60
> compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
>
> Unfortunately, I don't have any reproducer for this issue yet.
>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/b45273014a8f/disk-83a7eefe.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/94cd5708292e/vmlinux-83a7eefe.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/a89698812e8b/bzImage-83a7eefe.xz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+89cc4f2324ed37988b60@xxxxxxxxxxxxxxxxxxxxxxxxx
>
> ------------[ cut here ]------------
> kernel BUG at fs/nilfs2/btnode.c:59!
> Oops: invalid opcode: 0000 [#1] PREEMPT SMP KASAN PTI
> CPU: 1 PID: 7600 Comm: segctord Not tainted 6.10.0-rc3-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/02/2024
> RIP: 0010:nilfs_btnode_create_block+0x3dc/0x400 fs/nilfs2/btnode.c:59
> Code: 8e 48 89 da e8 85 25 73 01 e9 a7 fd ff ff e8 cb d2 28 fe eb 0c e8 c4 d2 28 fe eb 05 e8 bd d2 28 fe 4c 89 ef e8 35 00 00 00 90 <0f> 0b e8 ad d2 28 fe 4c 89 f7 48 c7 c6 40 f2 06 8c e8 8e c0 6f fe
> RSP: 0000:ffffc90004f1f270 EFLAGS: 00010202
> RAX: ffffffff821b2801 RBX: 0000000000000010 RCX: ffffffff821b2819
> RDX: 0000000000000001 RSI: 0000000000000004 RDI: ffff88807746f5d0
> RBP: 0000000000001cc3 R08: ffff88807746f5d3 R09: 1ffff1100ee8deba
> R10: dffffc0000000000 R11: ffffed100ee8debb R12: dffffc0000000000
> R13: ffff88807746f570 R14: 1ffff1100ee8deae R15: ffff88805e399490
> FS: 0000000000000000(0000) GS:ffff8880b9500000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00007fdd25186000 CR3: 000000007a728000 CR4: 00000000003506f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
> <TASK>
> nilfs_btnode_prepare_change_key+0x26d/0x300 fs/nilfs2/btnode.c:219
> nilfs_btree_prepare_update_v+0x397/0x450 fs/nilfs2/btree.c:1942
> nilfs_btree_prepare_propagate_v fs/nilfs2/btree.c:2001 [inline]
> nilfs_btree_propagate_v fs/nilfs2/btree.c:2054 [inline]
> nilfs_btree_propagate+0x3bf/0xdf0 fs/nilfs2/btree.c:2111
> nilfs_bmap_propagate+0x75/0x120 fs/nilfs2/bmap.c:345
> nilfs_segctor_apply_buffers+0x184/0x340 fs/nilfs2/segment.c:1006
> nilfs_segctor_scan_file+0x810/0xa50 fs/nilfs2/segment.c:1066
> nilfs_segctor_collect_blocks fs/nilfs2/segment.c:1164 [inline]
> nilfs_segctor_collect fs/nilfs2/segment.c:1492 [inline]
> nilfs_segctor_do_construct+0x1c43/0x6b50 fs/nilfs2/segment.c:2040
> nilfs_segctor_construct+0x181/0x6b0 fs/nilfs2/segment.c:2408
> nilfs_segctor_thread_construct fs/nilfs2/segment.c:2516 [inline]
> nilfs_segctor_thread+0x55c/0x11b0 fs/nilfs2/segment.c:2601
> kthread+0x2f0/0x390 kernel/kthread.c:389
> ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
> ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
> </TASK>
> Modules linked in:
> ---[ end trace 0000000000000000 ]---
> RIP: 0010:nilfs_btnode_create_block+0x3dc/0x400 fs/nilfs2/btnode.c:59
> Code: 8e 48 89 da e8 85 25 73 01 e9
>
>
> ---
> 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@xxxxxxxxxxxxxxxx.
>
> 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 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

Looking at the call trace, it looks like in
nilfs_btnode_create_block(), the buffer obtained by
nilfs_grab_buffer() is in an unexpected state, triggering a BUG() that
remains there.

If the abnormal state is reproducible when given a corrupted
filesystem image (which I suspect it is), it should be rewritten to
return an appropriate error, or at least handled with WARN_ON() or
WARN_ON_ONCE() if it is caused by some other bug.

Once syzbot finds the reproducer, this will become clearer.

Ryusuke Konishi