* [PATCH] hid: bigben_probe(): validate report count
@ 2023-02-12 0:01 Pietro Borrello
2023-02-16 11:33 ` Benjamin Tissoires
0 siblings, 1 reply; 2+ messages in thread
From: Pietro Borrello @ 2023-02-12 0:01 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires, Hanno Zulla
Cc: Jiri Kosina, linux-input, linux-kernel, Pietro Borrello
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: 256a90ed9e46 ("HID: hid-bigbenff: driver for BigBen Interactive PS3OFMINIPAD gamepad")
Signed-off-by: Pietro Borrello <borrello@diag.uniroma1.it>
---
drivers/hid/hid-bigbenff.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/hid/hid-bigbenff.c b/drivers/hid/hid-bigbenff.c
index e8b16665860d..1d0033a008ac 100644
--- a/drivers/hid/hid-bigbenff.c
+++ b/drivers/hid/hid-bigbenff.c
@@ -318,7 +318,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;
@@ -343,14 +342,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");
---
base-commit: 4ec5183ec48656cec489c49f989c508b68b518e3
change-id: 20230211-bigben-oob-8dd66a3c3cb3
Best regards,
--
Pietro Borrello <borrello@diag.uniroma1.it>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] hid: bigben_probe(): validate report count
2023-02-12 0:01 [PATCH] hid: bigben_probe(): validate report count Pietro Borrello
@ 2023-02-16 11:33 ` Benjamin Tissoires
0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Tissoires @ 2023-02-16 11:33 UTC (permalink / raw)
To: Jiri Kosina, Hanno Zulla, Pietro Borrello
Cc: Jiri Kosina, linux-input, linux-kernel
On Sun, 12 Feb 2023 00:01:44 +0000, Pietro Borrello wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] hid: bigben_probe(): validate report count
commit: b94335f899542a0da5fafc38af8edcaf90195843
Best regards,
--
Benjamin Tissoires <benjamin.tissoires@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-02-16 11:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-12 0:01 [PATCH] hid: bigben_probe(): validate report count Pietro Borrello
2023-02-16 11:33 ` Benjamin Tissoires
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).