HID: ntrig: validate feature report details
authorKees Cook <keescook@chromium.org>
Wed, 28 Aug 2013 20:31:28 +0000 (22:31 +0200)
committerJiri Kosina <jkosina@suse.cz>
Wed, 4 Sep 2013 10:00:23 +0000 (12:00 +0200)
A HID device could send a malicious feature report that would cause the
ntrig HID driver to trigger a NULL dereference during initialization:

[57383.031190] usb 3-1: New USB device found, idVendor=1b96, idProduct=0001
...
[57383.315193] BUG: unable to handle kernel NULL pointer dereference at 0000000000000030
[57383.315308] IP: [<ffffffffa08102de>] ntrig_probe+0x25e/0x420 [hid_ntrig]

CVE-2013-2896

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: stable@kernel.org
Signed-off-by: Rafi Rubin <rafi@seas.upenn.edu>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-ntrig.c

index 98d1fdf..600f207 100644 (file)
@@ -115,7 +115,8 @@ static inline int ntrig_get_mode(struct hid_device *hdev)
        struct hid_report *report = hdev->report_enum[HID_FEATURE_REPORT].
                                    report_id_hash[0x0d];
 
-       if (!report)
+       if (!report || report->maxfield < 1 ||
+           report->field[0]->report_count < 1)
                return -EINVAL;
 
        hid_hw_request(hdev, report, HID_REQ_GET_REPORT);