All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] HID: asus: fix touchpad multitouch initialization regression
@ 2026-08-18  8:25 PANZ
  2026-08-18  8:38 ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: PANZ @ 2026-08-18  8:25 UTC (permalink / raw)
  To: jikos, bentiss; +Cc: denis.benato, linux-input, linux-kernel, stable

In Linux 7.1, commit 7253091766de ("HID: asus: do not abort probe when
not necessary")
and commit 0919db9f3583 ("HID: asus: always fully initialize devices")
introduced regressions in the probe sequence for ASUS I2C/HID touchpads
(such as on the ASUS E200HA):

1. asus_start_multitouch() was placed inside the claimed input check block:
     if (drvdata->input && (hdev->claimed & HID_CLAIMED_INPUT))
   On ASUS touchpads, (hdev->claimed & HID_CLAIMED_INPUT) evaluates to
   false during asus_probe(), skipping asus_start_multitouch().

2. The asus_report_id_init loop in asus_probe() was executed unconditionally
   for all devices, which sends keyboard initialization feature requests
   (asus_kbd_init) to touchpad endpoints, corrupting touchpad probe state.

This patch fixes both issues by:
- Skipping keyboard report initialization for touchpad devices (!drvdata->tp).
- Moving asus_start_multitouch() outside the claimed input check block so
  multitouch initialization is always executed for touchpads.

Tested on ASUS E200HA (where touchpad functionality is fully restored)
and ASUS VivoBook Flip 14 TP401MA (confirming zero regressions).

Fixes: 7253091766de ("HID: asus: do not abort probe when not necessary")
Fixes: 0919db9f3583 ("HID: asus: always fully initialize devices")
Cc: stable@vger.kernel.org
Signed-off-by: ppanzenboeck <panz.development@gmail.com>
---
 drivers/hid/hid-asus.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 3f5e96900b67..7f19ca1e5a1b 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -1294,12 +1294,14 @@ static int asus_probe(struct hid_device *hdev,
const struct hid_device_id *id)
  return ret;
  }

- for (int r = 0; r < ARRAY_SIZE(asus_report_id_init); r++) {
- if (asus_has_report_id(hdev, asus_report_id_init[r])) {
- ret = asus_kbd_init(hdev, asus_report_id_init[r]);
- if (ret < 0)
- hid_warn(hdev, "Failed to initialize 0x%x: %d.\n",
- asus_report_id_init[r], ret);
+ if (!drvdata->tp) {
+ for (int r = 0; r < ARRAY_SIZE(asus_report_id_init); r++) {
+ if (asus_has_report_id(hdev, asus_report_id_init[r])) {
+ ret = asus_kbd_init(hdev, asus_report_id_init[r]);
+ if (ret < 0)
+ hid_warn(hdev, "Failed to initialize 0x%x: %d.\n",
+ asus_report_id_init[r], ret);
+ }
  }
  }

@@ -1327,12 +1329,12 @@ static int asus_probe(struct hid_device *hdev,
const struct hid_device_id *id)
  drvdata->input->name = "Asus TouchPad";
  else
  drvdata->input->name = "Asus Keyboard";
+ }

- if (drvdata->tp) {
- ret = asus_start_multitouch(hdev);
- if (ret)
- goto err_stop_hw;
- }
+ if (drvdata->tp) {
+ ret = asus_start_multitouch(hdev);
+ if (ret)
+ goto err_stop_hw;
  }

  return 0;
-- 
2.47.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] HID: asus: fix touchpad multitouch initialization regression
  2026-08-18  8:25 PANZ
