diff options
author | Kees Cook <keescook@chromium.org> | 2013-09-11 15:56:51 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2013-09-13 09:11:34 -0400 |
commit | 78214e81a1bf43740ce89bb5efda78eac2f8ef83 (patch) | |
tree | 82d36fa7693f2c6aea5a55d4eb64e57542fcae93 /drivers/hid | |
parent | 331415ff16a12147d57d5c953f3a961b7ede348b (diff) |
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 <keescook@chromium.org>
Cc: stable@vger.kernel.org
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/hid-zpff.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/drivers/hid/hid-zpff.c b/drivers/hid/hid-zpff.c index 6ec28a37c146..a29756c6ca02 100644 --- a/drivers/hid/hid-zpff.c +++ b/drivers/hid/hid-zpff.c | |||
@@ -68,21 +68,13 @@ static int zpff_init(struct hid_device *hid) | |||
68 | struct hid_report *report; | 68 | struct hid_report *report; |
69 | struct hid_input *hidinput = list_entry(hid->inputs.next, | 69 | struct hid_input *hidinput = list_entry(hid->inputs.next, |
70 | struct hid_input, list); | 70 | struct hid_input, list); |
71 | struct list_head *report_list = | ||
72 | &hid->report_enum[HID_OUTPUT_REPORT].report_list; | ||
73 | struct input_dev *dev = hidinput->input; | 71 | struct input_dev *dev = hidinput->input; |
74 | int error; | 72 | int i, error; |
75 | 73 | ||
76 | if (list_empty(report_list)) { | 74 | for (i = 0; i < 4; i++) { |
77 | hid_err(hid, "no output report found\n"); | 75 | report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, i, 1); |
78 | return -ENODEV; | 76 | if (!report) |
79 | } | 77 | return -ENODEV; |
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; | ||
86 | } | 78 | } |
87 | 79 | ||
88 | zpff = kzalloc(sizeof(struct zpff_device), GFP_KERNEL); | 80 | zpff = kzalloc(sizeof(struct zpff_device), GFP_KERNEL); |