Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a9856853 authored by Ma Ke's avatar Ma Ke Committed by Greg Kroah-Hartman
Browse files

HID: holtek: fix slab-out-of-bounds Write in holtek_kbd_input_event



[ Upstream commit ffe3b7837a2bb421df84d0177481db9f52c93a71 ]

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: default avatarMa Ke <make_ruc2021@163.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 79700b56
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -133,6 +133,10 @@ static int holtek_kbd_input_event(struct input_dev *dev, unsigned int type,
		return -ENODEV;
		return -ENODEV;


	boot_hid = usb_get_intfdata(boot_interface);
	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,
	boot_hid_input = list_first_entry(&boot_hid->inputs,
		struct hid_input, list);
		struct hid_input, list);