Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Even Xu" <even.xu@intel.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH 2/2] HID: Intel-thc-hid: Intel-quickspi: Use hid_safe_input_report()
Date: Tue, 22 Sep 2026 03:05:21 +0000	[thread overview]
Message-ID: <20260922030521.C9CAA1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260922025437.940072-3-even.xu@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] hid: intel-thc-hid: heap OOB write and report rejection due to incorrect buf_size
--

commit 89b3a4008ccfc5430514595b9a4bdb1131455535
Author: Even Xu <even.xu@intel.com>

    HID: Intel-thc-hid: Intel-quickspi: Use hid_safe_input_report()
    
    Replace the deprecated hid_input_report() with
    hid_safe_input_report(), which takes the allocated size of the input
    report buffer and allows hid-core to validate the reported data length
    against the actual buffer size.
    
    Track the allocated size of qsdev->input_buf in the new input_len
    field and pass it through quickspi_hid_send_report() to
    hid_safe_input_report() to prevent potential out-of-bounds reads.

> diff --git a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c
> index 847c5ec55569a..0df33c44fbffe 100644
> --- a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c
> +++ b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c
> @@ -240,7 +240,7 @@ void quickspi_handle_input_data(struct quickspi_device *qsdev, u32 buf_len)
>  		input_len = sizeof(body_hdr->content_id) + input_len;
>  		input_report = input_body->content - sizeof(body_hdr->content_id);
>  
> -		ret = quickspi_hid_send_report(qsdev, input_report, input_len);
> +		ret = quickspi_hid_send_report(qsdev, input_report, qsdev->input_len, input_len);

[Severity: High]
Does passing qsdev->input_len as the buf_size here overstate the available
buffer space?

In quickspi_handle_input_data(), input_report is calculated as an offset into
the allocated buffer:

    input_report = input_body->content - sizeof(body_hdr->content_id);

This offsets the pointer by 3 bytes into the qsdev->input_buf allocation.
However, qsdev->input_len represents the total allocation size, not the
remaining space from the input_report pointer.

When this overstated size reaches hid_safe_input_report(), if a short report
requires padding, hid_report_raw_event() in the HID core could write up to
3 bytes past the end of the qsdev->input_buf allocation via memset(), causing
a heap out-of-bounds write.

Additionally, if a maximum-sized report is received, the data length will
strictly exceed the stated buf_size, causing the HID core to falsely reject
the report with -EINVAL.

Should the buf_size passed to quickspi_hid_send_report() account for the
offset into the buffer?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260922025437.940072-1-even.xu@intel.com?part=2

  reply	other threads:[~2026-09-22  3:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22  2:54 [PATCH 0/2] HID: Intel-thc-hid: Use hid_safe_input_report() Even Xu
2026-09-22  2:54 ` [PATCH 1/2] HID: Intel-thc-hid: Intel-quicki2c: " Even Xu
2026-09-22  3:03   ` sashiko-bot
2026-09-22  2:54 ` [PATCH 2/2] HID: Intel-thc-hid: Intel-quickspi: " Even Xu
2026-09-22  3:05   ` sashiko-bot [this message]
2026-09-23 16:50 ` [PATCH 0/2] HID: Intel-thc-hid: " Jiri Kosina
2026-09-23 23:55   ` Xu, Even

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=20260922030521.C9CAA1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=even.xu@intel.com \
    --cc=linux-input@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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