Skip to content

Commit b94335f

Browse files
pietroborrellobentiss
authored andcommitted
hid: bigben_probe(): validate report count
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: 256a90e ("HID: hid-bigbenff: driver for BigBen Interactive PS3OFMINIPAD gamepad") Signed-off-by: Pietro Borrello <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Benjamin Tissoires <[email protected]>
1 parent 76ca8da commit b94335f

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

drivers/hid/hid-bigbenff.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ static int bigben_probe(struct hid_device *hid,
371371
{
372372
struct bigben_device *bigben;
373373
struct hid_input *hidinput;
374-
struct list_head *report_list;
375374
struct led_classdev *led;
376375
char *name;
377376
size_t name_sz;
@@ -396,14 +395,12 @@ static int bigben_probe(struct hid_device *hid,
396395
return error;
397396
}
398397

399-
report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
400-
if (list_empty(report_list)) {
398+
bigben->report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 8);
399+
if (!bigben->report) {
401400
hid_err(hid, "no output report found\n");
402401
error = -ENODEV;
403402
goto error_hw_stop;
404403
}
405-
bigben->report = list_entry(report_list->next,
406-
struct hid_report, list);
407404

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

0 commit comments

Comments
 (0)