@ 2026-08-18  8:38 ` Greg KH
  0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2026-08-18  8:38 UTC (permalink / raw)
  To: PANZ; +Cc: jikos, bentiss, denis.benato, linux-input, linux-kernel, stable

On Tue, Aug 18, 2026 at 10:25:27AM +0200, PANZ wrote:
> In Linux 7.1, commit 7253091766de ("HID: asus: do not abort probe when
> not necessary")
> and commit 0919db9f3583 ("HID: asus: always fully initialize devices")
> introduced regressions in the probe sequence for ASUS I2C/HID touchpads
> (such as on the ASUS E200HA):
> 
> 1. asus_start_multitouch() was placed inside the claimed input check block:
>      if (drvdata->input && (hdev->claimed & HID_CLAIMED_INPUT))
>    On ASUS touchpads, (hdev->claimed & HID_CLAIMED_INPUT) evaluates to
>    false during asus_probe(), skipping asus_start_multitouch().
> 
> 2. The asus_report_id_init loop in asus_probe() was executed unconditionally
>    for all devices, which sends keyboard initialization feature requests
>    (asus_kbd_init) to touchpad endpoints, corrupting touchpad probe state.
> 
> This patch fixes both issues by:
> - Skipping keyboard report initialization for touchpad devices (!drvdata->tp).
> - Moving asus_start_multitouch() outside the claimed input check block so
>   multitouch initialization is always executed for touchpads.
> 
> Tested on ASUS E200HA (where touchpad functionality is fully restored)
> and ASUS VivoBook Flip 14 TP401MA (confirming zero regressions).
> 
> Fixes: 7253091766de ("HID: asus: do not abort probe when not necessary")
> Fixes: 0919db9f3583 ("HID: asus: always fully initialize devices")
> Cc: stable@vger.kernel.org
> Signed-off-by: ppanzenboeck <panz.development@gmail.com>


Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch is malformed (tabs converted to spaces, linewrapped, etc.)
  and can not be applied.  Please read the file,
  Documentation/process/email-clients.rst in order to fix this.

- It looks like you did not use your "real" name for the patch on either
  the Signed-off-by: line, or the From: line (both of which have to
  match).  Please read the kernel file,
  Documentation/process/submitting-patches.rst for how to do this
  correctly.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] HID: asus: fix touchpad multitouch initialization regression
@ 2026-08-18  8:56 Panz Dev
  2026-08-18  9:13 ` Denis Benato
  2026-08-18  9:15 ` sashiko-bot
  0 siblings, 2 replies; 6+ messages in thread
From: Panz Dev @ 2026-08-18  8:56 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires
  Cc: Denis Benato, linux-input, linux-kernel, stable, Panz Dev

In Linux 7.1, commit 7253091766de ("HID: asus: do not abort probe when not necessary")
and commit 0919db9f3583 ("HID: asus: always fully initialize devices")
introduced regressions in the probe sequence for ASUS I2C/HID touchpads
(such as on the ASUS E200HA):

1. asus_start_multitouch() was placed inside the claimed input check block:
     if (drvdata->input && (hdev->claimed & HID_CLAIMED_INPUT))
   On ASUS touchpads, (hdev->claimed & HID_CLAIMED_INPUT) evaluates to
   false during asus_probe(), skipping asus_start_multitouch().

2. The asus_report_id_init loop in asus_probe() was executed unconditionally
   for all devices, which sends keyboard initialization feature requests
   (asus_kbd_init) to touchpad endpoints, corrupting touchpad probe state.

This patch fixes both issues by:
- Skipping keyboard report initialization for touchpad devices (!drvdata->tp).
- Moving asus_start_multitouch() outside the claimed input check block so
  multitouch initialization is always executed for touchpads.

Tested on ASUS E200HA (where touchpad functionality is fully restored)
and ASUS VivoBook Flip 14 TP401MA (confirming zero regressions).

Fixes: 7253091766de ("HID: asus: do not abort probe when not necessary")
Fixes: 0919db9f3583 ("HID: asus: always fully initialize devices")
Cc: stable@vger.kernel.org
Signed-off-by: Panz Dev <panz.development@gmail.com>
---
 drivers/hid/hid-asus.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 3f5e96900b67..7f19ca1e5a1b 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -1294,12 +1294,14 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		return ret;
 	}

-	for (int r = 0; r < ARRAY_SIZE(asus_report_id_init); r++) {
-		if (asus_has_report_id(hdev, asus_report_id_init[r])) {
-			ret = asus_kbd_init(hdev, asus_report_id_init[r]);
-			if (ret < 0)
-				hid_warn(hdev, "Failed to initialize 0x%x: %d.\n",
-					 asus_report_id_init[r], ret);
+	if (!drvdata->tp) {
+		for (int r = 0; r < ARRAY_SIZE(asus_report_id_init); r++) {
+			if (asus_has_report_id(hdev, asus_report_id_init[r])) {
+				ret = asus_kbd_init(hdev, asus_report_id_init[r]);
+				if (ret < 0)
+					hid_warn(hdev, "Failed to initialize 0x%x: %d.\n",
+						 asus_report_id_init[r], ret);
+			}
 		}
 	}

@@ -1327,12 +1329,12 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
 			drvdata->input->name = "Asus TouchPad";
 		else
 			drvdata->input->name = "Asus Keyboard";
+	}

-		if (drvdata->tp) {
-			ret = asus_start_multitouch(hdev);
-			if (ret)
-				goto err_stop_hw;
-		}
+	if (drvdata->tp) {
+		ret = asus_start_multitouch(hdev);
+		if (ret)
+			goto err_stop_hw;
 	}

 	return 0;
-- 
2.47.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] HID: asus: fix touchpad multitouch initialization regression
  2026-08-18  8:56 [PATCH] HID: asus: fix touchpad multitouch initialization regression Panz Dev
@ 2026-08-18  9:13 ` Denis Benato
  2026-08-18  9:15 ` sashiko-bot
  1 sibling, 0 replies; 6+ messages in thread
From: Denis Benato @ 2026-08-18  9:13 UTC (permalink / raw)
  To: Panz Dev, Jiri Kosina, Benjamin Tissoires
  Cc: linux-input, linux-kernel, stable


On 8/18/26 10:56, Panz Dev wrote:
> In Linux 7.1, commit 7253091766de ("HID: asus: do not abort probe when not necessary")
> and commit 0919db9f3583 ("HID: asus: always fully initialize devices")
> introduced regressions in the probe sequence for ASUS I2C/HID touchpads
> (such as on the ASUS E200HA):
>
> 1. asus_start_multitouch() was placed inside the claimed input check block:
>      if (drvdata->input && (hdev->claimed & HID_CLAIMED_INPUT))
>    On ASUS touchpads, (hdev->claimed & HID_CLAIMED_INPUT) evaluates to
>    false during asus_probe(), skipping asus_start_multitouch().
>
> 2. The asus_report_id_init loop in asus_probe() was executed unconditionally
>    for all devices, which sends keyboard initialization feature requests
>    (asus_kbd_init) to touchpad endpoints, corrupting touchpad probe state.
>
> This patch fixes both issues by:
> - Skipping keyboard report initialization for touchpad devices (!drvdata->tp).
> - Moving asus_start_multitouch() outside the claimed input check block so
>   multitouch initialization is always executed for touchpads.
>
> Tested on ASUS E200HA (where touchpad functionality is fully restored)
> and ASUS VivoBook Flip 14 TP401MA (confirming zero regressions).
Hi,

thanks for this! I forgot to exclude touchpads from that init sequence.
> Fixes: 7253091766de ("HID: asus: do not abort probe when not necessary")
> Fixes: 0919db9f3583 ("HID: asus: always fully initialize devices")
> Cc: stable@vger.kernel.org
> Signed-off-by: Panz Dev <panz.development@gmail.com>
> ---
>  drivers/hid/hid-asus.c | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> index 3f5e96900b67..7f19ca1e5a1b 100644
> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c
> @@ -1294,12 +1294,14 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
>  		return ret;
>  	}
>
> -	for (int r = 0; r < ARRAY_SIZE(asus_report_id_init); r++) {
> -		if (asus_has_report_id(hdev, asus_report_id_init[r])) {
> -			ret = asus_kbd_init(hdev, asus_report_id_init[r]);
> -			if (ret < 0)
> -				hid_warn(hdev, "Failed to initialize 0x%x: %d.\n",
> -					 asus_report_id_init[r], ret);
> +	if (!drvdata->tp) {
> +		for (int r = 0; r < ARRAY_SIZE(asus_report_id_init); r++) {
> +			if (asus_has_report_id(hdev, asus_report_id_init[r])) {
> +				ret = asus_kbd_init(hdev, asus_report_id_init[r]);
> +				if (ret < 0)
> +					hid_warn(hdev, "Failed to initialize 0x%x: %d.\n",
> +						 asus_report_id_init[r], ret);
> +			}
>  		}
>  	}
>
> @@ -1327,12 +1329,12 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
>  			drvdata->input->name = "Asus TouchPad";
>  		else
>  			drvdata->input->name = "Asus Keyboard";
> +	}
>
> -		if (drvdata->tp) {
> -			ret = asus_start_multitouch(hdev);
> -			if (ret)
> -				goto err_stop_hw;
> -		}
> +	if (drvdata->tp) {
> +		ret = asus_start_multitouch(hdev);
> +		if (ret)
> +			goto err_stop_hw;
>  	}
I think this will re-introduce the security vulnerability fixed in the commit that led to me
creating the "HID: asus: do not abort probe when unnecessary"...

Furthermore if that drvdata->input && (hdev->claumed & HID_CLAIMED_INPUT) doesn't
evaluate to true it would be useful to know what part is false and that code that prevents
null/invalid dereference is wrong, and since I tried touching it the least possible it means
there is also the need to change the && back into ||, but that would undo the "keep the
proper name of the device" for keyboards...

With these in mind would you want to try fixing them all at once?
>  	return 0;

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] HID: asus: fix touchpad multitouch initialization regression
  2026-08-18  8:56 [PATCH] HID: asus: fix touchpad multitouch initialization regression Panz Dev
  2026-08-18  9:13 ` Denis Benato
