提交 6e6e3cd9 编写于 作者: L Lee Jones 提交者: openeuler-sync-bot

HID: steam: Prevent NULL pointer dereference in steam_{recv,send}_report

stable inclusion
from stable-v5.10.141
commit dc815761948ab5b8c94db6cb53c95103588f16ae
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I685FC

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=dc815761948ab5b8c94db6cb53c95103588f16ae

--------------------------------

commit cd11d1a6 upstream.

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: c164d6ab ("HID: add driver for Valve Steam Controller")
Signed-off-by: NLee Jones <lee.jones@linaro.org>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
Reviewed-by: NZheng Zengkai <zhengzengkai@huawei.com>
(cherry picked from commit c9d1231b)
上级 67aad65b
...@@ -134,6 +134,11 @@ static int steam_recv_report(struct steam_device *steam, ...@@ -134,6 +134,11 @@ static int steam_recv_report(struct steam_device *steam,
int ret; int ret;
r = steam->hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0]; 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) if (hid_report_len(r) < 64)
return -EINVAL; return -EINVAL;
...@@ -165,6 +170,11 @@ static int steam_send_report(struct steam_device *steam, ...@@ -165,6 +170,11 @@ static int steam_send_report(struct steam_device *steam,
int ret; int ret;
r = steam->hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0]; 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) if (hid_report_len(r) < 64)
return -EINVAL; return -EINVAL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册