All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Denis Benato" <denis.benato@linux.dev>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v11 12/18] HID: asus: size feature reports from the HID report descriptor
Date: Mon, 26 Oct 2026 00:06:18 +0000	[thread overview]
Message-ID: <sashiko-outbox-184550@kernel.org> (raw)
In-Reply-To: <20261025235232.129945-13-denis.benato@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] HID: asus: slab out-of-bounds read in asus_kbd_get_functions()
--

commit c08fc8186d8cfc7d33787c731647d924103580c9
Author: Denis Benato <benato.denis96@gmail.com>

HID: asus: size feature reports from the HID report descriptor

This commit derives feature report transfer lengths dynamically from the
device's HID report descriptor instead of using hardcoded sizes. It adds
asus_report_len() and asus_kbd_get_report(), updates asus_kbd_set_report() to
zero-pad short payloads to the report length, and converts callers to size
their buffers per report.

> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> index ea27495c3df66..fe2a326ccd861 100644
> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c

[ ... ]

> @@ -5426,7 +5521,7 @@ static int asus_kbd_get_functions(struct hid_device *hdev,
>  				  u8 report_id)
>  {
>  	const u8 buf[] = { report_id, 0x05, 0x20, 0x31, 0x00, 0x08 };
> -	u8 *readbuf;
> +	size_t hw_len = asus_report_len(hdev, report_id);
>  	int ret;
>  
>  	ret = asus_kbd_set_report(hdev, buf, sizeof(buf));
> @@ -5435,23 +5530,22 @@ static int asus_kbd_get_functions(struct hid_device *hdev,
>  		return ret;
>  	}
>  
> -	readbuf = kzalloc(FEATURE_KBD_REPORT_SIZE, GFP_KERNEL);
> +	if (!hw_len)
> +		return -EINVAL;
> +
> +	u8 *readbuf __free(kfree) = kzalloc(hw_len, GFP_KERNEL);
>  	if (!readbuf)
>  		return -ENOMEM;
>  
> -	ret = hid_hw_raw_request(hdev, report_id, readbuf,
> -				 FEATURE_KBD_REPORT_SIZE, HID_FEATURE_REPORT,
> -				 HID_REQ_GET_REPORT);
> +	ret = asus_kbd_get_report(hdev, report_id, readbuf, hw_len);
>  	if (ret < 0) {
>  		hid_err(hdev, "Asus failed to request functions: %d\n", ret);
> -		kfree(readbuf);
>  		return ret;
>  	}
>  
>  	*kbd_func = readbuf[6];

[Severity: High]
Can this read past the end of readbuf[] when a device descriptor declares a
6-byte feature report for report_id?

Previously, asus_kbd_get_functions() in drivers/hid/hid-asus.c allocated
readbuf with FEATURE_KBD_REPORT_SIZE (64 bytes). With this change, readbuf is
allocated with size hw_len.

In asus_kbd_get_functions(), sizeof(buf) is 6, so asus_kbd_set_report()
accepts hw_len == 6 via:

    if (!hw_len || buf_size > hw_len)
        return -EINVAL;

asus_kbd_get_functions() then only checks !hw_len before allocating readbuf of
6 bytes and reading readbuf[6] (the 7th byte), resulting in a 1-byte slab
out-of-bounds read during probe via
asus_probe()->asus_kbd_register_leds()->asus_kbd_get_functions().

Should asus_kbd_get_functions() check that hw_len is at least 7 (or
hw_len <= 6) before allocating readbuf and indexing readbuf[6]?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261025235232.129945-1-denis.benato@linux.dev?part=12

  reply	other threads:[~2026-10-26  0:06 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-25 23:52 [PATCH v11 00/18] HID: asus: add support for ROG Ally handhelds Denis Benato
2026-10-25 23:52 ` [PATCH v11 01/18] " Denis Benato
2026-10-26  0:10   ` sashiko-bot
2026-10-26 12:38   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 02/18] HID: asus: add gamepad configuration Denis Benato
2026-10-26  0:10   ` sashiko-bot
2026-10-26 12:56   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 03/18] HID: asus: add vibration strength configuration Denis Benato
2026-10-25 23:52 ` [PATCH v11 04/18] HID: asus: add joysticks inner and outer range configuration Denis Benato
2026-10-26 13:00   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 05/18] HID: asus: add triggers " Denis Benato
2026-10-25 23:52 ` [PATCH v11 06/18] HID: asus: add joysticks anti-deadzone configuration Denis Benato
2026-10-25 23:52 ` [PATCH v11 07/18] HID: asus: add support for response curve Denis Benato
2026-10-26 13:06   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 08/18] HID: asus: add support to force feedback Denis Benato
2026-10-26  0:19   ` sashiko-bot
2026-10-26 12:36   ` Sakari Ailus
2026-10-26 18:21     ` Ilpo Järvinen
2026-10-26 18:27       ` Sakari Ailus
2026-10-26 13:13   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 09/18] HID: asus: add support for gamepad mode Denis Benato
2026-10-26 13:20   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 10/18] HID: asus: add support for turbo buttons Denis Benato
2026-10-26 13:29   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 11/18] HID: asus: add support for btn remapping Denis Benato
2026-10-26  0:06   ` sashiko-bot
2026-10-26 14:03   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 12/18] HID: asus: size feature reports from the HID report descriptor Denis Benato
2026-10-26  0:06   ` sashiko-bot [this message]
2026-10-26 13:06   ` Rebecca Mara Müller
2026-10-26 19:38     ` Denis Benato
2026-10-25 23:52 ` [PATCH v11 13/18] HID: asus: identify XG Mobile stations and bind the LED to the reported model Denis Benato
2026-10-25 23:52 ` [PATCH v11 14/18] HID: asus: expose XG Mobile identity and firmware information Denis Benato
2026-10-26  0:05   ` sashiko-bot
2026-10-26 14:10   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 15/18] HID: asus: size ally gamepad commands from the HID report descriptor Denis Benato
2026-10-26  0:10   ` sashiko-bot
2026-10-25 23:52 ` [PATCH v11 16/18] platform/x86: asus-armoury: pick the eGPU activation from the reported GPU Denis Benato
2026-10-25 23:52 ` [PATCH v11 17/18] HID: asus: report the XG Mobile GPU vendor to asus-wmi Denis Benato
2026-10-26  0:03   ` sashiko-bot
2026-10-26 14:15   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 18/18] MAINTAINERS: add maintainer for the ASUS HID driver Denis Benato
2026-10-26 14:24 ` [PATCH v11 00/18] HID: asus: add support for ROG Ally handhelds Ilpo Järvinen
2026-10-26 18:03   ` Denis Benato

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-184550@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=denis.benato@linux.dev \
    --cc=dmitry.torokhov@gmail.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 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.