Skip to content

Commit 78214e8

Browse files
keesJiri Kosina
authored andcommitted
HID: zeroplus: validate output report details
The zeroplus HID driver was not checking the size of allocated values in fields it used. A HID device could send a malicious output report that would cause the driver to write beyond the output report allocation during initialization, causing a heap overflow: [ 1442.728680] usb 1-1: New USB device found, idVendor=0c12, idProduct=0005 ... [ 1466.243173] BUG kmalloc-192 (Tainted: G W ): Redzone overwritten CVE-2013-2889 Signed-off-by: Kees Cook <[email protected]> Cc: [email protected] Reviewed-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 331415f commit 78214e8

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

drivers/hid/hid-zpff.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,13 @@ static int zpff_init(struct hid_device *hid)
6868
struct hid_report *report;
6969
struct hid_input *hidinput = list_entry(hid->inputs.next,
7070
struct hid_input, list);
71-
struct list_head *report_list =
72-
&hid->report_enum[HID_OUTPUT_REPORT].report_list;
7371
struct input_dev *dev = hidinput->input;
74-
int error;
72+
int i, error;
7573

76-
if (list_empty(report_list)) {
77-
hid_err(hid, "no output report found\n");
78-
return -ENODEV;
79-
}
80-
81-
report = list_entry(report_list->next, struct hid_report, list);
82-
83-
if (report->maxfield < 4) {
84-
hid_err(hid, "not enough fields in report\n");
85-
return -ENODEV;
74+
for (i = 0; i < 4; i++) {
75+
report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, i, 1);
76+
if (!report)
77+
return -ENODEV;
8678
}
8779

8880
zpff = kzalloc(sizeof(struct zpff_device), GFP_KERNEL);

0 commit comments

Comments
 (0)