BUG: unable to handle kernel NULL pointer dereference in holtek_kbd_input_event

From: Rondreis
Date: Fri Sep 16 2022 - 07:47:17 EST


Hello,

When fuzzing the Linux kernel driver v6.0-rc4, the following crash was
triggered.

HEAD commit: 7e18e42e4b280c85b76967a9106a13ca61c16179
git tree: upstream

kernel config: https://pastebin.com/raw/xtrgsXP3
console output: https://pastebin.com/raw/nHbNncrF

Basically, we use the gadget module to emulate
attaching a USB device and executing some simple sequence of system calls.

Sorry I do not have c reproducer for this bug, but I would so
appreciate it if you have any idea how to solve this bug.

The crash report is as follows:

BUG: kernel NULL pointer dereference, address: 0000000000000000
#PF: supervisor instruction fetch in kernel mode
#PF: error_code(0x0010) - not-present page
PGD 4519d067 P4D 4519d067 PUD 4650c067 PMD 0
Oops: 0010 [#1] PREEMPT SMP KASAN
CPU: 3 PID: 13073 Comm: syz-executor.0 Not tainted 6.0.0-rc4+ #20
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
1.13.0-1ubuntu1.1 04/01/2014
RIP: 0010:0x0
Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
RSP: 0018:ffffc9001a6d7c60 EFLAGS: 00010046
RAX: dffffc0000000000 RBX: ffff88803c455a00 RCX: 0000000000000080
RDX: 0000000000000001 RSI: 0000000000000014 RDI: ffff88803c455a00
RBP: 0000000000000014 R08: ffffffff86d5d39a R09: 0000000000000000
R10: 0000000000000004 R11: fffffbfff1ac6947 R12: 0000000000000001
R13: 0000000000000080 R14: 0000000000000080 R15: 0000000000000003
FS: 00007f02dfa7e700(0000) GS:ffff888135d00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffffffffd6 CR3: 00000001082e2000 CR4: 0000000000350ee0
Call Trace:
<TASK>
holtek_kbd_input_event+0x14e/0x1c0 drivers/hid/hid-holtek-kbd.c:136
input_event_dispose+0x81/0x5e0 drivers/input/input.c:351
input_handle_event+0x203/0xdc0 drivers/input/input.c:402
input_inject_event+0x1c4/0x320 drivers/input/input.c:461
evdev_do_ioctl drivers/input/evdev.c:1072 [inline]
evdev_ioctl_handler+0x724/0x1af0 drivers/input/evdev.c:1272
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:870 [inline]
__se_sys_ioctl fs/ioctl.c:856 [inline]
__x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0x80 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f02df2a80fd
Code: 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa 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:00007f02dfa7dbf8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f02df39c340 RCX: 00007f02df2a80fd
RDX: 00000000200001c0 RSI: 0000000040084503 RDI: 0000000000000006
RBP: 00007f02df30b606 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffd773bc70f R14: 00007ffd773bc8b0 R15: 00007f02dfa7dd80
</TASK>
Modules linked in:
CR2: 0000000000000000
---[ end trace 0000000000000000 ]---
RIP: 0010:0x0
Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
RSP: 0018:ffffc9001a6d7c60 EFLAGS: 00010046
RAX: dffffc0000000000 RBX: ffff88803c455a00 RCX: 0000000000000080
RDX: 0000000000000001 RSI: 0000000000000014 RDI: ffff88803c455a00
RBP: 0000000000000014 R08: ffffffff86d5d39a R09: 0000000000000000
R10: 0000000000000004 R11: fffffbfff1ac6947 R12: 0000000000000001
R13: 0000000000000080 R14: 0000000000000080 R15: 0000000000000003
FS: 00007f02dfa7e700(0000) GS:ffff888135d00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffffffffd6 CR3: 00000001082e2000 CR4: 0000000000350ee0