diff options
author | Ma Ke <make_ruc2021@163.com> | 2023-09-18 10:40:59 +0800 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2023-09-18 17:13:01 +0200 |
commit | ffe3b7837a2bb421df84d0177481db9f52c93a71 (patch) | |
tree | fb997d77650d9caab0b302004d92035024f26bbb /drivers | |
parent | 058574879853260a22bbec1f94221dfc5149d85c (diff) | |
download | linux-stable-ffe3b7837a2bb421df84d0177481db9f52c93a71.tar.gz linux-stable-ffe3b7837a2bb421df84d0177481db9f52c93a71.tar.bz2 linux-stable-ffe3b7837a2bb421df84d0177481db9f52c93a71.zip |
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@163.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hid/hid-holtek-kbd.c | 4 |
1 files changed, 4 insertions, 0 deletions
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); |