syzbot


KASAN: null-ptr-deref Write in hidraw_release

Status: auto-obsoleted due to no activity on 2023/10/30 10:32
Bug presence: origin:upstream
Labels: missing-backport
[Documentation on labels]
Reported-by: syzbot+d1541a0e06c700dc9e85@syzkaller.appspotmail.com
First crash: 324d, last: 265d
Cause bisection: failed (error log, bisect log)
  
Fix bisection: fixed by (bisect log) :
commit 0e477a82e6d9e013a7f26cba2a2012179d28ac74
Author: Ludvig Michaelsson <ludvig.michaelsson@yubico.com>
Date: Wed Jun 21 11:17:43 2023 +0000

  UPSTREAM: HID: hidraw: fix data race on device refcount

  
Bug presence (4)
Date Name Commit Repro Result
2023/07/22 android14-6.1 (ToT) d51e21b39415 C [report] KASAN: null-ptr-deref Write in hidraw_release
2023/06/07 lts (merge base) b1644a0031cf C [report] KASAN: null-ptr-deref Write in hidraw_release
2023/06/07 upstream (ToT) a4d7d7011219 C [report] KASAN: null-ptr-deref Write in hidraw_release
2023/07/22 upstream (ToT) d192f5382581 C Didn't crash
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream general protection fault in hidraw_release input C done unreliable 102 287d 829d 0/26 auto-obsoleted due to no activity on 2023/09/13 13:28
Fix bisection attempts (2)
Created Duration User Patch Repo Result
2023/09/22 01:38 4h04m bisect fix android14-6.1 job log (1)
2023/07/11 11:23 1h01m 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_spin_lock include/asm-generic/qspinlock.h:111 [inline]
BUG: KASAN: null-ptr-deref in do_raw_spin_lock include/linux/spinlock.h:186 [inline]
BUG: KASAN: null-ptr-deref in __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:111 [inline]
BUG: KASAN: null-ptr-deref in _raw_spin_lock_irqsave+0xec/0x210 kernel/locking/spinlock.c:162
Write of size 4 at addr 0000000000000038 by task syz-executor418/731

CPU: 0 PID: 731 Comm: syz-executor418 Not tainted 6.1.25-syzkaller-00355-g312dfb3b7ec3 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/25/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_spin_lock include/asm-generic/qspinlock.h:111 [inline]
 do_raw_spin_lock include/linux/spinlock.h:186 [inline]
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:111 [inline]
 _raw_spin_lock_irqsave+0xec/0x210 kernel/locking/spinlock.c:162
 hidraw_release+0xbe/0x600 drivers/hid/hidraw.c:352
 __fput+0x3ab/0x870 fs/file_table.c:320
 ____fput+0x15/0x20 fs/file_table.c:348
 task_work_run+0x24d/0x2e0 kernel/task_work.c:179
 ptrace_notify+0x29e/0x350 kernel/signal.c:2357
 ptrace_report_syscall include/linux/ptrace.h:420 [inline]
 ptrace_report_syscall_exit include/linux/ptrace.h:482 [inline]
 syscall_exit_work kernel/entry/common.c:252 [inline]
 syscall_exit_to_user_mode_prepare kernel/entry/common.c:279 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:284 [inline]
 syscall_exit_to_user_mode+0x9d/0x130 kernel/entry/common.c:297
 do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fd099ff55eb
Code: 0f 05 48 3d 00 f0 ff ff 77 45 c3 0f 1f 40 00 48 83 ec 18 89 7c 24 0c e8 63 fc ff ff 8b 7c 24 0c 41 89 c0 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 44 89 c7 89 44 24 0c e8 a1 fc ff ff 8b 44
RSP: 002b:00007ffdd6be49c0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000007 RCX: 00007fd099ff55eb
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000006
RBP: 0000000000000032 R08: 0000000000000000 R09: 00007ffdd6bf20b0
R10: 0000000000000000 R11: 0000000000000293 R12: 00007fd09a0bd4cc
R13: 0000000000013030 R14: 00007ffdd6be4a20 R15: 00007fd09a0bd4c0
 </TASK>
