HID: steam: Prevent NULL pointer dereference in steam_{recv,send}_report
Subsystems (2)
PATCH 1/1 HID: steam: Prevent NULL pointer dereference in steam_{recv,send}_report
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.
--- drivers/hid/hid-steam.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/hid/hid-steam.c +10 -0
@@ -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 ;
@@ -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 ;
Signature · 1 line
2.37.0.rc0.161.g10f37bed90-goog
Quoted 5 lines · Lee Jones
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.
Quoted 8 lines
Cc Jiri Kosina <[email protected]>Cc Benjamin Tissoires <[email protected]>Fixes c164d6abf3841 ("HID: add driver for Valve Steam Controller")Signed-off-by Lee Jones <[email protected]>--- drivers/hid/hid-steam.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
Did anyone get a chance to look at this?
Would you like me to submit a [RESEND]?
Quoted 28 lines
drivers/hid/hid-steam.c +10
-0@@ -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 ;@@ -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 ;
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Jiri Kosina
maintainerQuoted 10 lines · Lee Jones
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 <[email protected]>Cc Benjamin Tissoires <[email protected]>Fixes c164d6abf3841 ("HID: add driver for Valve Steam Controller")Signed-off-by Lee Jones <[email protected]>
Sorry for the delay, I had some time off and things got stalled. Applied now, thank you.
Signature · 2 lines
Jiri Kosina SUSE Labs