Skip to content

Commit 0a9cd0a

Browse files
keesJiri Kosina
authored andcommitted
HID: lenovo-tpkbd: validate output report details
A HID device could send a malicious output report that would cause the lenovo-tpkbd HID driver to write just beyond the output report allocation during initialization, causing a heap overflow: [ 76.109807] usb 1-1: New USB device found, idVendor=17ef, idProduct=6009 ... [ 80.462540] BUG kmalloc-192 (Tainted: G W ): Redzone overwritten CVE-2013-2894 Signed-off-by: Kees Cook <[email protected]> Cc: [email protected] Signed-off-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 0fb6bd0 commit 0a9cd0a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/hid/hid-lenovo-tpkbd.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,15 @@ static int tpkbd_probe_tp(struct hid_device *hdev)
339339
struct tpkbd_data_pointer *data_pointer;
340340
size_t name_sz = strlen(dev_name(dev)) + 16;
341341
char *name_mute, *name_micmute;
342-
int ret;
342+
int i, ret;
343+
344+
/* Validate required reports. */
345+
for (i = 0; i < 4; i++) {
346+
if (!hid_validate_values(hdev, HID_FEATURE_REPORT, 4, i, 1))
347+
return -ENODEV;
348+
}
349+
if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 3, 0, 2))
350+
return -ENODEV;
343351

344352
if (sysfs_create_group(&hdev->dev.kobj,
345353
&tpkbd_attr_group_pointer)) {

0 commit comments

Comments
 (0)