syzbot


KASAN: null-ptr-deref Write in f2fs_stop_discard_thread

Status: fixed on 2023/02/02 00:40
Subsystems: f2fs
[Documentation on labels]
Reported-by: syzbot+6f453ac99ae7f152b7b3@syzkaller.appspotmail.com
Fix commit: 865bb7b5a7de f2fs: fix to invalidate dcc->f2fs_issue_discard in error path
First crash: 554d, last: 451d
Cause bisection: failed (error log, bisect log)
  
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream BUG: unable to handle kernel NULL pointer dereference in f2fs_stop_discard_thread f2fs C done 23 491d 557d 22/26 fixed on 2023/02/24 13:50
Last patch testing requests (1)
Created Duration User Patch Repo Result
2022/11/15 10:01 15m jun.nie@linaro.org patch android13-5.15-lts OK log

Sample crash report:
==================================================================
BUG: KASAN: null-ptr-deref in instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
BUG: KASAN: null-ptr-deref in atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:111 [inline]
BUG: KASAN: null-ptr-deref in __refcount_add include/linux/refcount.h:193 [inline]
BUG: KASAN: null-ptr-deref in __refcount_inc include/linux/refcount.h:250 [inline]
BUG: KASAN: null-ptr-deref in refcount_inc include/linux/refcount.h:267 [inline]
BUG: KASAN: null-ptr-deref in get_task_struct include/linux/sched/task.h:105 [inline]
BUG: KASAN: null-ptr-deref in kthread_stop+0x36/0x3c0 kernel/kthread.c:644
Write of size 4 at addr 000000000000001c by task syz-executor780/419

CPU: 0 PID: 419 Comm: syz-executor780 Not tainted 5.15.74-syzkaller-04383-g7f2e600bf63a #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/11/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106
 __kasan_report mm/kasan/report.c:439 [inline]
 kasan_report+0x19c/0x1f0 mm/kasan/report.c:452
 kasan_check_range+0x2aa/0x2e0 mm/kasan/generic.c:189
 __kasan_check_write+0x14/0x20 mm/kasan/shadow.c:37
 instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
 atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:111 [inline]
 __refcount_add include/linux/refcount.h:193 [inline]
 __refcount_inc include/linux/refcount.h:250 [inline]
 refcount_inc include/linux/refcount.h:267 [inline]
 get_task_struct include/linux/sched/task.h:105 [inline]
 kthread_stop+0x36/0x3c0 kernel/kthread.c:644
 f2fs_stop_discard_thread+0xa1/0xc0 fs/f2fs/segment.c:1761
 kill_f2fs_super+0xe0/0x3c0 fs/f2fs/super.c:4525
 deactivate_locked_super+0xb0/0x100 fs/super.c:335
 deactivate_super+0xa5/0xd0 fs/super.c:366
 cleanup_mnt+0x45f/0x510 fs/namespace.c:1143
 __cleanup_mnt+0x19/0x20 fs/namespace.c:1150
 task_work_run+0x147/0x1b0 kernel/task_work.c:164
 ptrace_notify+0x29a/0x340 kernel/signal.c:2382
 ptrace_report_syscall include/linux/tracehook.h:66 [inline]
 tracehook_report_syscall_exit include/linux/tracehook.h:130 [inline]
 arch_syscall_exit_tracehook include/linux/entry-common.h:297 [inline]
 syscall_exit_work+0x94/0x150 kernel/entry/common.c:255
 syscall_exit_to_user_mode_prepare kernel/entry/common.c:282 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:287 [inline]
 syscall_exit_to_user_mode+0x6c/0xc0 kernel/entry/common.c:300
 do_syscall_64+0x50/0xd0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7f58f059ebd7
Code: 07 00 48 83 c4 08 5b 5d c3 66 2e 0f 1f 84 00 00 00 00 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 a6 00 00 00 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:00007fffa701fcf8 EFLAGS: 00000202 ORIG_RAX: 00000000000000a6
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00007f58f059ebd7
RDX: 00007fffa701fdb9 RSI: 000000000000000a RDI: 00007fffa701fdb0
RBP: 00007fffa701fdb0 R08: 00000000ffffffff R09: 00007fffa701fb90
R10: 0000555556734653 R11: 0000000000000202 R12: 00007fffa7020e30
R13: 00005555567345f0 R14: 00007fffa701fd20 R15: 0000000000000002
 </TASK>
