Re: [syzbot] kernel BUG in __clear_extent_bit

From: Dmitry Vyukov
Date: Fri Dec 02 2022 - 05:43:13 EST


On Thu, 1 Dec 2022 at 23:48, Pawel Suchanecki <subdcc@xxxxxxxxx> wrote:
>
>
>> Hello,
>>
>> syzbot found the following issue on:
>>
>> HEAD commit: c3eb11fbb826 Merge tag 'pci-v6.1-fixes-3' of git://git.ker..
>> git tree: upstream
>> console+strace: https://syzkaller.appspot.com/x/log.txt?x=1675aebb880000
>> kernel config: https://syzkaller.appspot.com/x/.config?x=8d01b6e3197974dd
>> dashboard link: https://syzkaller.appspot.com/bug?extid=5338ef8374ed180ba281
>> compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
>> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=103324e3880000
>> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12e7e1c9880000
>>
>> Downloadable assets:
>> disk image: https://storage.googleapis.com/syzbot-assets/d81ac029767f/disk-c3eb11fb.raw.xz
>> vmlinux: https://storage.googleapis.com/syzbot-assets/b68346b5b73c/vmlinux-c3eb11fb.xz
>> kernel image: https://storage.googleapis.com/syzbot-assets/410a61724587/bzImage-c3eb11fb.xz
>> mounted in repro: https://storage.googleapis.com/syzbot-assets/c27a26bacb83/mount_0.gz
>>
>> IMPORTANT: if you fix the issue, please add the following tag to the commit:
>> Reported-by: syzbot+5338ef...@xxxxxxxxxxxxxxxxxxxxxxxxx
>>
>> ------------[ cut here ]------------
>> kernel BUG at fs/btrfs/extent-io-tree.c:639!
>> invalid opcode: 0000 [#1] PREEMPT SMP KASAN
>> CPU: 0 PID: 3632 Comm: syz-executor118 Not tainted 6.1.0-rc6-syzkaller-00015-gc3eb11fbb826 #0
>> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
>> RIP: 0010:__clear_extent_bit+0xbbb/0xc60 fs/btrfs/extent-io-tree.c:639
>> Code: 1c 2f fe e9 cf fe ff ff 89 e9 80 e1 07 80 c1 03 38 c1 0f 8c 0e ff ff ff 48 89 ef e8 5f 1c 2f fe e9 01 ff ff ff e8 05 04 db fd <0f> 0b e8 fe 03 db fd 48 8b 44 24 08 48 83 c0 08 48 89 c5 48 c1 e8
>> RSP: 0018:ffffc90003c7f7a8 EFLAGS: 00010293
>> RAX: ffffffff83af946b RBX: 0000000000000000 RCX: ffff88807de80000
>> RDX: 0000000000000000 RSI: ffffffff8aedc420 RDI: ffffffff8b4b3ae0
>> RBP: 0000000000002fff R08: 00000000ffffffff R09: fffffbfff1a42e97
>> R10: fffffbfff1a42e97 R11: 1ffffffff1a42e96 R12: 000000000004ffff
>> R13: ffff88807eb05b40 R14: 1ffff1100fd60b68 R15: 0000000000002000
>> FS: 0000555557044300(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
>> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>> CR2: 0000000020002000 CR3: 000000007e9f2000 CR4: 00000000003506f0
>> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
>> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
>> Call Trace:
>> <TASK>
>> try_release_extent_state fs/btrfs/extent_io.c:3391 [inline]
>> try_release_extent_mapping+0x4e5/0x560 fs/btrfs/extent_io.c:3487
>> __btrfs_release_folio fs/btrfs/inode.c:8175 [inline]
>> btrfs_release_folio+0x126/0x340 fs/btrfs/inode.c:8188
>> mapping_evict_folio+0x24d/0x570 mm/truncate.c:279
>> invalidate_mapping_pagevec+0x37d/0x7c0 mm/truncate.c:528
>> btrfs_direct_write fs/btrfs/file.c:1917 [inline]
>> btrfs_do_write_iter+0x112e/0x1260 fs/btrfs/file.c:1980
>> call_write_iter include/linux/fs.h:2191 [inline]
>> new_sync_write fs/read_write.c:491 [inline]
>> vfs_write+0x7dc/0xc50 fs/read_write.c:584
>> ksys_write+0x177/0x2a0 fs/read_write.c:637
>> do_syscall_x64 arch/x86/entry/common.c:50 [inline]
>> do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
>> entry_SYSCALL_64_after_hwframe+0x63/0xcd
>> RIP: 0033:0x7fcc98e18a19
>> Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 11 15 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
>> RSP: 002b:00007fffcb04cad8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
>> RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007fcc98e18a19
>> RDX: 0000000000000004 RSI: 0000000020000000 RDI: 0000000000000004
>> RBP: 00007fffcb04cb00 R08: 0000000000000002 R09: 00007fffcb04cb10
>> R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000005
>> R13: 00007fffcb04cb40 R14: 00007fffcb04cb20 R15: 0000000000000000
>> </TASK>
>> Modules linked in:
>> ---[ end trace 0000000000000000 ]---
>> RIP: 0010:__clear_extent_bit+0xbbb/0xc60 fs/btrfs/extent-io-tree.c:639
>> Code: 1c 2f fe e9 cf fe ff ff 89 e9 80 e1 07 80 c1 03 38 c1 0f 8c 0e ff ff ff 48 89 ef e8 5f 1c 2f fe e9 01 ff ff ff e8 05 04 db fd <0f> 0b e8 fe 03 db fd 48 8b 44 24 08 48 83 c0 08 48 89 c5 48 c1 e8
>> RSP: 0018:ffffc90003c7f7a8 EFLAGS: 00010293
>> RAX: ffffffff83af946b RBX: 0000000000000000 RCX: ffff88807de80000
>> RDX: 0000000000000000 RSI: ffffffff8aedc420 RDI: ffffffff8b4b3ae0
>> RBP: 0000000000002fff R08: 00000000ffffffff R09: fffffbfff1a42e97
>> R10: fffffbfff1a42e97 R11: 1ffffffff1a42e96 R12: 000000000004ffff
>> R13: ffff88807eb05b40 R14: 1ffff1100fd60b68 R15: 0000000000002000
>> FS: 0000555557044300(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
>> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>> CR2: 0000000020002000 CR3: 000000007e9f2000 CR4: 00000000003506f0
>> 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 syzk...@xxxxxxxxxxxxxxxx.
>>
>> syzbot will keep track of this issue. See:
>> https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
>> syzbot can test patches for this issue, for details see:
>> https://goo.gl/tpsmEJ#testing-patches
>
>
> Hi,
>
> This bug is to be fixed by recently published patch by Josef Bacik, named: [PATCH 3/3] btrfs: do not panic if we can't allocate a prealloc extent state [1].
>
> [1] https://lore.kernel.org/all/97fb0828deb341efe99ef2bc35cda0eccc5963de.1665755095.git.josef@xxxxxxxxxxxxxx
>
> Thanks,
> Pawel

Let's tell syzbot about the fix so that it reports similar bugs in future:

#syz fix:
btrfs: do not panic if we can't allocate a prealloc extent state