Blame SOURCES/CVE-2021-0512.patch

fb3ac1
From cd6338e72336f073342df3b49a4d6cb7fb6cdbee Mon Sep 17 00:00:00 2001
fb3ac1
From: Joe Lawrence <joe.lawrence@redhat.com>
fb3ac1
Date: Tue, 26 Oct 2021 10:59:31 -0400
fb3ac1
Subject: [KPATCH CVE-2021-0512] HID: kpatch fixes for CVE-2021-0512
fb3ac1
fb3ac1
Kernels:
fb3ac1
4.18.0-305.el8
fb3ac1
4.18.0-305.3.1.el8_4
fb3ac1
4.18.0-305.7.1.el8_4
fb3ac1
4.18.0-305.10.2.el8_4
fb3ac1
4.18.0-305.12.1.el8_4
fb3ac1
4.18.0-305.17.1.el8_4
fb3ac1
4.18.0-305.19.1.el8_4
fb3ac1
fb3ac1
Changes since last build:
fb3ac1
arches: x86_64 ppc64le
fb3ac1
hid-core.o: changed function: hid_add_field
fb3ac1
---------------------------
fb3ac1
fb3ac1
Kernels:
fb3ac1
4.18.0-305.el8
fb3ac1
4.18.0-305.3.1.el8_4
fb3ac1
4.18.0-305.7.1.el8_4
fb3ac1
4.18.0-305.10.2.el8_4
fb3ac1
4.18.0-305.12.1.el8_4
fb3ac1
4.18.0-305.17.1.el8_4
fb3ac1
4.18.0-305.19.1.el8_4
fb3ac1
fb3ac1
Modifications: none
fb3ac1
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-8/-/merge_requests/5
fb3ac1
Approved-by: Artem Savkov (@artem.savkov)
fb3ac1
fb3ac1
Z-MR: https://gitlab.com/redhat/rhel/src/kernel/rhel-8/-/merge_requests/1350
fb3ac1
fb3ac1
KT0 test PASS: https://beaker.engineering.redhat.com/jobs/5942710
fb3ac1
for kpatch-patch-4_18_0-305-1-6.el8 scratch build:
fb3ac1
https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=40615898
fb3ac1
fb3ac1
commit 8ee375b059ce42c0c38f2593f76077d915eee89e
fb3ac1
Author: Benjamin Tissoires <benjamin.tissoires@redhat.com>
fb3ac1
Date:   Tue Aug 17 09:26:20 2021 +0200
fb3ac1
fb3ac1
    HID: make arrays usage and value to be the same
fb3ac1
fb3ac1
    Bugzilla: https://bugzilla.redhat.com/1974941
fb3ac1
    CVE: CVE-2021-0512
fb3ac1
    Y-Commit: 87ed552fb937790a5d9439c179bb523cfb0efdc6
fb3ac1
fb3ac1
    O-Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1974942
fb3ac1
    Upstream Status: since v5.12
fb3ac1
    Test: me on the hid-tools test suite
fb3ac1
fb3ac1
    commit ed9be64eefe26d7d8b0b5b9fa3ffdf425d87a01f
fb3ac1
    Author: Will McVicker <willmcvicker@google.com>
fb3ac1
    Date:   Sat Dec 5 00:48:48 2020 +0000
fb3ac1
fb3ac1
        HID: make arrays usage and value to be the same
fb3ac1
fb3ac1
        The HID subsystem allows an "HID report field" to have a different
fb3ac1
        number of "values" and "usages" when it is allocated. When a field
fb3ac1
        struct is created, the size of the usage array is guaranteed to be at
fb3ac1
        least as large as the values array, but it may be larger. This leads to
fb3ac1
        a potential out-of-bounds write in
fb3ac1
        __hidinput_change_resolution_multipliers() and an out-of-bounds read in
fb3ac1
        hidinput_count_leds().
fb3ac1
fb3ac1
        To fix this, let's make sure that both the usage and value arrays are
fb3ac1
        the same size.
fb3ac1
fb3ac1
        Cc: stable@vger.kernel.org
fb3ac1
        Signed-off-by: Will McVicker <willmcvicker@google.com>
fb3ac1
        Signed-off-by: Jiri Kosina <jkosina@suse.cz>
fb3ac1
fb3ac1
    Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
fb3ac1
    Signed-off-by: Julio Faracco <jfaracco@redhat.com>
fb3ac1
fb3ac1
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
fb3ac1
---
fb3ac1
 drivers/hid/hid-core.c | 6 +++---
fb3ac1
 1 file changed, 3 insertions(+), 3 deletions(-)
fb3ac1
fb3ac1
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
fb3ac1
index d2ecc9c45255..263eca119ff0 100644
fb3ac1
--- a/drivers/hid/hid-core.c
fb3ac1
+++ b/drivers/hid/hid-core.c
fb3ac1
@@ -90,7 +90,7 @@ EXPORT_SYMBOL_GPL(hid_register_report);
fb3ac1
  * Register a new field for this report.
fb3ac1
  */
fb3ac1
 
fb3ac1
-static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values)
fb3ac1
+static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages)
fb3ac1
 {
fb3ac1
 	struct hid_field *field;
fb3ac1
 
fb3ac1
@@ -101,7 +101,7 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned
fb3ac1
 
fb3ac1
 	field = kzalloc((sizeof(struct hid_field) +
fb3ac1
 			 usages * sizeof(struct hid_usage) +
fb3ac1
-			 values * sizeof(unsigned)), GFP_KERNEL);
fb3ac1
+			 usages * sizeof(unsigned)), GFP_KERNEL);
fb3ac1
 	if (!field)
fb3ac1
 		return NULL;
fb3ac1
 
fb3ac1
@@ -300,7 +300,7 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
fb3ac1
 	usages = max_t(unsigned, parser->local.usage_index,
fb3ac1
 				 parser->global.report_count);
fb3ac1
 
fb3ac1
-	field = hid_register_field(report, usages, parser->global.report_count);
fb3ac1
+	field = hid_register_field(report, usages);
fb3ac1
 	if (!field)
fb3ac1
 		return 0;
fb3ac1
 
fb3ac1
-- 
fb3ac1
2.31.1
fb3ac1
fb3ac1