aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorScott Bauer <sbauer@plzdonthack.me>2016-06-23 08:59:47 -0600
committerSimon Shields <keepcalm444@gmail.com>2016-06-30 18:22:06 +1000
commit219a2d78a8bc79df201c45a78a5ece714c002704 (patch)
tree75528a9ac4ba5ec464ce93c9fbc2e6853834ac6e /drivers
parent28ea59dc1c4781c819996a65e60aa773f1da6765 (diff)
downloadkernel_samsung_smdk4412-219a2d78a8bc79df201c45a78a5ece714c002704.tar.gz
kernel_samsung_smdk4412-219a2d78a8bc79df201c45a78a5ece714c002704.tar.bz2
kernel_samsung_smdk4412-219a2d78a8bc79df201c45a78a5ece714c002704.zip
HID: hiddev: validate num_values for HIDIOCGUSAGES, HIDIOCSUSAGES commands
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. Change-Id: I10866ee01c7ba430eab2b5cc3356c9519c7f9730 Cc: stable@vger.kernel.org Signed-off-by: Scott Bauer <sbauer@plzdonthack.me> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hid/usbhid/hiddev.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 7c1188b53c3..fd78f2b6f48 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -515,13 +515,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];