HID: hiddev: validate num_values for HIDIOCGUSAGES, HIDIOCSUSAGES commands (CVE-2016-5829)

This commit is contained in:
Salvatore Bonaccorso 2016-06-30 14:49:56 +02:00
parent 419d6356df
commit 3c35987b05
3 changed files with 50 additions and 0 deletions

5
debian/changelog vendored
View File

@ -1,5 +1,6 @@
linux (4.6.3-1) UNRELEASED; urgency=medium
[ Ben Hutchings ]
* New upstream stable update:
https://www.kernel.org/pub/linux/kernel/v4.x/ChangeLog-4.6.3
- scsi_lib: correctly retry failed zero length REQ_TYPE_FS commands
@ -67,6 +68,10 @@ linux (4.6.3-1) UNRELEASED; urgency=medium
- [x86] Revert "drm/i915: Exit cherryview_irq_handler() after one pass"
- gpio: make sure gpiod_to_irq() returns negative on NULL desc
[ Salvatore Bonaccorso ]
* HID: hiddev: validate num_values for HIDIOCGUSAGES, HIDIOCSUSAGES commands
(CVE-2016-5829)
-- Ben Hutchings <ben@decadent.org.uk> Mon, 27 Jun 2016 00:31:11 +0200
linux (4.6.2-2) unstable; urgency=medium

View File

@ -0,0 +1,44 @@
From: Scott Bauer <sbauer@plzdonthack.me>
Date: Thu, 23 Jun 2016 08:59:47 -0600
Subject: HID: hiddev: validate num_values for HIDIOCGUSAGES, HIDIOCSUSAGES
commands
Origin: https://git.kernel.org/linus/93a2001bdfd5376c3dc2158653034c20392d15c5
This patch validates the num_values parameter from userland during the
HIDIOCGUSAGES and HIDIOCSUSAGES commands. Previously, if the report id was set
to HID_REPORT_ID_UNKNOWN, we would fail to validate the num_values parameter
leading to a heap overflow.
Cc: stable@vger.kernel.org
Signed-off-by: Scott Bauer <sbauer@plzdonthack.me>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
---
drivers/hid/usbhid/hiddev.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 2f1ddca..700145b 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -516,13 +516,13 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd,
goto inval;
} else if (uref->usage_index >= field->report_count)
goto inval;
-
- else if ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) &&
- (uref_multi->num_values > HID_MAX_MULTI_USAGES ||
- uref->usage_index + uref_multi->num_values > field->report_count))
- goto inval;
}
+ if ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) &&
+ (uref_multi->num_values > HID_MAX_MULTI_USAGES ||
+ uref->usage_index + uref_multi->num_values > field->report_count))
+ goto inval;
+
switch (cmd) {
case HIDIOCGUSAGE:
uref->value = field->value[uref->usage_index];
--
2.8.1

View File

@ -113,6 +113,7 @@ bugfix/all/percpu-fix-synchronization-between-chunk-map_extend_.patch
bugfix/all/percpu-fix-synchronization-between-synchronous-map-e.patch
bugfix/all/posix_acl-add-set_posix_acl.patch
bugfix/all/nfsd-check-permissions-when-setting-acls.patch
bugfix/all/HID-hiddev-validate-num_values-for-HIDIOCGUSAGES-HID.patch
# ABI maintenance
debian/mips-siginfo-fix-abi-change-in-4.6.2.patch