[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230918024059.3472762-1-make_ruc2021@163.com>
Date: Mon, 18 Sep 2023 10:40:59 +0800
From: Ma Ke <make_ruc2021@....com>
To: jikos@...nel.org, benjamin.tissoires@...hat.com
Cc: linux-input@...r.kernel.org, linux-kernel@...r.kernel.org,
Ma Ke <make_ruc2021@....com>
Subject: [PATCH] HID: holtek: fix slab-out-of-bounds Write in holtek_kbd_input_event
There is a slab-out-of-bounds Write bug in hid-holtek-kbd driver.
The problem is the driver assumes the device must have an input
but some malicious devices violate this assumption.
Fix this by checking hid_device's input is non-empty before its usage.
Signed-off-by: Ma Ke <make_ruc2021@....com>
---
drivers/hid/hid-holtek-kbd.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/hid/hid-holtek-kbd.c b/drivers/hid/hid-holtek-kbd.c
index 403506b9697e..b346d68a06f5 100644
--- a/drivers/hid/hid-holtek-kbd.c
+++ b/drivers/hid/hid-holtek-kbd.c
@@ -130,6 +130,10 @@ static int holtek_kbd_input_event(struct input_dev *dev, unsigned int type,
return -ENODEV;
boot_hid = usb_get_intfdata(boot_interface);
+ if (list_empty(&boot_hid->inputs)) {
+ hid_err(hid, "no inputs found\n");
+ return -ENODEV;
+ }
boot_hid_input = list_first_entry(&boot_hid->inputs,
struct hid_input, list);
--
2.37.2
Powered by blists - more mailing lists