Re: [syzbot] [btrfs?] kernel BUG in __extent_writepage_io (2)

syzbot
2024-08-29T09:30:03Z

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
general protection fault in try_merge_map

em: ffff88802539cdc8, blockstart: 18446744073709551613, start: 0, len: 503808, btrfs_get_extent
em: ffff88802539cdc8, blockstart: 18446744073709551613, em refs: 1, add_extent_mapping
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000005: 0000 [#1] PREEMPT SMP KASAN PTI
KASAN: null-ptr-deref in range [0x0000000000000028-0x000000000000002f]
CPU: 1 UID: 0 PID: 6499 Comm: syz.4.24 Not tainted 6.11.0-rc5-syzkaller-00081-gd5d547aa7b51-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
RIP: 0010:extent_map_block_start fs/btrfs/extent_map.h:154 [inline]
RIP: 0010:try_merge_map+0x684/0x8e0 fs/btrfs/extent_map.c:387
Code: 19 e8 a0 f9 e1 fd 48 8b 2c 24 eb 0e e8 95 f9 e1 fd 48 8b 2c 24 4c 8b 64 24 10 48 83 c5 28 48 89 e8 48 c1 e8 03 48 89 44 24 20 <42> 80 3c 38 00 74 08 48 89 ef e8 4d 16 46 fe 48 89 6c 24 18 48 8b
RSP: 0018:ffffc90008e8f2c0 EFLAGS: 00010206
RAX: 0000000000000005 RBX: ffff88802539cdc8 RCX: ffff88802b4e0000
RDX: 0000000000000000 RSI: fffffffffffffffd RDI: fffffffffffffffc
RBP: 0000000000000028 R08: ffffffff83b19139 R09: 1ffff11004a739c3
R10: dffffc0000000000 R11: ffffed1004a739c4 R12: fffffffffffffffd
R13: ffff88802539ce18 R14: 1ffff11004a739c3 R15: dffffc0000000000
FS: 00007f6c742e86c0(0000) GS:ffff8880b9300000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f6c742e7f98 CR3: 00000000221cc000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
setup_extent_mapping fs/btrfs/extent_map.c:467 [inline]
add_extent_mapping+0x604/0xa50 fs/btrfs/extent_map.c:500
btrfs_add_extent_mapping+0x10e/0x7b0 fs/btrfs/extent_map.c:712
btrfs_get_extent+0x124b/0x1d30 fs/btrfs/inode.c:6962
btrfs_cont_expand+0x28f/0xcd0 fs/btrfs/inode.c:4923
btrfs_write_check+0x440/0x590 fs/btrfs/file.c:1181
btrfs_direct_write+0x2f1/0xb40 fs/btrfs/direct-io.c:818
btrfs_do_write_iter+0x2a1/0x760 fs/btrfs/file.c:1505
do_iter_readv_writev+0x60a/0x890
vfs_writev+0x37c/0xbb0 fs/read_write.c:971
do_pwritev fs/read_write.c:1072 [inline]
__do_sys_pwritev2 fs/read_write.c:1131 [inline]
__se_sys_pwritev2+0x1ca/0x2d0 fs/read_write.c:1122
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f6c73579e79
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f6c742e8038 EFLAGS: 00000246 ORIG_RAX: 0000000000000148
RAX: ffffffffffffffda RBX: 00007f6c73716058 RCX: 00007f6c73579e79
RDX: 0000000000000001 RSI: 0000000020000240 RDI: 0000000000000004
RBP: 00007f6c735e793e R08: 0000000000000000 R09: 0000000000000003
R10: 0000000000002000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f6c73716058 R15: 00007ffed77574b8
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:extent_map_block_start fs/btrfs/extent_map.h:154 [inline]
RIP: 0010:try_merge_map+0x684/0x8e0 fs/btrfs/extent_map.c:387
Code: 19 e8 a0 f9 e1 fd 48 8b 2c 24 eb 0e e8 95 f9 e1 fd 48 8b 2c 24 4c 8b 64 24 10 48 83 c5 28 48 89 e8 48 c1 e8 03 48 89 44 24 20 <42> 80 3c 38 00 74 08 48 89 ef e8 4d 16 46 fe 48 89 6c 24 18 48 8b
RSP: 0018:ffffc90008e8f2c0 EFLAGS: 00010206
RAX: 0000000000000005 RBX: ffff88802539cdc8 RCX: ffff88802b4e0000
RDX: 0000000000000000 RSI: fffffffffffffffd RDI: fffffffffffffffc
RBP: 0000000000000028 R08: ffffffff83b19139 R09: 1ffff11004a739c3
R10: dffffc0000000000 R11: ffffed1004a739c4 R12: fffffffffffffffd
R13: ffff88802539ce18 R14: 1ffff11004a739c3 R15: dffffc0000000000
FS: 00007f6c742e86c0(0000) GS:ffff8880b9300000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f6c742e7f98 CR3: 00000000221cc000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess), 1 bytes skipped:
0: e8 a0 f9 e1 fd call 0xfde1f9a5
5: 48 8b 2c 24 mov (%rsp),%rbp
9: eb 0e jmp 0x19
b: e8 95 f9 e1 fd call 0xfde1f9a5
10: 48 8b 2c 24 mov (%rsp),%rbp
14: 4c 8b 64 24 10 mov 0x10(%rsp),%r12
19: 48 83 c5 28 add $0x28,%rbp
1d: 48 89 e8 mov %rbp,%rax
20: 48 c1 e8 03 shr $0x3,%rax
24: 48 89 44 24 20 mov %rax,0x20(%rsp)
* 29: 42 80 3c 38 00 cmpb $0x0,(%rax,%r15,1) <-- trapping instruction
2e: 74 08 je 0x38
30: 48 89 ef mov %rbp,%rdi
33: e8 4d 16 46 fe call 0xfe461685
38: 48 89 6c 24 18 mov %rbp,0x18(%rsp)
3d: 48 rex.W
3e: 8b .byte 0x8b

Tested on:

commit: d5d547aa Merge tag 'random-6.11-rc6-for-linus' of git:..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1162fc35980000
kernel config: https://syzkaller.appspot.com/x/.config?x=a0455552d0b27491
dashboard link: https://syzkaller.appspot.com/bug?extid=ba3c0273042a898c230e
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=1166fa0b980000