syzbot


KASAN: null-ptr-deref Write in __drop_extent_tree

Status: upstream: reported C repro on 2023/05/20 17:57
Bug presence: origin:upstream
Labels: missing-backport
[Documentation on labels]
Reported-by: syzbot+83fc2c742f2ef6bab8ce@syzkaller.appspotmail.com
First crash: 342d, last: 27d
Cause bisection: introduced by (bisect log) :
commit 5ce7de6415c02b5d02731c7b2f27ba10ad566c1a
Author: Jaegeuk Kim <jaegeuk@kernel.org>
Date: Fri Dec 2 21:51:09 2022 +0000

  f2fs: allocate the extent_cache by default

Crash: KASAN: null-ptr-deref Write in f2fs_drop_extent_tree (log)
Repro: C syz .config
  
Bug presence (4)
Date Name Commit Repro Result
2023/07/08 android14-6.1 (ToT) 0a2e9dd65c6b C [report] KASAN: null-ptr-deref Write in __drop_extent_tree
2023/05/20 lts (merge base) b1644a0031cf C Didn't crash
2023/05/20 upstream (ToT) 0dd2a6fb1e34 C [report] KASAN: null-ptr-deref Write in __drop_extent_tree
2023/07/08 upstream (ToT) 8689f4f2ea56 C Didn't crash
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream general protection fault in __drop_extent_tree f2fs C error 3 342d 381d 23/26 fixed on 2023/10/12 12:48
Last patch testing requests (1)
Created Duration User Patch Repo Result
2023/09/16 10:08 10m retest repro android14-6.1 report log
Fix bisection attempts (7)
Created Duration User Patch Repo Result
2024/03/30 12:50 1h27m bisect fix android14-6.1 job log (0) log
2024/02/29 10:30 50m bisect fix android14-6.1 job log (0) log
2024/01/20 10:55 1h37m bisect fix android14-6.1 job log (0) log
2023/12/19 09:15 1h16m bisect fix android14-6.1 job log (0) log
2023/11/19 03:43 56m bisect fix android14-6.1 job log (0) log
2023/10/18 15:01 57m bisect fix android14-6.1 job log (0) log
2023/06/19 17:56 42m bisect fix android14-6.1 job log (0) log

Sample crash report:
==================================================================
BUG: KASAN: null-ptr-deref in instrument_atomic_read_write include/linux/instrumented.h:102 [inline]
BUG: KASAN: null-ptr-deref in atomic_try_cmpxchg_acquire include/linux/atomic/atomic-instrumented.h:541 [inline]
BUG: KASAN: null-ptr-deref in queued_write_lock include/asm-generic/qrwlock.h:98 [inline]
BUG: KASAN: null-ptr-deref in __raw_write_lock include/linux/rwlock_api_smp.h:210 [inline]
BUG: KASAN: null-ptr-deref in _raw_write_lock+0x97/0x170 kernel/locking/spinlock.c:300
Write of size 4 at addr 0000000000000030 by task syz-executor997/1845

CPU: 1 PID: 1845 Comm: syz-executor997 Not tainted 6.1.25-syzkaller-00258-gcffbdd825e02 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/28/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106
 print_report+0xe1/0x4e0 mm/kasan/report.c:398
 kasan_report+0x13c/0x170 mm/kasan/report.c:495
 kasan_check_range+0x294/0x2a0 mm/kasan/generic.c:189
 __kasan_check_write+0x14/0x20 mm/kasan/shadow.c:37
 instrument_atomic_read_write include/linux/instrumented.h:102 [inline]
 atomic_try_cmpxchg_acquire include/linux/atomic/atomic-instrumented.h:541 [inline]
 queued_write_lock include/asm-generic/qrwlock.h:98 [inline]
 __raw_write_lock include/linux/rwlock_api_smp.h:210 [inline]
 _raw_write_lock+0x97/0x170 kernel/locking/spinlock.c:300
 __drop_extent_tree+0x3db/0x680 fs/f2fs/extent_cache.c:1100
 f2fs_drop_extent_tree+0x17/0x30 fs/f2fs/extent_cache.c:1116
 f2fs_insert_range+0x455/0x560 fs/f2fs/file.c:1664
 f2fs_fallocate+0x502/0x770 fs/f2fs/file.c:1838
 vfs_fallocate+0x492/0x570 fs/open.c:324
 ksys_fallocate fs/open.c:347 [inline]
 __do_sys_fallocate fs/open.c:355 [inline]
 __se_sys_fallocate fs/open.c:353 [inline]
 __x64_sys_fallocate+0xc0/0x110 fs/open.c:353
 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:0x7faf27fddbb9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 61 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:00007faf27f81208 EFLAGS: 00000246 ORIG_RAX: 000000000000011d
RAX: ffffffffffffffda RBX: 00007faf28060788 RCX: 00007faf27fddbb9
RDX: 0000000000000000 RSI: 0000000000000020 RDI: 0000000000000005
RBP: 00007faf28060780 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000010000 R11: 0000000000000246 R12: 00007faf2806078c
R13: 00007ffd07795a3f R14: 00007faf27f81300 R15: 0000000000022000
 </TASK>
