From patchwork Thu Oct 10 13:48:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Henriques X-Patchwork-Id: 282264 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id B0E932C00E7 for ; Fri, 11 Oct 2013 00:48:29 +1100 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1VUGbH-00064T-26; Thu, 10 Oct 2013 13:48:23 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1VUGb7-00063e-HF for kernel-team@lists.ubuntu.com; Thu, 10 Oct 2013 13:48:13 +0000 Received: from bl15-103-32.dsl.telepac.pt ([188.80.103.32] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1VUGb7-0003NG-Ab for kernel-team@lists.ubuntu.com; Thu, 10 Oct 2013 13:48:13 +0000 From: Luis Henriques To: kernel-team@lists.ubuntu.com Subject: [Lucid][CVE 1/2] HID: add usage_index in struct hid_usage. Date: Thu, 10 Oct 2013 14:48:09 +0100 Message-Id: <1381412890-5152-2-git-send-email-luis.henriques@canonical.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1381412890-5152-1-git-send-email-luis.henriques@canonical.com> References: <1381412890-5152-1-git-send-email-luis.henriques@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Benjamin Tissoires BugLink: http://bugs.launchpad.net/bugs/1220205 CVE-2013-2897 Currently, there is no way to know the index of the current field in the .input_mapping and .event callbacks when this field is inside an array of HID fields. This patch adds this index to the struct hid_usage so that this information is available to input_mapping and event callbacks. Signed-off-by: Benjamin Tissoires Acked-by: Jiri Kosina Signed-off-by: Jiri Kosina (cherry picked from commit f262d1fa2c651a5e2f92b6aee8779597631cd5d4) Signed-off-by: Luis Henriques --- drivers/hid/hid-core.c | 4 ++++ include/linux/hid.h | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 011e4a1..0fb4906 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -87,6 +87,7 @@ static struct hid_report *hid_register_report(struct hid_device *device, unsigne static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) { struct hid_field *field; + int i; if (report->maxfield == HID_MAX_FIELDS) { dbg_hid("too many fields in report\n"); @@ -102,6 +103,9 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned field->value = (s32 *)(field->usage + usages); field->report = report; + for (i = 0; i < usages; i++) + field->usage[i].usage_index = i; + return field; } diff --git a/include/linux/hid.h b/include/linux/hid.h index e5db8e5..b441d08 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -363,6 +363,7 @@ struct hid_collection { struct hid_usage { unsigned hid; /* hid usage code */ unsigned collection_index; /* index into collection array */ + unsigned usage_index; /* index into usage array */ /* hidinput data */ __u16 code; /* input driver code */ __u8 type; /* input driver type */