aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2013-09-11 15:56:56 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-10-01 12:17:46 -0400
commit7661107379d11e11736e3c3210a95eb421a1ad3d (patch)
tree5f822cdaaeee6c01750d60105f21799586a01c71
parent855f21e01243b09e5166b10e9c9e88585fc8e0c5 (diff)
HID: logitech-dj: validate output report details
commit 297502abb32e225fb23801fcdb0e4f6f8e17099a upstream. A HID device could send a malicious output report that would cause the logitech-dj HID driver to leak kernel memory contents to the device, or trigger a NULL dereference during initialization: [ 304.424553] usb 1-1: New USB device found, idVendor=046d, idProduct=c52b ... [ 304.780467] BUG: unable to handle kernel NULL pointer dereference at 0000000000000028 [ 304.781409] IP: [<ffffffff815d50aa>] logi_dj_recv_send_report.isra.11+0x1a/0x90 CVE-2013-2895 Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/hid/hid-logitech-dj.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
index 5207591a598c..0522b80eab5a 100644
--- a/drivers/hid/hid-logitech-dj.c
+++ b/drivers/hid/hid-logitech-dj.c
@@ -421,7 +421,7 @@ static int logi_dj_recv_send_report(struct dj_receiver_dev *djrcv_dev,
421 struct hid_report *report; 421 struct hid_report *report;
422 struct hid_report_enum *output_report_enum; 422 struct hid_report_enum *output_report_enum;
423 u8 *data = (u8 *)(&dj_report->device_index); 423 u8 *data = (u8 *)(&dj_report->device_index);
424 int i; 424 unsigned int i;
425 425
426 output_report_enum = &hdev->report_enum[HID_OUTPUT_REPORT]; 426 output_report_enum = &hdev->report_enum[HID_OUTPUT_REPORT];
427 report = output_report_enum->report_id_hash[REPORT_ID_DJ_SHORT]; 427 report = output_report_enum->report_id_hash[REPORT_ID_DJ_SHORT];
@@ -431,7 +431,7 @@ static int logi_dj_recv_send_report(struct dj_receiver_dev *djrcv_dev,
431 return -ENODEV; 431 return -ENODEV;
432 } 432 }
433 433
434 for (i = 0; i < report->field[0]->report_count; i++) 434 for (i = 0; i < DJREPORT_SHORT_LENGTH - 1; i++)
435 report->field[0]->value[i] = data[i]; 435 report->field[0]->value[i] = data[i];
436 436
437 hid_hw_request(hdev, report, HID_REQ_SET_REPORT); 437 hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
@@ -738,6 +738,12 @@ static int logi_dj_probe(struct hid_device *hdev,
738 goto hid_parse_fail; 738 goto hid_parse_fail;
739 } 739 }
740 740
741 if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, REPORT_ID_DJ_SHORT,
742 0, DJREPORT_SHORT_LENGTH - 1)) {
743 retval = -ENODEV;
744 goto hid_parse_fail;
745 }
746
741 /* Starts the usb device and connects to upper interfaces hiddev and 747 /* Starts the usb device and connects to upper interfaces hiddev and
742 * hidraw */ 748 * hidraw */
743 retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 749 retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT);