Re: [syzbot] [btrfs?] kernel BUG in __set_extent_bit

From: David Sterba
Date: Thu May 16 2024 - 11:15:38 EST


On Wed, Jan 11, 2023 at 02:51:47AM -0800, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 358a161a6a9e Merge branch 'for-next/fixes' into for-kernelci
> git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
> console output: https://syzkaller.appspot.com/x/log.txt?x=12115e1c480000
> kernel config: https://syzkaller.appspot.com/x/.config?x=2573056c6a11f00d
> dashboard link: https://syzkaller.appspot.com/bug?extid=89700d262ed1fb9f9351
> compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
> userspace arch: arm64
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13abc0a6480000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1153e53c480000
>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/99d14e0f4c19/disk-358a161a.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/23275b612976/vmlinux-358a161a.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/ed79195fac61/Image-358a161a.gz.xz
> mounted in repro: https://storage.googleapis.com/syzbot-assets/fdb7b054a0c8/mount_0.gz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+89700d262ed1fb9f9351@xxxxxxxxxxxxxxxxxxxxxxxxx
>
> __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
> invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
> el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
> do_el0_svc+0x48/0x140 arch/arm64/kernel/syscall.c:197
> el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:637
> el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
> el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:584
> ------------[ cut here ]------------
> kernel BUG at fs/btrfs/extent-io-tree.c:379!

set_state_bits()

ret = add_extent_changeset(state, bits_to_set, changeset, 1);
BUG_ON(ret < 0);
state->state |= bits_to_set;

ret is -ENOMEM (returned in register x1), known problem in general in
the state helpers everywhere, it's hard to fix as there's little change
of rollback.