==================================================================
BUG: kernel NULL pointer dereference, address: 000000000000001c
#PF: supervisor write access in kernel mode
#PF: error_code(0x0002) - not-present page
PGD 0 P4D 0 
Oops: 0002 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 419 Comm: syz-executor780 Tainted: G    B             5.15.74-syzkaller-04383-g7f2e600bf63a #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/11/2022
RIP: 0010:atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:112 [inline]
RIP: 0010:__refcount_add include/linux/refcount.h:193 [inline]
RIP: 0010:__refcount_inc include/linux/refcount.h:250 [inline]
RIP: 0010:refcount_inc include/linux/refcount.h:267 [inline]
RIP: 0010:get_task_struct include/linux/sched/task.h:105 [inline]
RIP: 0010:kthread_stop+0x3b/0x3c0 kernel/kthread.c:644
Code: bd 00 00 00 00 00 fc ff df e8 61 cc 25 00 0f 1f 44 00 00 4d 8d 74 24 28 4c 89 f7 be 04 00 00 00 e8 0a 1b 68 00 bb 01 00 00 00 <f0> 41 0f c1 5c 24 28 31 ff 89 de e8 a5 d0 25 00 85 db 0f 84 33 01
RSP: 0018:ffffc9000038fb58 EFLAGS: 00010246
RAX: ffff888105f90000 RBX: 0000000000000001 RCX: 0000000000000001
RDX: 0000000000000000 RSI: 0000000000000292 RDI: 0000000000000001
RBP: ffffc9000038fb80 R08: ffffffff8142fa13 R09: fffffbfff0e4f8f5
R10: fffffbfff0e4f8f5 R11: 1ffffffff0e4f8f4 R12: fffffffffffffff4
R13: dffffc0000000000 R14: 000000000000001c R15: dffffc0000000000
FS:  0000555556733300(0000) GS:ffff8881f7100000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000000000001c CR3: 0000000107181000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 f2fs_stop_discard_thread+0xa1/0xc0 fs/f2fs/segment.c:1761
 kill_f2fs_super+0xe0/0x3c0 fs/f2fs/super.c:4525
 deactivate_locked_super+0xb0/0x100 fs/super.c:335
 deactivate_super+0xa5/0xd0 fs/super.c:366
 cleanup_mnt+0x45f/0x510 fs/namespace.c:1143
 __cleanup_mnt+0x19/0x20 fs/namespace.c:1150
 task_work_run+0x147/0x1b0 kernel/task_work.c:164
 ptrace_notify+0x29a/0x340 kernel/signal.c:2382
 ptrace_report_syscall include/linux/tracehook.h:66 [inline]
 tracehook_report_syscall_exit include/linux/tracehook.h:130 [inline]
 arch_syscall_exit_tracehook include/linux/entry-common.h:297 [inline]
 syscall_exit_work+0x94/0x150 kernel/entry/common.c:255
 syscall_exit_to_user_mode_prepare kernel/entry/common.c:282 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:287 [inline]
 syscall_exit_to_user_mode+0x6c/0xc0 kernel/entry/common.c:300
 do_syscall_64+0x50/0xd0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7f58f059ebd7
Code: 07 00 48 83 c4 08 5b 5d c3 66 2e 0f 1f 84 00 00 00 00 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 a6 00 00 00 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:00007fffa701fcf8 EFLAGS: 00000202 ORIG_RAX: 00000000000000a6
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00007f58f059ebd7
RDX: 00007fffa701fdb9 RSI: 000000000000000a RDI: 00007fffa701fdb0
RBP: 00007fffa701fdb0 R08: 00000000ffffffff R09: 00007fffa701fb90
R10: 0000555556734653 R11: 0000000000000202 R12: 00007fffa7020e30
R13: 00005555567345f0 R14: 00007fffa701fd20 R15: 0000000000000002
 </TASK>