@ 2026-08-18  9:15 ` sashiko-bot
  2026-08-18 15:16   ` Panz Dev
  1 sibling, 1 reply; 6+ messages in thread
From: sashiko-bot @ 2026-08-18  9:15 UTC (permalink / raw)
  To: Panz Dev; +Cc: dmitry.torokhov, linux-input

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:

New issues:
- [High] Unconditionally calling `asus_start_multitouch()` outside the `HID_CLAIMED_INPUT` check introduces a Use-After-Free if input registration fails.

Pre-existing issues:
- [High] Incorrect cleanup order in `asus_remove()` creates a Use-After-Free race condition by cancelling the workqueue before disabling hardware events.
- [High] Missing `hid_is_usb()` check in `asus_kbd_register_leds()` allows an invalid cast to `usb_interface`, causing out-of-bounds reads or crashes.
- [Medium] Modifying `input->name` after device registration creates a data race and violates input subsystem API requirements.
--

--- Patch [1]: [PATCH] HID: asus: fix touchpad multitouch initialization regression ---
commit 53becd94719f665ca15fc8c3f4b7876a402da45f
Author: Panz Dev <panz.development@gmail.com>

HID: asus: fix touchpad multitouch initialization regression

This patch fixes probe regressions for ASUS I2C/HID touchpads by skipping
keyboard report initialization for touchpads and moving
asus_start_multitouch() outside the claimed input check block.

> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> index 3f5e96900b67a..72b93bdeb4e8f 100644
> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c
[ ... ]
> @@ -1327,12 +1329,12 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
>  			drvdata->input->name = "Asus TouchPad";
>  		else
>  			drvdata->input->name = "Asus Keyboard";

[Severity: Medium]
This is a pre-existing issue, but can modifying drvdata->input->name here
after device registration (which occurs earlier during hid_hw_start) create a
data race?

If a userspace process like udev reads the name attribute concurrently, might
it read the default string or race with the pointer reassignment?

> +	}
>  
> -		if (drvdata->tp) {
> -			ret = asus_start_multitouch(hdev);
> -			if (ret)
> -				goto err_stop_hw;
> -		}
> +	if (drvdata->tp) {
> +		ret = asus_start_multitouch(hdev);
> +		if (ret)
> +			goto err_stop_hw;
>  	}

[Severity: High]
Does moving asus_start_multitouch() outside the HID_CLAIMED_INPUT check
introduce a use-after-free regression if input registration fails?

If input_register_device() fails during hid_hw_start(), hidinput_connect()
frees the allocated input_dev and returns an error without setting
HID_CLAIMED_INPUT.

Since the HID_CLAIMED_INPUT safety guard is now removed, the driver
will force the touchpad hardware to start sending reports. When the hardware
interrupt arrives, asus_raw_event() intercepts it and routes to
asus_report_input():

drivers/hid/hid-asus.c:asus_raw_event() {
    ...
	if (drvdata->tp && data[0] == INPUT_REPORT_ID)
		return asus_report_input(drvdata, data, size);
    ...
}

This blindly dereferences the freed drvdata->input pointer, which was assigned
earlier in asus_input_configured():

