From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: shashikiranah@chromium.org
Cc: Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>,
Stephen Boyd <swboyd@chromium.org>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Tzung-Bi Shih <tzungbi@chromium.org>,
Sean O'Brien <seobrien@chromium.org>
Subject: Re: [PATCH] HID: vivaldi: Validate Report ID and length in feature mapping
Date: Thu, 8 Oct 2026 12:23:12 -0700 [thread overview]
Message-ID: <asfk_jRVjY8pXzjt@google.com> (raw)
In-Reply-To: <20261006-upstream-vivaldi-fix-v1-1-bbc9a7f14ea6@chromium.org>
Hi Shashikirana,
On Tue, Oct 06, 2026 at 03:06:59PM +0000, Shashikirana H K via B4 Relay wrote:
> From: Shashikirana H K <shashikiranah@chromium.org>
>
> vivaldi_feature_mapping() currently passes the descriptor-declared
> report_len as the received data size to hid_report_raw_event() instead
> of the actual number of bytes returned by hid_hw_raw_request(). It also
> does not verify that the returned Report ID matches the requested
> report->id, or handle a zero-byte return before decrementing the length
> for unnumbered reports.
>
> Validate that hid_hw_raw_request() returns at least one byte and that
> the returned Report ID matches report->id, and pass the actual received
> byte count (ret) to hid_report_raw_event().
>
> Fixes: 33bbe04a15f2 ("HID: google: extract Vivaldi hid feature mapping for use in hid-hammer")
> Cc: Tzung-Bi Shih <tzungbi@chromium.org>
> Cc: Sean O'Brien <seobrien@chromium.org>
> Signed-off-by: Shashikirana H K <shashikiranah@chromium.org>
> ---
> Change-Id: I3cf03bd2457f44c6ed47835f3d603f235f5993de
> ---
> drivers/hid/hid-vivaldi-common.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hid/hid-vivaldi-common.c b/drivers/hid/hid-vivaldi-common.c
> index b12bb5cc091aa..ea2c661e623d1 100644
> --- a/drivers/hid/hid-vivaldi-common.c
> +++ b/drivers/hid/hid-vivaldi-common.c
> @@ -69,12 +69,18 @@ void vivaldi_feature_mapping(struct hid_device *hdev,
> ret = hid_hw_raw_request(hdev, report->id, report_data,
> report_len, HID_FEATURE_REPORT,
> HID_REQ_GET_REPORT);
> - if (ret < 0) {
> + if (ret <= 0) {
> dev_warn(&hdev->dev, "failed to fetch feature %d\n",
> field->report->id);
> goto out;
> }
>
> + if (report->id && report_data[0] != report->id) {
I do not think checking whether report is numbered is needed. While
transports handle numbered and non-numbered reports differently here I
believe we always have report number (0 for unnumbered) in first byte.
Also, shouldn't this check be in hid core if it is needed?
> + dev_warn(&hdev->dev, "report ID mismatch: expected %d got %d\n",
> + report->id, report_data[0]);
> + goto out;
> + }
> +
> if (!report->id) {
> /*
> * Undo the damage from hid_hw_raw_request() for unnumbered
> @@ -82,10 +88,11 @@ void vivaldi_feature_mapping(struct hid_device *hdev,
> */
> report_data++;
> report_len--;
> + ret--;
> }
>
> ret = hid_report_raw_event(hdev, HID_FEATURE_REPORT, report_data,
> - report_len, report_len, 0);
> + report_len, ret, 0);
Devices typically do not return short reports. Could you please tell me
what prompted this change?
Thanks.
--
Dmitry
next prev parent reply other threads:[~2026-10-08 19:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 15:06 [PATCH] HID: vivaldi: Validate Report ID and length in feature mapping Shashikirana H K via B4 Relay
2026-10-06 15:06 ` Shashikirana H K
2026-10-08 19:23 ` Dmitry Torokhov [this message]
2026-10-11 17:29 ` Shashikirana H K
2026-10-13 0:22 ` Dmitry Torokhov
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=asfk_jRVjY8pXzjt@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=bentiss@kernel.org \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=seobrien@chromium.org \
--cc=shashikiranah@chromium.org \
--cc=swboyd@chromium.org \
--cc=tzungbi@chromium.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.