Skip to content

Commit

Permalink
HID: steam: Prevent NULL pointer dereference in steam_{recv,send}_report
Browse files Browse the repository at this point in the history
It is possible for a malicious device to forgo submitting a Feature
Report.  The HID Steam driver presently makes no prevision for this
and de-references the 'struct hid_report' pointer obtained from the
HID devices without first checking its validity.  Let's change that.

Cc: Jiri Kosina <jikos@kernel.org>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: linux-input@vger.kernel.org
Fixes: c164d6a ("HID: add driver for Valve Steam Controller")
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Lee Jones authored and Jiri Kosina committed Aug 25, 2022
1 parent 8d9420c commit cd11d1a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/hid/hid-steam.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ static int steam_recv_report(struct steam_device *steam,
int ret;

r = steam->hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0];
if (!r) {
hid_err(steam->hdev, "No HID_FEATURE_REPORT submitted - nothing to read\n");
return -EINVAL;
}

if (hid_report_len(r) < 64)
return -EINVAL;

Expand Down Expand Up @@ -165,6 +170,11 @@ static int steam_send_report(struct steam_device *steam,
int ret;

r = steam->hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0];
if (!r) {
hid_err(steam->hdev, "No HID_FEATURE_REPORT submitted - nothing to read\n");
return -EINVAL;
}

if (hid_report_len(r) < 64)
return -EINVAL;

Expand Down

0 comments on commit cd11d1a

Please sign in to comment.