drivers/hid/hid-asus.c:asus_report_input() {
    ...
		input_mt_slot(drvdat->input, i);
		input_mt_report_slot_state(drvdat->input, toolType, down);
    ...
}

Is it possible for this to cause a use-after-free, for instance if triggered
via uhid device spoofing or resource allocation failures during probe?

>  
>  	return 0;

[Severity: High]
This isn't a bug introduced by this patch, but does the cleanup order in
asus_remove() create a use-after-free race condition?

In asus_remove(), the driver calls:

drivers/hid/hid-asus.c:asus_remove() {
    ...
	if (drvdata->quirks & QUIRK_HID_FN_LOCK)
		cancel_work_sync(&drvdata->fn_lock_sync_work);

	hid_hw_stop(hdev);
    ...
}

If the device sends a KEY_FN_ESC report via hardware interrupt immediately
after cancel_work_sync() returns but before hid_hw_stop() completes, might
asus_event() re-queue the work via schedule_work()? Once asus_remove()
finishes, the devm-managed drvdata is freed, which could leave the work item
scheduled and lead to a use-after-free when the worker executes.

[Severity: High]
This is a pre-existing issue, but could the lack of a hid_is_usb() check in
asus_kbd_register_leds() allow an invalid cast?

When handling the QUIRK_ROG_ALLY_XPAD quirk:

drivers/hid/hid-asus.c:asus_kbd_register_leds() {
    ...
	if (drvdata->quirks & QUIRK_ROG_ALLY_XPAD) {
		intf = to_usb_interface(hdev->dev.parent);
		udev = interface_to_usbdev(intf);
    ...
}

If the device is connected via another transport (like Bluetooth, I2C, or
spoofed via uhid), the parent device is not a USB interface. Would calling
interface_to_usbdev() on this invalid pointer lead to out-of-bounds
memory access or a crash?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260818085623.18467-1-panz.development@gmail.com?part=1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] HID: asus: fix touchpad multitouch initialization regression
  2026-08-18  9:15 ` sashiko-bot
@ 2026-08-18 15:16   ` Panz Dev
  0 siblings, 0 replies; 6+ messages in thread
From: Panz Dev @ 2026-08-18 15:16 UTC (permalink / raw)
  To: Denis Benato
  Cc: dmitry.torokhov, linux-input, Jiri Kosina, Benjamin Tissoires,
	linux-kernel

Hi Denis,

Thanks for the fast reply!
Good catch on the UAF risk. It turns out simply adding `if
(!drvdata->tp)` to skip the keyboard init loop was actually all that
was needed to fix the touchpad probe on the E200HA.

That way, `asus_start_multitouch()` stays safely inside the claimed
input check as before without touching any of the security logic, and
the && condition doesn't need to be changed back to ||.

I've tested this on hardware (ASUS E200HA and VivoBook Flip 14
TP401MA) and just sent v2.

Sincerely,
PANZ

