aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/hid/hid-lgff.c
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2013-09-11 21:56:54 +0200
committerJiri Kosina <jkosina@suse.cz>2013-09-13 15:12:39 +0200
commit0fb6bd06e06792469acc15bbe427361b56ada528 (patch)
tree9c389f833e25a00ca172274e359aefe77fa713dc /drivers/hid/hid-lgff.c
parentHID: steelseries: validate output report details (diff)
downloadwireguard-linux-0fb6bd06e06792469acc15bbe427361b56ada528.tar.xz
wireguard-linux-0fb6bd06e06792469acc15bbe427361b56ada528.zip
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-lgff.c')
-rw-r--r--drivers/hid/hid-lgff.c17
1 files changed, 2 insertions, 15 deletions
diff --git a/drivers/hid/hid-lgff.c b/drivers/hid/hid-lgff.c
index d7ea8c845b40..e1394af0ae7b 100644
--- a/drivers/hid/hid-lgff.c
+++ b/drivers/hid/hid-lgff.c
@@ -128,27 +128,14 @@ static void hid_lgff_set_autocenter(struct input_dev *dev, u16 magnitude)
int lgff_init(struct hid_device* hid)
{
struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
- struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
struct input_dev *dev = hidinput->input;
- struct hid_report *report;
- struct hid_field *field;
const signed short *ff_bits = ff_joystick;
int error;
int i;
- /* Find the report to use */
- if (list_empty(report_list)) {
- hid_err(hid, "No output report found\n");
- return -1;
- }
-
/* Check that the report looks ok */
- report = list_entry(report_list->next, struct hid_report, list);
- field = report->field[0];
- if (!field) {
- hid_err(hid, "NULL field\n");
- return -1;
- }
+ if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7))
+ return -ENODEV;
for (i = 0; i < ARRAY_SIZE(devices); i++) {
if (dev->id.vendor == devices[i].idVendor &&