syzbot


general protection fault in btrfs_finish_ordered_extent

Status: fixed on 2023/10/12 12:47
Subsystems: btrfs
[Documentation on labels]
Reported-by: syzbot+5b82f0e951f8c2bcdb8f@syzkaller.appspotmail.com
Fix commit: 7cad645ebf20 btrfs: fix ordered extent split error handling in btrfs_dio_submit_io
First crash: 235d, last: 230d
Cause bisection: introduced by (bisect log) :
commit b41b6f6937dc89e072b334e8d814487cb4692770
Author: Christoph Hellwig <hch@lst.de>
Date: Wed May 31 07:54:09 2023 +0000

  btrfs: use btrfs_finish_ordered_extent to complete direct writes

Crash: BUG: unable to handle kernel NULL pointer dereference in btrfs_finish_ordered_extent (log)
Repro: C syz .config
  
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [btrfs?] general protection fault in btrfs_finish_ordered_extent 0 (2) 2023/07/14 01:43
Last patch testing requests (1)
Created Duration User Patch Repo Result
2023/07/14 07:43 40m hch@lst.de git://git.infradead.org/users/hch/misc.git btrfs-btrfs_dio_submit_io-err-handling OK log

Sample crash report:
RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000008
R10: 0000000000004000 R11: 0000000000000246 R12: 00007ffee9c289bc
R13: 0000000000000002 R14: 431bde82d7b634db R15: 00007ffee9c28a00
 </TASK>
BTRFS warning (device loop0): direct IO failed ino 263 op 0x8801 offset 0x4000 len 4096 err no 9
general protection fault, probably for non-canonical address 0xdffffc000000000c: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000060-0x0000000000000067]
CPU: 0 PID: 5072 Comm: syz-executor267 Not tainted 6.5.0-rc1-syzkaller-00152-g4b810bf037e5 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/03/2023
RIP: 0010:btrfs_finish_ordered_extent+0x3c/0x2a0 fs/btrfs/ordered-data.c:375
Code: 55 44 89 c5 53 48 89 fb 48 83 ec 08 48 89 34 24 e8 39 d7 0c fe 48 8d 7b 60 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 33 02 00 00 4c 8b 6b 60 40 0f b6 ed 0f 1f 44 00
RSP: 0018:ffffc90003c1f4b8 EFLAGS: 00010216
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 000000000000000c RSI: ffffffff83799767 RDI: 0000000000000060
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000009 R11: 0000000000000001 R12: ffff88802999c100
R13: 0000000000004000 R14: 0000000000004000 R15: 0000000000001000
FS:  0000555555fee380(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f4acf86c100 CR3: 0000000023465000 CR4: 0000000000350ef0
Call Trace:
 <TASK>
 btrfs_dio_end_io+0x235/0x4b0 fs/btrfs/inode.c:7810
 btrfs_dio_submit_io+0x454/0x720 fs/btrfs/inode.c:7853
 iomap_dio_submit_bio+0x194/0x210 fs/iomap/direct-io.c:75
 iomap_dio_bio_iter+0x7ac/0x1460 fs/iomap/direct-io.c:347
 iomap_dio_iter fs/iomap/direct-io.c:430 [inline]
 __iomap_dio_rw+0xd10/0x1da0 fs/iomap/direct-io.c:575
 btrfs_dio_write+0xb1/0xe0 fs/btrfs/inode.c:7884
 btrfs_direct_write fs/btrfs/file.c:1526 [inline]
 btrfs_do_write_iter+0x995/0x11a0 fs/btrfs/file.c:1667
 call_write_iter include/linux/fs.h:1871 [inline]
 do_iter_readv_writev+0x21e/0x3c0 fs/read_write.c:735
 do_iter_write+0x17f/0x830 fs/read_write.c:860
 vfs_writev+0x221/0x700 fs/read_write.c:933
 do_pwritev+0x1af/0x260 fs/read_write.c:1030
 __do_sys_pwritev2 fs/read_write.c:1089 [inline]
 __se_sys_pwritev2 fs/read_write.c:1080 [inline]
 __x64_sys_pwritev2+0xef/0x150 fs/read_write.c:1080
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f4acf7ef329
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 21 18 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffee9c28988 EFLAGS: 00000246 ORIG_RAX: 0000000000000148
RAX: ffffffffffffffda RBX: 00007ffee9c289c0 RCX: 00007f4acf7ef329
RDX: 0000000000000002 RSI: 0000000020000240 RDI: 0000000000000005
RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000008
R10: 0000000000004000 R11: 0000000000000246 R12: 00007ffee9c289bc
R13: 0000000000000002 R14: 431bde82d7b634db R15: 00007ffee9c28a00
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:btrfs_finish_ordered_extent+0x3c/0x2a0 fs/btrfs/ordered-data.c:375
Code: 55 44 89 c5 53 48 89 fb 48 83 ec 08 48 89 34 24 e8 39 d7 0c fe 48 8d 7b 60 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 33 02 00 00 4c 8b 6b 60 40 0f b6 ed 0f 1f 44 00
RSP: 0018:ffffc90003c1f4b8 EFLAGS: 00010216
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 000000000000000c RSI: ffffffff83799767 RDI: 0000000000000060
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000009 R11: 0000000000000001 R12: ffff88802999c100
R13: 0000000000004000 R14: 0000000000004000 R15: 0000000000001000
FS:  0000555555fee380(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f4acf86c100 CR3: 0000000023465000 CR4: 0000000000350ef0
----------------
Code disassembly (best guess):
   0:	55                   	push   %rbp
   1:	44 89 c5             	mov    %r8d,%ebp
   4:	53                   	push   %rbx
   5:	48 89 fb             	mov    %rdi,%rbx
   8:	48 83 ec 08          	sub    $0x8,%rsp
   c:	48 89 34 24          	mov    %rsi,(%rsp)
  10:	e8 39 d7 0c fe       	call   0xfe0cd74e
  15:	48 8d 7b 60          	lea    0x60(%rbx),%rdi
  19:	48 b8 00 00 00 00 00 	movabs $0xdffffc0000000000,%rax
  20:	fc ff df
  23:	48 89 fa             	mov    %rdi,%rdx
  26:	48 c1 ea 03          	shr    $0x3,%rdx
* 2a:	80 3c 02 00          	cmpb   $0x0,(%rdx,%rax,1) <-- trapping instruction
  2e:	0f 85 33 02 00 00    	jne    0x267
  34:	4c 8b 6b 60          	mov    0x60(%rbx),%r13
  38:	40 0f b6 ed          	movzbl %bpl,%ebp
  3c:	0f                   	.byte 0xf
  3d:	1f                   	(bad)
  3e:	44                   	rex.R

Crashes (8):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/07/14 16:24 upstream 4b810bf037e5 d624500f .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci-upstream-kasan-badwrites-root general protection fault in btrfs_finish_ordered_extent
2023/07/14 15:31 upstream 4b810bf037e5 d624500f .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci-upstream-kasan-badwrites-root general protection fault in btrfs_finish_ordered_extent
2023/07/11 02:32 upstream 3f01e9fed845 d47e94ee .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-upstream-fs general protection fault in btrfs_finish_ordered_extent
2023/07/11 01:07 upstream 3f01e9fed845 d47e94ee .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-upstream-fs general protection fault in btrfs_finish_ordered_extent
2023/07/09 18:15 upstream 1c7873e33645 668cb1fa .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci-upstream-kasan-gce-selinux-root general protection fault in btrfs_finish_ordered_extent
2023/07/09 17:06 upstream 1c7873e33645 668cb1fa .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci-upstream-kasan-gce-root general protection fault in btrfs_finish_ordered_extent
2023/07/09 17:02 upstream 1c7873e33645 668cb1fa .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root general protection fault in btrfs_finish_ordered_extent
2023/07/09 16:48 upstream 1c7873e33645 668cb1fa .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root general protection fault in btrfs_finish_ordered_extent
* Struck through repros no longer work on HEAD.