Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Paolo Pisati" <p.pisati@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH v2 5/7] HID: asus: Do not send feature reports larger than declared
Date: Fri, 09 Oct 2026 15:43:40 +0000	[thread overview]
Message-ID: <sashiko-outbox-165788@kernel.org> (raw)
In-Reply-To: <20261009153459.124752-6-p.pisati@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] hid: asus: handshake string truncated by report size clamping
--

commit fda25fdf61cb84326a7d3ef09500a6da741dd0bc
Author: Paolo Pisati <p.pisati@gmail.com>

HID: asus: Do not send feature reports larger than declared

This commit limits feature report write sizes to the length declared by the
device descriptor. This prevents control transfer timeouts on Zenbook Duo
keyboards, which declare a 15-byte feature report instead of 64 bytes.

> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> index d8a931290c9a7..9e80a2bb54c37 100644
> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c
> @@ -618,6 +618,17 @@ static int asus_raw_event(struct hid_device *hdev,
>  
>  static int asus_kbd_set_report(struct hid_device *hdev, const u8 *buf, size_t buf_size)
>  {
> +	struct hid_report *report;
> +
> +	/*
> +	 * Do not send more than the declared size of the report: the
> +	 * Zenbook Duo keyboards declare report 0x5a as 15 bytes long and
> +	 * do not answer the 64 byte writes sized for the ROG keyboards.
> +	 */
> +	report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[buf[0]];
> +	if (report)
> +		buf_size = min_t(size_t, buf_size, hid_report_len(report));

[Severity: Medium]
Will this clamp the 16-byte initialization handshake buffer and drop its null
terminator?

The commit message notes that "the 16 byte handshake goes through" on the
Zenbook Duo. However, looking at asus_kbd_init(), it sends a 16-byte magic
string for initialization:

	const u8 buf[] = { report_id, 0x41, 0x53, 0x55, 0x53, 0x20, 0x54,
		     0x65, 0x63, 0x68, 0x2e, 0x49, 0x6e, 0x63, 0x2e, 0x00 };
	int ret;

	ret = asus_kbd_set_report(hdev, buf, sizeof(buf));

If the Zenbook Duo declares report 0x5a as 15 bytes, the min_t function will
reduce buf_size to 15. The trailing 0x00 null terminator of "ASUS Tech.Inc.\0"
will be silently truncated before the buffer is duplicated and sent to the
hardware via hid_hw_raw_request().

Could this unterminated string cause the firmware to reject the initialization
sequence?

> +
>  	u8 *dmabuf __free(kfree) = kmemdup(buf, buf_size, GFP_KERNEL);
>  	if (!dmabuf)
>  		return -ENOMEM;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261009153459.124752-1-p.pisati@gmail.com?part=5

  reply	other threads:[~2026-10-09 15:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 15:34 [PATCH v2 0/7] HID: asus: ASUS Zenbook Duo keyboard support Paolo Pisati
2026-10-09 15:34 ` [PATCH v2 1/7] HID: asus: Fix up Zenbook Duo report descriptors Paolo Pisati
2026-10-09 15:34 ` [PATCH v2 2/7] HID: asus: Add missing Zenbook Duo hotkeys Paolo Pisati
2026-10-09 15:34 ` [PATCH v2 3/7] HID: asus: Force hid-input to bind to the Zenbook Duo hotkey interface Paolo Pisati
2026-10-09 15:34 ` [PATCH v2 4/7] HID: asus: Cycle the platform profile from the Zenbook Duo profile key Paolo Pisati
2026-10-09 15:45   ` sashiko-bot
2026-10-09 15:34 ` [PATCH v2 5/7] HID: asus: Do not send feature reports larger than declared Paolo Pisati
2026-10-09 15:43   ` sashiko-bot [this message]
2026-10-09 15:34 ` [PATCH v2 6/7] HID: asus: add prod-id, quirk for Zenbook Duo keyboard Paolo Pisati
2026-10-09 15:45   ` sashiko-bot
2026-10-09 15:34 ` [PATCH v2 7/7] HID: asus: Re-send the Zenbook Duo keyboard handshake after probe Paolo Pisati
2026-10-10  4:44 ` [PATCH v2 0/7] HID: asus: ASUS Zenbook Duo keyboard support Rebecca Mara Müller

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=sashiko-outbox-165788@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=p.pisati@gmail.com \
    --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