From: sashiko-bot@kernel.org
To: "Vicki Pfau" <vi@endrift.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH v2 09/10] HID: steam: Reject short reads
Date: Tue, 07 Jul 2026 23:47:04 +0000 [thread overview]
Message-ID: <20260707234704.AB9211F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260707233241.2644971-10-vi@endrift.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Out-of-bounds stack memory read in `steam_recv_report` when logging debug information.
- [Medium] Uninitialized kernel stack memory read on the error path for short reports.
--
--- Patch [9]: [PATCH v2 09/10] HID: steam: Reject short reads ---
commit ea3743d28300ad972f70af0939882012d7dbf763
Author: Vicki Pfau <vi@endrift.com>
HID: steam: Reject short reads
Steam Controller FEATURE reports encode the size of the message in the
message itself. Previously we were trusting that the size reported matched
the size we actually read, leading to a potential issue with short reads.
Instead, we should actually verify the length of the read.
Fixes: c164d6abf384 ("HID: add driver for Valve Steam Controller")
Reported-by: syzbot+75f3f9bff8c510602d36@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=75f3f9bff8c510602d36
> diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c
> index 1f2cf15d40831..49f6733d89359 100644
> --- a/drivers/hid/hid-steam.c
> +++ b/drivers/hid/hid-steam.c
[ ... ]
> @@ -380,8 +387,10 @@ static int steam_recv_report(struct steam_device *steam,
> buf, hid_report_len(r) + 1,
> HID_FEATURE_REPORT, HID_REQ_GET_REPORT);
> if (ret > 0) {
> - ret = min(size, ret - 1);
> - memcpy(data, buf + 1, ret);
> + /* Remove the report ID from the return buffer */
> + ret--;
> + size = min(size, ret);
> + memcpy(data, buf + 1, size);
> }
> kfree(buf);
>
> @@ -389,7 +398,15 @@ static int steam_recv_report(struct steam_device *steam,
> hid_err(steam->hdev, "%s: error %d\n", __func__, ret);
> else
> hid_dbg(steam->hdev, "Received report %*ph\n", ret, data);
[Severity: Medium]
Since the clamping of ret to size was removed above, ret can now be larger
than the caller-provided buffer size.
If a caller provides a small stack buffer (e.g. 25 bytes in
steam_get_serial()) and the device returns a larger report, will hid_dbg()
read out-of-bounds stack memory from the data buffer when dynamic debug is
enabled?
> - return ret;
> + if (ret < 0)
> + return ret;
> +
> + if (ret < 2 || ret < data[1] + 2) {
> + hid_err(steam->hdev, "%s: expected %u bytes, read %i\n",
> + __func__, data[1] + 2, ret);
[Severity: Medium]
If the device returns a short read of 0 or 1 bytes, memcpy() copies less
than 2 bytes to data, leaving data[1] uninitialized.
Since hid_err() arguments are unconditionally evaluated before the function
is called, could this read uninitialized stack memory from data[1] if
ret < 2 evaluates to true?
> + return -EPROTO;
> + }
> + return size;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260707233241.2644971-1-vi@endrift.com?part=9
next prev parent reply other threads:[~2026-07-07 23:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 23:32 [PATCH v2 00/10] HID: steam: General cleanup and improvements Vicki Pfau
2026-07-07 23:32 ` [PATCH v2 01/10] HID: steam: Update documentation Vicki Pfau
2026-07-07 23:32 ` [PATCH v2 02/10] HID: steam: Refactor and clean up report parsing Vicki Pfau
2026-07-07 23:32 ` [PATCH v2 03/10] HID: steam: Rename some constants that got renamed upstream Vicki Pfau
2026-07-07 23:32 ` [PATCH v2 04/10] HID: steam: Add support for sensor events on the Steam Controller (2015) Vicki Pfau
2026-07-07 23:50 ` sashiko-bot
2026-07-07 23:32 ` [PATCH v2 05/10] HID: steam: Coalesce rumble packets Vicki Pfau
2026-07-07 23:46 ` sashiko-bot
2026-07-07 23:32 ` [PATCH v2 06/10] HID: steam: Fully unregister controller when hidraw is opened Vicki Pfau
2026-07-07 23:52 ` sashiko-bot
2026-07-07 23:32 ` [PATCH v2 07/10] HID: steam: Rearrange deinitialization sequence Vicki Pfau
2026-07-07 23:32 ` [PATCH v2 08/10] HID: steam: Improve logging and other cleanup Vicki Pfau
2026-07-07 23:47 ` sashiko-bot
2026-07-07 23:32 ` [PATCH v2 09/10] HID: steam: Reject short reads Vicki Pfau
2026-07-07 23:47 ` sashiko-bot [this message]
2026-07-07 23:32 ` [PATCH v2 10/10] HID: steam: Retry send/recv reports if stale Vicki Pfau
2026-07-07 23:48 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260707234704.AB9211F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vi@endrift.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox