HID: sensor-hub: validate feature report details
authorKees Cook <keescook@chromium.org>
Wed, 28 Aug 2013 20:31:44 +0000 (22:31 +0200)
committerBadhri Jagan Sridharan <Badhri@google.com>
Fri, 11 Jul 2014 21:26:57 +0000 (14:26 -0700)
A HID device could send a malicious feature report that would cause the
sensor-hub HID driver to read past the end of heap allocation, leaking
kernel memory contents to the caller.

CVE-2013-2898

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: stable@kernel.org
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-sensor-hub.c

index ca74981073271effdddc72ba1f173acea27ebbf9..aa34755ca205eb6955cb10b01b2a6b01bc1a3dd1 100644 (file)
@@ -221,7 +221,8 @@ int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
 
        mutex_lock(&data->mutex);
        report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
-       if (!report || (field_index >=  report->maxfield)) {
+       if (!report || (field_index >=  report->maxfield) ||
+           report->field[field_index]->report_count < 1) {
                ret = -EINVAL;
                goto done_proc;
        }