diff options
author | Kees Cook <keescook@chromium.org> | 2013-09-11 15:56:54 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2013-09-13 09:12:39 -0400 |
commit | 0fb6bd06e06792469acc15bbe427361b56ada528 (patch) | |
tree | 9c389f833e25a00ca172274e359aefe77fa713dc /drivers/hid/hid-lg2ff.c | |
parent | 41df7f6d43723deb7364340b44bc5d94bf717456 (diff) |
HID: LG: validate HID output report details
A HID device could send a malicious output report that would cause the
lg, lg3, and lg4 HID drivers to write beyond the output report allocation
during an event, causing a heap overflow:
[ 325.245240] usb 1-1: New USB device found, idVendor=046d, idProduct=c287
...
[ 414.518960] BUG kmalloc-4096 (Not tainted): Redzone overwritten
Additionally, while lg2 did correctly validate the report details, it was
cleaned up and shortened.
CVE-2013-2893
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/hid-lg2ff.c')
-rw-r--r-- | drivers/hid/hid-lg2ff.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/drivers/hid/hid-lg2ff.c b/drivers/hid/hid-lg2ff.c index b3cd1507dda2..1a42eaa6ca02 100644 --- a/drivers/hid/hid-lg2ff.c +++ b/drivers/hid/hid-lg2ff.c | |||
@@ -64,26 +64,13 @@ int lg2ff_init(struct hid_device *hid) | |||
64 | struct hid_report *report; | 64 | struct hid_report *report; |
65 | struct hid_input *hidinput = list_entry(hid->inputs.next, | 65 | struct hid_input *hidinput = list_entry(hid->inputs.next, |
66 | struct hid_input, list); | 66 | struct hid_input, list); |
67 | struct list_head *report_list = | ||
68 | &hid->report_enum[HID_OUTPUT_REPORT].report_list; | ||
69 | struct input_dev *dev = hidinput->input; | 67 | struct input_dev *dev = hidinput->input; |
70 | int error; | 68 | int error; |
71 | 69 | ||
72 | if (list_empty(report_list)) { | 70 | /* Check that the report looks ok */ |
73 | hid_err(hid, "no output report found\n"); | 71 | report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7); |
72 | if (!report) | ||
74 | return -ENODEV; | 73 | return -ENODEV; |
75 | } | ||
76 | |||
77 | report = list_entry(report_list->next, struct hid_report, list); | ||
78 | |||
79 | if (report->maxfield < 1) { | ||
80 | hid_err(hid, "output report is empty\n"); | ||
81 | return -ENODEV; | ||
82 | } | ||
83 | if (report->field[0]->report_count < 7) { | ||
84 | hid_err(hid, "not enough values in the field\n"); | ||
85 | return -ENODEV; | ||
86 | } | ||
87 | 74 | ||
88 | lg2ff = kmalloc(sizeof(struct lg2ff_device), GFP_KERNEL); | 75 | lg2ff = kmalloc(sizeof(struct lg2ff_device), GFP_KERNEL); |
89 | if (!lg2ff) | 76 | if (!lg2ff) |