==================================================================
BUG: kernel NULL pointer dereference, address: 0000000000000030
#PF: supervisor write access in kernel mode
#PF: error_code(0x0002) - not-present page
PGD 109bf9067 P4D 109bf9067 PUD 122011067 PMD 0 
Oops: 0002 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 1845 Comm: syz-executor997 Tainted: G    B              6.1.25-syzkaller-00258-gcffbdd825e02 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/28/2023
RIP: 0010:atomic_try_cmpxchg_acquire include/linux/atomic/atomic-instrumented.h:543 [inline]
RIP: 0010:queued_write_lock include/asm-generic/qrwlock.h:98 [inline]
RIP: 0010:__raw_write_lock include/linux/rwlock_api_smp.h:210 [inline]
RIP: 0010:_raw_write_lock+0xb6/0x170 kernel/locking/spinlock.c:300
Code: ef be 04 00 00 00 e8 79 b9 ae fc 4c 89 ff be 04 00 00 00 e8 6c b9 ae fc 43 0f b6 04 26 84 c0 75 7d 8b 44 24 20 b9 ff 00 00 00 <f0> 41 0f b1 4d 00 75 33 48 c7 04 24 0e 36 e0 45 49 c7 04 1c 00 00
RSP: 0018:ffffc90004307be0 EFLAGS: 00010297
RAX: 0000000000000000 RBX: 1ffff92000860f7c RCX: 00000000000000ff
RDX: 0000000000000001 RSI: 0000000000000004 RDI: ffffc90004307c00
RBP: ffffc90004307c78 R08: dffffc0000000000 R09: 0000000000000003
R10: ffffffffffffffff R11: dffffc0000000001 R12: dffffc0000000000
R13: 0000000000000030 R14: 1ffff92000860f80 R15: ffffc90004307c00
FS:  00007faf27f81700(0000) GS:ffff8881f7100000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000030 CR3: 000000011aa03000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 __drop_extent_tree+0x3db/0x680 fs/f2fs/extent_cache.c:1100
 f2fs_drop_extent_tree+0x17/0x30 fs/f2fs/extent_cache.c:1116
 f2fs_insert_range+0x455/0x560 fs/f2fs/file.c:1664
 f2fs_fallocate+0x502/0x770 fs/f2fs/file.c:1838
 vfs_fallocate+0x492/0x570 fs/open.c:324
 ksys_fallocate fs/open.c:347 [inline]
 __do_sys_fallocate fs/open.c:355 [inline]
 __se_sys_fallocate fs/open.c:353 [inline]
 __x64_sys_fallocate+0xc0/0x110 fs/open.c:353
 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:0x7faf27fddbb9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 61 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:00007faf27f81208 EFLAGS: 00000246 ORIG_RAX: 000000000000011d
RAX: ffffffffffffffda RBX: 00007faf28060788 RCX: 00007faf27fddbb9
RDX: 0000000000000000 RSI: 0000000000000020 RDI: 0000000000000005
RBP: 00007faf28060780 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000010000 R11: 0000000000000246 R12: 00007faf2806078c
R13: 00007ffd07795a3f R14: 00007faf27f81300 R15: 0000000000022000
 </TASK>
Modules linked in:
CR2: 0000000000000030
---[ end trace 0000000000000000 ]---
RIP: 0010:atomic_try_cmpxchg_acquire include/linux/atomic/atomic-instrumented.h:543 [inline]
RIP: 0010:queued_write_lock include/asm-generic/qrwlock.h:98 [inline]
RIP: 0010:__raw_write_lock include/linux/rwlock_api_smp.h:210 [inline]
RIP: 0010:_raw_write_lock+0xb6/0x170 kernel/locking/spinlock.c:300
Code: ef be 04 00 00 00 e8 79 b9 ae fc 4c 89 ff be 04 00 00 00 e8 6c b9 ae fc 43 0f b6 04 26 84 c0 75 7d 8b 44 24 20 b9 ff 00 00 00 <f0> 41 0f b1 4d 00 75 33 48 c7 04 24 0e 36 e0 45 49 c7 04 1c 00 00
RSP: 0018:ffffc90004307be0 EFLAGS: 00010297
RAX: 0000000000000000 RBX: 1ffff92000860f7c RCX: 00000000000000ff
RDX: 0000000000000001 RSI: 0000000000000004 RDI: ffffc90004307c00
RBP: ffffc90004307c78 R08: dffffc0000000000 R09: 0000000000000003
R10: ffffffffffffffff R11: dffffc0000000001 R12: dffffc0000000000
R13: 0000000000000030 R14: 1ffff92000860f80 R15: ffffc90004307c00
FS:  00007faf27f81700(0000) GS:ffff8881f7100000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000030 CR3: 000000011aa03000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
   0:	ef                   	out    %eax,(%dx)
   1:	be 04 00 00 00       	mov    $0x4,%esi
   6:	e8 79 b9 ae fc       	callq  0xfcaeb984
   b:	4c 89 ff             	mov    %r15,%rdi
   e:	be 04 00 00 00       	mov    $0x4,%esi
  13:	e8 6c b9 ae fc       	callq  0xfcaeb984
  18:	43 0f b6 04 26       	movzbl (%r14,%r12,1),%eax
  1d:	84 c0                	test   %al,%al
  1f:	75 7d                	jne    0x9e
  21:	8b 44 24 20          	mov    0x20(%rsp),%eax
  25:	b9 ff 00 00 00       	mov    $0xff,%ecx
* 2a:	f0 41 0f b1 4d 00    	lock cmpxchg %ecx,0x0(%r13) <-- trapping instruction
  30:	75 33                	jne    0x65
  32:	48 c7 04 24 0e 36 e0 	movq   $0x45e0360e,(%rsp)
  39:	45
  3a:	49                   	rex.WB
  3b:	c7                   	.byte 0xc7
  3c:	04 1c                	add    $0x1c,%al

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/05/20 17:55 android14-6.1 cffbdd825e02 4bce1a3e .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-android-6-1 KASAN: null-ptr-deref Write in __drop_extent_tree
* Struck through repros no longer work on HEAD.