==================================================================
BUG: kernel NULL pointer dereference, address: 0000000000000038
#PF: supervisor write access in kernel mode
#PF: error_code(0x0002) - not-present page
PGD 111deb067 P4D 111deb067 PUD 125b3f067 PMD 0 
Oops: 0002 [#1] PREEMPT SMP KASAN
CPU: 0 PID: 731 Comm: syz-executor418 Tainted: G    B              6.1.25-syzkaller-00355-g312dfb3b7ec3 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/25/2023
RIP: 0010:atomic_try_cmpxchg_acquire include/linux/atomic/atomic-instrumented.h:543 [inline]
RIP: 0010:queued_spin_lock include/asm-generic/qspinlock.h:111 [inline]
RIP: 0010:do_raw_spin_lock include/linux/spinlock.h:186 [inline]
RIP: 0010:__raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:111 [inline]
RIP: 0010:_raw_spin_lock_irqsave+0x10f/0x210 kernel/locking/spinlock.c:162
Code: 00 00 e8 74 8a ae fc 4c 89 e7 be 04 00 00 00 e8 67 8a ae fc 42 0f b6 04 3b 84 c0 0f 85 be 00 00 00 8b 44 24 40 b9 01 00 00 00 <f0> 41 0f b1 4d 00 75 45 48 c7 44 24 20 0e 36 e0 45 4b c7 04 37 00
RSP: 0018:ffffc90003e2fb20 EFLAGS: 00010097
RAX: 0000000000000000 RBX: 1ffff920007c5f6c RCX: 0000000000000001
RDX: 0000000000000001 RSI: 0000000000000004 RDI: ffffc90003e2fb60
RBP: ffffc90003e2fbf8 R08: dffffc0000000000 R09: 0000000000000003
R10: ffffffffffffffff R11: dffffc0000000001 R12: ffffc90003e2fb60
R13: 0000000000000038 R14: 1ffff920007c5f68 R15: dffffc0000000000
FS:  00005555563c1400(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000038 CR3: 0000000113400000 CR4: 00000000003506b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 hidraw_release+0xbe/0x600 drivers/hid/hidraw.c:352
 __fput+0x3ab/0x870 fs/file_table.c:320
 ____fput+0x15/0x20 fs/file_table.c:348
 task_work_run+0x24d/0x2e0 kernel/task_work.c:179
 ptrace_notify+0x29e/0x350 kernel/signal.c:2357
 ptrace_report_syscall include/linux/ptrace.h:420 [inline]
 ptrace_report_syscall_exit include/linux/ptrace.h:482 [inline]
 syscall_exit_work kernel/entry/common.c:252 [inline]
 syscall_exit_to_user_mode_prepare kernel/entry/common.c:279 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:284 [inline]
 syscall_exit_to_user_mode+0x9d/0x130 kernel/entry/common.c:297
 do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fd099ff55eb
Code: 0f 05 48 3d 00 f0 ff ff 77 45 c3 0f 1f 40 00 48 83 ec 18 89 7c 24 0c e8 63 fc ff ff 8b 7c 24 0c 41 89 c0 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 44 89 c7 89 44 24 0c e8 a1 fc ff ff 8b 44
RSP: 002b:00007ffdd6be49c0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000007 RCX: 00007fd099ff55eb
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000006
RBP: 0000000000000032 R08: 0000000000000000 R09: 00007ffdd6bf20b0
R10: 0000000000000000 R11: 0000000000000293 R12: 00007fd09a0bd4cc
R13: 0000000000013030 R14: 00007ffdd6be4a20 R15: 00007fd09a0bd4c0
 </TASK>
Modules linked in:
CR2: 0000000000000038
---[ end trace 0000000000000000 ]---
RIP: 0010:atomic_try_cmpxchg_acquire include/linux/atomic/atomic-instrumented.h:543 [inline]
RIP: 0010:queued_spin_lock include/asm-generic/qspinlock.h:111 [inline]
RIP: 0010:do_raw_spin_lock include/linux/spinlock.h:186 [inline]
RIP: 0010:__raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:111 [inline]
RIP: 0010:_raw_spin_lock_irqsave+0x10f/0x210 kernel/locking/spinlock.c:162
Code: 00 00 e8 74 8a ae fc 4c 89 e7 be 04 00 00 00 e8 67 8a ae fc 42 0f b6 04 3b 84 c0 0f 85 be 00 00 00 8b 44 24 40 b9 01 00 00 00 <f0> 41 0f b1 4d 00 75 45 48 c7 44 24 20 0e 36 e0 45 4b c7 04 37 00
RSP: 0018:ffffc90003e2fb20 EFLAGS: 00010097
RAX: 0000000000000000 RBX: 1ffff920007c5f6c RCX: 0000000000000001
RDX: 0000000000000001 RSI: 0000000000000004 RDI: ffffc90003e2fb60
RBP: ffffc90003e2fbf8 R08: dffffc0000000000 R09: 0000000000000003
R10: ffffffffffffffff R11: dffffc0000000001 R12: ffffc90003e2fb60
R13: 0000000000000038 R14: 1ffff920007c5f68 R15: dffffc0000000000
FS:  00005555563c1400(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000038 CR3: 0000000113400000 CR4: 00000000003506b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
   0:	00 00                	add    %al,(%rax)
   2:	e8 74 8a ae fc       	callq  0xfcae8a7b
   7:	4c 89 e7             	mov    %r12,%rdi
   a:	be 04 00 00 00       	mov    $0x4,%esi
   f:	e8 67 8a ae fc       	callq  0xfcae8a7b
  14:	42 0f b6 04 3b       	movzbl (%rbx,%r15,1),%eax
  19:	84 c0                	test   %al,%al
  1b:	0f 85 be 00 00 00    	jne    0xdf
  21:	8b 44 24 40          	mov    0x40(%rsp),%eax
  25:	b9 01 00 00 00       	mov    $0x1,%ecx
* 2a:	f0 41 0f b1 4d 00    	lock cmpxchg %ecx,0x0(%r13) <-- trapping instruction
  30:	75 45                	jne    0x77
  32:	48 c7 44 24 20 0e 36 	movq   $0x45e0360e,0x20(%rsp)
  39:	e0 45
  3b:	4b                   	rex.WXB
  3c:	c7                   	.byte 0xc7
  3d:	04 37                	add    $0x37,%al

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/06/07 01:48 android14-6.1 312dfb3b7ec3 a4ae4f42 .config strace log report syz C ci2-android-6-1 KASAN: null-ptr-deref Write in hidraw_release
2023/06/08 11:57 android14-6.1 08f318933781 058b3a5a .config console log report info ci2-android-6-1 KASAN: null-ptr-deref Write in hidraw_release
2023/06/08 11:32 android14-6.1 08f318933781 058b3a5a .config console log report info ci2-android-6-1 KASAN: null-ptr-deref Write in hidraw_release
2023/06/06 19:49 android14-6.1 312dfb3b7ec3 a4ae4f42 .config console log report info ci2-android-6-1 KASAN: null-ptr-deref Write in hidraw_release
2023/05/24 14:20 android14-6.1 ae6e8fb652a7 4bce1a3e .config console log report info ci2-android-6-1 KASAN: null-ptr-deref Write in hidraw_release
* Struck through repros no longer work on HEAD.