On Tue, Aug 18, 2026 at 11:15 AM <sashiko-bot@kernel.org> wrote:
>
> Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
>
> New issues:
> - [High] Unconditionally calling `asus_start_multitouch()` outside the `HID_CLAIMED_INPUT` check introduces a Use-After-Free if input registration fails.
>
> Pre-existing issues:
> - [High] Incorrect cleanup order in `asus_remove()` creates a Use-After-Free race condition by cancelling the workqueue before disabling hardware events.
> - [High] Missing `hid_is_usb()` check in `asus_kbd_register_leds()` allows an invalid cast to `usb_interface`, causing out-of-bounds reads or crashes.
> - [Medium] Modifying `input->name` after device registration creates a data race and violates input subsystem API requirements.
> --
>
> --- Patch [1]: [PATCH] HID: asus: fix touchpad multitouch initialization regression ---
> commit 53becd94719f665ca15fc8c3f4b7876a402da45f
> Author: Panz Dev <panz.development@gmail.com>
>
> HID: asus: fix touchpad multitouch initialization regression
>
> This patch fixes probe regressions for ASUS I2C/HID touchpads by skipping
> keyboard report initialization for touchpads and moving
> asus_start_multitouch() outside the claimed input check block.
>
> > diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> > index 3f5e96900b67a..72b93bdeb4e8f 100644
> > --- a/drivers/hid/hid-asus.c
> > +++ b/drivers/hid/hid-asus.c
> [ ... ]
> > @@ -1327,12 +1329,12 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
> >                       drvdata->input->name = "Asus TouchPad";
> >               else
> >                       drvdata->input->name = "Asus Keyboard";
>
> [Severity: Medium]
> This is a pre-existing issue, but can modifying drvdata->input->name here
> after device registration (which occurs earlier during hid_hw_start) create a
> data race?
>
> If a userspace process like udev reads the name attribute concurrently, might
> it read the default string or race with the pointer reassignment?
>
> > +     }
> >
> > -             if (drvdata->tp) {
> > -                     ret = asus_start_multitouch(hdev);
> > -                     if (ret)
> > -                             goto err_stop_hw;
> > -             }
> > +     if (drvdata->tp) {
> > +             ret = asus_start_multitouch(hdev);
> > +             if (ret)
> > +                     goto err_stop_hw;
> >       }
>
> [Severity: High]
> Does moving asus_start_multitouch() outside the HID_CLAIMED_INPUT check
> introduce a use-after-free regression if input registration fails?
>
> If input_register_device() fails during hid_hw_start(), hidinput_connect()
> frees the allocated input_dev and returns an error without setting
> HID_CLAIMED_INPUT.
>
> Since the HID_CLAIMED_INPUT safety guard is now removed, the driver
> will force the touchpad hardware to start sending reports. When the hardware
> interrupt arrives, asus_raw_event() intercepts it and routes to
> asus_report_input():
>
> drivers/hid/hid-asus.c:asus_raw_event() {
>     ...
>         if (drvdata->tp && data[0] == INPUT_REPORT_ID)
>                 return asus_report_input(drvdata, data, size);
>     ...
> }
>
> This blindly dereferences the freed drvdata->input pointer, which was assigned
> earlier in asus_input_configured():
>
> drivers/hid/hid-asus.c:asus_report_input() {
>     ...
>                 input_mt_slot(drvdat->input, i);
>                 input_mt_report_slot_state(drvdat->input, toolType, down);
>     ...
> }
>
> Is it possible for this to cause a use-after-free, for instance if triggered
> via uhid device spoofing or resource allocation failures during probe?
>
> >
> >       return 0;
>
> [Severity: High]
> This isn't a bug introduced by this patch, but does the cleanup order in
> asus_remove() create a use-after-free race condition?
>
> In asus_remove(), the driver calls:
>
> drivers/hid/hid-asus.c:asus_remove() {
>     ...
>         if (drvdata->quirks & QUIRK_HID_FN_LOCK)
>                 cancel_work_sync(&drvdata->fn_lock_sync_work);
>
>         hid_hw_stop(hdev);
>     ...
> }
>
> If the device sends a KEY_FN_ESC report via hardware interrupt immediately
> after cancel_work_sync() returns but before hid_hw_stop() completes, might
> asus_event() re-queue the work via schedule_work()? Once asus_remove()
> finishes, the devm-managed drvdata is freed, which could leave the work item
> scheduled and lead to a use-after-free when the worker executes.
>
> [Severity: High]
> This is a pre-existing issue, but could the lack of a hid_is_usb() check in
> asus_kbd_register_leds() allow an invalid cast?
>
> When handling the QUIRK_ROG_ALLY_XPAD quirk:
>
> drivers/hid/hid-asus.c:asus_kbd_register_leds() {
>     ...
>         if (drvdata->quirks & QUIRK_ROG_ALLY_XPAD) {
>                 intf = to_usb_interface(hdev->dev.parent);
>                 udev = interface_to_usbdev(intf);
>     ...
> }
>
> If the device is connected via another transport (like Bluetooth, I2C, or
> spoofed via uhid), the parent device is not a USB interface. Would calling
> interface_to_usbdev() on this invalid pointer lead to out-of-bounds
> memory access or a crash?
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260818085623.18467-1-panz.development@gmail.com?part=1

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-08-18 15:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-18  8:56 [PATCH] HID: asus: fix touchpad multitouch initialization regression Panz Dev
2026-08-18  9:13 ` Denis Benato
2026-08-18  9:15 ` sashiko-bot
2026-08-18 15:16   ` Panz Dev
  -- strict thread matches above, loose matches on Subject: below --
2026-08-18  8:25 PANZ
2026-08-18  8:38 ` Greg KH

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.