general protection fault in holtek_kbd_input_event

8 views
Skip to first unread message

syzbot

unread,
Jul 25, 2019, 8:08:06 AM7/25/19
to andre...@google.com, benjamin....@redhat.com, ji...@kernel.org, linux...@vger.kernel.org, linux-...@vger.kernel.org, linu...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: 6a3599ce usb-fuzzer: main usb gadget fuzzer driver
git tree: https://github.com/google/kasan.git usb-fuzzer
console output: https://syzkaller.appspot.com/x/log.txt?x=14e6d3d0600000
kernel config: https://syzkaller.appspot.com/x/.config?x=700ca426ab83faae
dashboard link: https://syzkaller.appspot.com/bug?extid=965152643a75a56737be
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1663f8cc600000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=145f2978600000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+965152...@syzkaller.appspotmail.com

kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP KASAN
CPU: 0 PID: 9738 Comm: syz-executor849 Not tainted 5.2.0-rc6+ #15
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
RIP: 0010:usb_get_intfdata include/linux/usb.h:265 [inline]
RIP: 0010:holtek_kbd_input_event+0xb7/0x1a0 drivers/hid/hid-holtek-kbd.c:127
Code: 48 8b 7b 40 31 f6 48 81 ef a0 00 00 00 e8 c1 7b ee fe 48 ba 00 00 00
00 00 fc ff df 48 8d b8 a8 00 00 00 48 89 f9 48 c1 e9 03 <80> 3c 11 00 0f
85 ab 00 00 00 48 8b 98 a8 00 00 00 48 b8 00 00 00
RSP: 0018:ffff8881ce297af8 EFLAGS: 00010002
RAX: 0000000000000000 RBX: ffff8881d530bbb0 RCX: 0000000000000015
RDX: dffffc0000000000 RSI: ffffffff8345640b RDI: 00000000000000a8
RBP: 0000000000000014 R08: ffff8881d1be1800 R09: ffffed103b646748
R10: ffffed103b646747 R11: ffff8881db233a3b R12: 0000000000000000
R13: 0000000000000004 R14: ffffffff8456e680 R15: 0000000000000003
FS: 00007f9ebaadb700(0000) GS:ffff8881db200000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f646c43c000 CR3: 00000001ce2a8000 CR4: 00000000001406f0
Call Trace:
input_handle_event+0x6a9/0x11c0 drivers/input/input.c:374
input_inject_event+0x270/0x304 drivers/input/input.c:462
evdev_do_ioctl drivers/input/evdev.c:1102 [inline]
evdev_ioctl_handler+0x6c4/0x19b0 drivers/input/evdev.c:1303
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:509 [inline]
do_vfs_ioctl+0xcda/0x12e0 fs/ioctl.c:696
ksys_ioctl+0x9b/0xc0 fs/ioctl.c:713
__do_sys_ioctl fs/ioctl.c:720 [inline]
__se_sys_ioctl fs/ioctl.c:718 [inline]
__x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:718
do_syscall_64+0xb7/0x560 arch/x86/entry/common.c:301
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x44e599
Code: e8 3c e6 ff ff 48 83 c4 18 c3 0f 1f 80 00 00 00 00 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 0f 83 cb ca fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f9ebaadace8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000006e0c28 RCX: 000000000044e599
RDX: 0000000020000040 RSI: 0000000040084503 RDI: 0000000000000004
RBP: 00000000006e0c20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006e0c2c
R13: 00007ffe21581f9f R14: 00007f9ebaadb9c0 R15: 0000000000000000
Modules linked in:
---[ end trace 48abaec9fafcd397 ]---
RIP: 0010:usb_get_intfdata include/linux/usb.h:265 [inline]
RIP: 0010:holtek_kbd_input_event+0xb7/0x1a0 drivers/hid/hid-holtek-kbd.c:127
Code: 48 8b 7b 40 31 f6 48 81 ef a0 00 00 00 e8 c1 7b ee fe 48 ba 00 00 00
00 00 fc ff df 48 8d b8 a8 00 00 00 48 89 f9 48 c1 e9 03 <80> 3c 11 00 0f
85 ab 00 00 00 48 8b 98 a8 00 00 00 48 b8 00 00 00
RSP: 0018:ffff8881ce297af8 EFLAGS: 00010002
RAX: 0000000000000000 RBX: ffff8881d530bbb0 RCX: 0000000000000015
RDX: dffffc0000000000 RSI: ffffffff8345640b RDI: 00000000000000a8
RBP: 0000000000000014 R08: ffff8881d1be1800 R09: ffffed103b646748
R10: ffffed103b646747 R11: ffff8881db233a3b R12: 0000000000000000
R13: 0000000000000004 R14: ffffffff8456e680 R15: 0000000000000003
FS: 00007f9ebaadb700(0000) GS:ffff8881db200000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f646c43c000 CR3: 00000001ce2a8000 CR4: 00000000001406f0


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches

Oliver Neukum

unread,
Jul 25, 2019, 8:43:15 AM7/25/19
to syzbot, andre...@google.com, syzkall...@googlegroups.com, ji...@kernel.org, benjamin....@redhat.com, linux...@vger.kernel.org
Am Donnerstag, den 25.07.2019, 05:08 -0700 schrieb syzbot:
> Hello,
>
> syzbot found the following crash on:
>
> HEAD commit: 6a3599ce usb-fuzzer: main usb gadget fuzzer driver
> git tree: https://github.com/google/kasan.git usb-fuzzer
> console output: https://syzkaller.appspot.com/x/log.txt?x=14e6d3d0600000
> kernel config: https://syzkaller.appspot.com/x/.config?x=700ca426ab83faae
> dashboard link: https://syzkaller.appspot.com/bug?extid=965152643a75a56737be
> compiler: gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1663f8cc600000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=145f2978600000
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+965152...@syzkaller.appspotmail.com

#syz test: https://github.com/google/kasan.git usb-fuzzer-usb-testing-2019.07.11

From 93eb5c925a204804b82a7526a8b9252a102fd339 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <one...@suse.com>
Date: Thu, 25 Jul 2019 14:37:53 +0200
Subject: [PATCH] holtek: test for sanity of intfdata

The ioctl handler uses the intfdata of a second interface,
which may not be present in a broken or malicious device, hence
the intfdata needs to be checked for NULL.

Reported-by: syzbot+965152...@syzkaller.appspotmail.com
Signed-off-by: Oliver Neukum <one...@suse.com>
---
drivers/hid/hid-holtek-kbd.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-holtek-kbd.c b/drivers/hid/hid-holtek-kbd.c
index b3d502421b79..67ce75dfa9a4 100644
--- a/drivers/hid/hid-holtek-kbd.c
+++ b/drivers/hid/hid-holtek-kbd.c
@@ -123,9 +123,14 @@ static int holtek_kbd_input_event(struct input_dev *dev, unsigned int type,

/* Locate the boot interface, to receive the LED change events */
struct usb_interface *boot_interface = usb_ifnum_to_if(usb_dev, 0);
-
- struct hid_device *boot_hid = usb_get_intfdata(boot_interface);
- struct hid_input *boot_hid_input = list_first_entry(&boot_hid->inputs,
+ struct hid_device *boot_hid;
+ struct hid_input *boot_hid_input;
+
+ if (unlikely(boot_interface == NULL))
+ return -ENODEV;
+
+ boot_hid = usb_get_intfdata(boot_interface);
+ boot_hid_input = list_first_entry(&boot_hid->inputs,
struct hid_input, list);

return boot_hid_input->input->event(boot_hid_input->input, type, code,
--
2.16.4

syzbot

unread,
Jul 25, 2019, 9:02:02 AM7/25/19
to andre...@google.com, benjamin....@redhat.com, ji...@kernel.org, linux...@vger.kernel.org, one...@suse.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger
crash:

Reported-and-tested-by:
syzbot+965152...@syzkaller.appspotmail.com

Tested on:

commit: 6a3599ce usb-fuzzer: main usb gadget fuzzer driver
git tree: https://github.com/google/kasan.git
usb-fuzzer-usb-testing-2019.07.11
kernel config: https://syzkaller.appspot.com/x/.config?x=700ca426ab83faae
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
patch: https://syzkaller.appspot.com/x/patch.diff?x=135edb68600000

Note: testing is done by a robot and is best-effort only.
Reply all
Reply to author
Forward
0 new messages