Modules linked in:
CR2: 000000000000001c
---[ end trace 2726d20e06291262 ]---
RIP: 0010:atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:112 [inline]
RIP: 0010:__refcount_add include/linux/refcount.h:193 [inline]
RIP: 0010:__refcount_inc include/linux/refcount.h:250 [inline]
RIP: 0010:refcount_inc include/linux/refcount.h:267 [inline]
RIP: 0010:get_task_struct include/linux/sched/task.h:105 [inline]
RIP: 0010:kthread_stop+0x3b/0x3c0 kernel/kthread.c:644
Code: bd 00 00 00 00 00 fc ff df e8 61 cc 25 00 0f 1f 44 00 00 4d 8d 74 24 28 4c 89 f7 be 04 00 00 00 e8 0a 1b 68 00 bb 01 00 00 00 <f0> 41 0f c1 5c 24 28 31 ff 89 de e8 a5 d0 25 00 85 db 0f 84 33 01
RSP: 0018:ffffc9000038fb58 EFLAGS: 00010246
RAX: ffff888105f90000 RBX: 0000000000000001 RCX: 0000000000000001
RDX: 0000000000000000 RSI: 0000000000000292 RDI: 0000000000000001
RBP: ffffc9000038fb80 R08: ffffffff8142fa13 R09: fffffbfff0e4f8f5
R10: fffffbfff0e4f8f5 R11: 1ffffffff0e4f8f4 R12: fffffffffffffff4
R13: dffffc0000000000 R14: 000000000000001c R15: dffffc0000000000
FS:  0000555556733300(0000) GS:ffff8881f7100000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000000000001c CR3: 0000000107181000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
   0:	bd 00 00 00 00       	mov    $0x0,%ebp
   5:	00 fc                	add    %bh,%ah
   7:	ff                   	(bad)
   8:	df e8                	fucomip %st(0),%st
   a:	61                   	(bad)
   b:	cc                   	int3
   c:	25 00 0f 1f 44       	and    $0x441f0f00,%eax
  11:	00 00                	add    %al,(%rax)
  13:	4d 8d 74 24 28       	lea    0x28(%r12),%r14
  18:	4c 89 f7             	mov    %r14,%rdi
  1b:	be 04 00 00 00       	mov    $0x4,%esi
  20:	e8 0a 1b 68 00       	callq  0x681b2f
  25:	bb 01 00 00 00       	mov    $0x1,%ebx
* 2a:	f0 41 0f c1 5c 24 28 	lock xadd %ebx,0x28(%r12) <-- trapping instruction
  31:	31 ff                	xor    %edi,%edi
  33:	89 de                	mov    %ebx,%esi
  35:	e8 a5 d0 25 00       	callq  0x25d0df
  3a:	85 db                	test   %ebx,%ebx
  3c:	0f                   	.byte 0xf
  3d:	84 33                	test   %dh,(%rbx)
  3f:	01                   	.byte 0x1

Crashes (10):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/10/22 21:07 android13-5.15-lts 7f2e600bf63a c0b80a55 .config strace log report syz C [disk image] [vmlinux] [mounted in repro] ci2-android-5-15 KASAN: null-ptr-deref Write in f2fs_stop_discard_thread
2023/01/27 18:33 android13-5.15-lts d753150bdc01 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: null-ptr-deref Write in f2fs_stop_discard_thread
2022/11/27 02:44 android13-5.15-lts 4ec71a9ec769 f4470a7b .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: null-ptr-deref Write in f2fs_stop_discard_thread
2022/10/30 20:37 android13-5.15-lts 7f2e600bf63a 2a71366b .config console log report info [disk image] [vmlinux] ci2-android-5-15 KASAN: null-ptr-deref Write in f2fs_stop_discard_thread
2022/10/23 20:06 android13-5.15-lts 7f2e600bf63a 23bf86af .config console log report info ci2-android-5-15 KASAN: null-ptr-deref Write in f2fs_stop_discard_thread
2022/10/22 20:55 android13-5.15-lts 7f2e600bf63a c0b80a55 .config console log report info [disk image] [vmlinux] ci2-android-5-15 KASAN: null-ptr-deref Write in f2fs_stop_discard_thread
2022/10/21 22:34 android13-5.15-lts 7f2e600bf63a 63e790dd .config console log report info [disk image] [vmlinux] ci2-android-5-15 KASAN: null-ptr-deref Write in f2fs_stop_discard_thread
2022/10/21 21:37 android13-5.15-lts 7f2e600bf63a 63e790dd .config console log report info [disk image] [vmlinux] ci2-android-5-15 KASAN: null-ptr-deref Write in f2fs_stop_discard_thread
2022/10/20 12:59 android13-5.15-lts 7f2e600bf63a b31320fc .config console log report info [disk image] [vmlinux] ci2-android-5-15 KASAN: null-ptr-deref Write in f2fs_stop_discard_thread
2022/10/15 23:02 android13-5.15-lts 44b8b2ac1d96 67cb024c .config console log report info [disk image] [vmlinux] ci2-android-5-15 KASAN: null-ptr-deref Write in f2fs_stop_discard_thread
* Struck through repros no longer work on HEAD.