Commit 7cb5ee0e authored by Scott Bauer's avatar Scott Bauer Committed by Ben Hutchings

HID: hiddev: validate num_values for HIDIOCGUSAGES, HIDIOCSUSAGES commands

commit 93a2001b upstream.

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.
Signed-off-by: default avatarScott Bauer <sbauer@plzdonthack.me>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 53056f82
...@@ -515,12 +515,12 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd, ...@@ -515,12 +515,12 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd,
goto inval; goto inval;
} else if (uref->usage_index >= field->report_count) } else if (uref->usage_index >= field->report_count)
goto inval; goto inval;
}
else if ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) && if ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) &&
(uref_multi->num_values > HID_MAX_MULTI_USAGES || (uref_multi->num_values > HID_MAX_MULTI_USAGES ||
uref->usage_index + uref_multi->num_values > field->report_count)) uref->usage_index + uref_multi->num_values > field->report_count))
goto inval; goto inval;
}
switch (cmd) { switch (cmd) {
case HIDIOCGUSAGE: case HIDIOCGUSAGE:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment