Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a195fa4 authored by Pietro Borrello's avatar Pietro Borrello Committed by Greg Kroah-Hartman
Browse files

hid: bigben_probe(): validate report count



[ Upstream commit b94335f899542a0da5fafc38af8edcaf90195843 ]

bigben_probe() does not validate that the output report has the
needed report values in the first field.
A malicious device registering a report with one field and a single
value causes an head OOB write in bigben_worker() when
accessing report_field->value[1] to report_field->value[7].
Use hid_validate_values() which takes care of all the needed checks.

Fixes: 256a90ed ("HID: hid-bigbenff: driver for BigBen Interactive PS3OFMINIPAD gamepad")
Signed-off-by: default avatarPietro Borrello <borrello@diag.uniroma1.it>
Link: https://lore.kernel.org/r/20230211-bigben-oob-v1-1-d2849688594c@diag.uniroma1.it


Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 9f525559
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -371,7 +371,6 @@ static int bigben_probe(struct hid_device *hid,
{
	struct bigben_device *bigben;
	struct hid_input *hidinput;
	struct list_head *report_list;
	struct led_classdev *led;
	char *name;
	size_t name_sz;
@@ -396,14 +395,12 @@ static int bigben_probe(struct hid_device *hid,
		return error;
	}

	report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
	if (list_empty(report_list)) {
	bigben->report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 8);
	if (!bigben->report) {
		hid_err(hid, "no output report found\n");
		error = -ENODEV;
		goto error_hw_stop;
	}
	bigben->report = list_entry(report_list->next,
		struct hid_report, list);

	if (list_empty(&hid->inputs)) {
		hid_err(hid, "no inputs found\n");