From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Will McVicker <willmcvicker@google.com>,
Jiri Kosina <jkosina@suse.cz>
Subject: [PATCH 5.4 02/17] HID: make arrays usage and value to be the same
Date: Thu, 25 Feb 2021 10:53:47 +0100 [thread overview]
Message-ID: <20210225092515.126158905@linuxfoundation.org> (raw)
In-Reply-To: <20210225092515.001992375@linuxfoundation.org>
From: Will McVicker <willmcvicker@google.com>
commit ed9be64eefe26d7d8b0b5b9fa3ffdf425d87a01f upstream.
The HID subsystem allows an "HID report field" to have a different
number of "values" and "usages" when it is allocated. When a field
struct is created, the size of the usage array is guaranteed to be at
least as large as the values array, but it may be larger. This leads to
a potential out-of-bounds write in
__hidinput_change_resolution_multipliers() and an out-of-bounds read in
hidinput_count_leds().
To fix this, let's make sure that both the usage and value arrays are
the same size.
Cc: stable@vger.kernel.org
Signed-off-by: Will McVicker <willmcvicker@google.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/hid/hid-core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -90,7 +90,7 @@ EXPORT_SYMBOL_GPL(hid_register_report);
* Register a new field for this report.
*/
-static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values)
+static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages)
{
struct hid_field *field;
@@ -101,7 +101,7 @@ static struct hid_field *hid_register_fi
field = kzalloc((sizeof(struct hid_field) +
usages * sizeof(struct hid_usage) +
- values * sizeof(unsigned)), GFP_KERNEL);
+ usages * sizeof(unsigned)), GFP_KERNEL);
if (!field)
return NULL;
@@ -300,7 +300,7 @@ static int hid_add_field(struct hid_pars
usages = max_t(unsigned, parser->local.usage_index,
parser->global.report_count);
- field = hid_register_field(report, usages, parser->global.report_count);
+ field = hid_register_field(report, usages);
if (!field)
return 0;
next prev parent reply other threads:[~2021-02-25 10:23 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-25 9:53 [PATCH 5.4 00/17] 5.4.101-rc1 review Greg Kroah-Hartman
2021-02-25 9:53 ` [PATCH 5.4 01/17] bpf: Fix truncation handling for mod32 dst reg wrt zero Greg Kroah-Hartman
2021-02-25 9:53 ` Greg Kroah-Hartman [this message]
2021-02-25 9:53 ` [PATCH 5.4 03/17] USB: quirks: sort quirk entries Greg Kroah-Hartman
2021-02-25 9:53 ` [PATCH 5.4 04/17] usb: quirks: add quirk to start video capture on ELMO L-12F document camera reliable Greg Kroah-Hartman
2021-02-25 9:53 ` [PATCH 5.4 05/17] ntfs: check for valid standard information attribute Greg Kroah-Hartman
2021-02-25 9:53 ` [PATCH 5.4 06/17] arm64: tegra: Add power-domain for Tegra210 HDA Greg Kroah-Hartman
2021-02-25 9:53 ` [PATCH 5.4 07/17] scripts: use pkg-config to locate libcrypto Greg Kroah-Hartman
2021-02-25 9:53 ` [PATCH 5.4 08/17] scripts: set proper OpenSSL include dir also for sign-file Greg Kroah-Hartman
2021-02-25 9:53 ` [PATCH 5.4 09/17] mm: unexport follow_pte_pmd Greg Kroah-Hartman
2021-02-25 9:53 ` [PATCH 5.4 10/17] mm: simplify follow_pte{,pmd} Greg Kroah-Hartman
2021-02-25 9:53 ` [PATCH 5.4 11/17] KVM: do not assume PTE is writable after follow_pfn Greg Kroah-Hartman
2021-02-25 9:53 ` [PATCH 5.4 12/17] mm: provide a saner PTE walking API for modules Greg Kroah-Hartman
2021-02-25 9:53 ` [PATCH 5.4 13/17] KVM: Use kvm_pfn_t for local PFN variable in hva_to_pfn_remapped() Greg Kroah-Hartman
2021-02-25 9:53 ` [PATCH 5.4 14/17] NET: usb: qmi_wwan: Adding support for Cinterion MV31 Greg Kroah-Hartman
2021-02-25 9:54 ` [PATCH 5.4 15/17] cxgb4: Add new T6 PCI device id 0x6092 Greg Kroah-Hartman
2021-02-25 9:54 ` [PATCH 5.4 16/17] cifs: Set CIFS_MOUNT_USE_PREFIX_PATH flag on setting cifs_sb->prepath Greg Kroah-Hartman
2021-02-25 9:54 ` [PATCH 5.4 17/17] scripts/recordmcount.pl: support big endian for ARCH sh Greg Kroah-Hartman
2021-02-25 19:51 ` [PATCH 5.4 00/17] 5.4.101-rc1 review Guenter Roeck
2021-02-25 21:17 ` Florian Fainelli
2021-02-26 2:25 ` Shuah Khan
2021-02-26 3:38 ` Ross Schmidt
2021-02-26 9:28 ` Naresh Kamboju
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210225092515.126158905@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=willmcvicker@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox