public inbox for linux-input@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] HID: wacom: fix out-of-bounds read in wacom_intuos_bt_irq
@ 2026-03-03 13:58 Benoît Sevens
  2026-03-06 19:32 ` Gerecke, Jason
  2026-03-09 18:34 ` Jiri Kosina
  0 siblings, 2 replies; 3+ messages in thread
From: Benoît Sevens @ 2026-03-03 13:58 UTC (permalink / raw)
  To: Ping Cheng, Jason Gerecke, Jiri Kosina, Benjamin Tissoires
  Cc: linux-input, linux-kernel, Benoît Sevens

The wacom_intuos_bt_irq() function processes Bluetooth HID reports
without sufficient bounds checking. A maliciously crafted short report
can trigger an out-of-bounds read when copying data into the wacom
structure.

Specifically, report 0x03 requires at least 22 bytes to safely read
the processed data and battery status, while report 0x04 (which
falls through to 0x03) requires 32 bytes.

Add explicit length checks for these report IDs and log a warning if
a short report is received.

Signed-off-by: Benoît Sevens <bsevens@google.com>
---
 drivers/hid/wacom_wac.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 9b2c710f8da1..da1f0ea85625 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -1208,10 +1208,20 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
 
 	switch (data[0]) {
 	case 0x04:
+		if (len < 32) {
+			dev_warn(wacom->pen_input->dev.parent,
+				 "Report 0x04 too short: %zu bytes\n", len);
+			break;
+		}
 		wacom_intuos_bt_process_data(wacom, data + i);
 		i += 10;
 		fallthrough;
 	case 0x03:
+		if (i == 1 && len < 22) {
+			dev_warn(wacom->pen_input->dev.parent,
+				 "Report 0x03 too short: %zu bytes\n", len);
+			break;
+		}
 		wacom_intuos_bt_process_data(wacom, data + i);
 		i += 10;
 		wacom_intuos_bt_process_data(wacom, data + i);
-- 
2.53.0.473.g4a7958ca14-goog


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

* Re: [PATCH] HID: wacom: fix out-of-bounds read in wacom_intuos_bt_irq
  2026-03-03 13:58 [PATCH] HID: wacom: fix out-of-bounds read in wacom_intuos_bt_irq Benoît Sevens
@ 2026-03-06 19:32 ` Gerecke, Jason
  2026-03-09 18:34 ` Jiri Kosina
  1 sibling, 0 replies; 3+ messages in thread
From: Gerecke, Jason @ 2026-03-06 19:32 UTC (permalink / raw)
  To: bsevens
  Cc: bentiss, jason.gerecke, jikos, linux-input, linux-kernel,
	ping.cheng

On Mar 3 2026, Benoît Sevens wrote:
> The wacom_intuos_bt_irq() function processes Bluetooth HID reports
> without sufficient bounds checking. A maliciously crafted short report
> can trigger an out-of-bounds read when copying data into the wacom
> structure.
> 
> Specifically, report 0x03 requires at least 22 bytes to safely read
> the processed data and battery status, while report 0x04 (which
> falls through to 0x03) requires 32 bytes.
> 
> Add explicit length checks for these report IDs and log a warning if
> a short report is received.
> 
> Signed-off-by: Benoît Sevens <bsevens@google.com>
> ---
>  drivers/hid/wacom_wac.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
> index 9b2c710f8da1..da1f0ea85625 100644
> --- a/drivers/hid/wacom_wac.c
> +++ b/drivers/hid/wacom_wac.c
> @@ -1208,10 +1208,20 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
>  
>  	switch (data[0]) {
>  	case 0x04:
> +		if (len < 32) {
> +			dev_warn(wacom->pen_input->dev.parent,
> +				 "Report 0x04 too short: %zu bytes\n", len);
> +			break;
> +		}
>  		wacom_intuos_bt_process_data(wacom, data + i);
>  		i += 10;
>  		fallthrough;
>  	case 0x03:
> +		if (i == 1 && len < 22) {
> +			dev_warn(wacom->pen_input->dev.parent,
> +				 "Report 0x03 too short: %zu bytes\n", len);
> +			break;
> +		}
>  		wacom_intuos_bt_process_data(wacom, data + i);
>  		i += 10;
>  		wacom_intuos_bt_process_data(wacom, data + i);
> -- 
> 2.53.0.473.g4a7958ca14-goog

Seems reasonable enough...

Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>

Note: this file is chock-full of functions that blindly process the
buffer in a way that could lead to out-of-bounds reads. I don't mind
fixing these two specific cases as an improvement, but we should
consider working on the other cases as well.

For reference, the potential OOB issues were introduced by commit
5e013ad20689 ("HID: wacom: Remove static WACOM_PKGLEN_MAX limit").
Prior to that point, all processing was done from a local statically-
sized buffer. Short packets might have led to unintentional behavior
but not an OOB read. We now work directly from the pointer provided
by HID and (usually) do no bounds checking to make sure the lengths
are reasonable.

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

* Re: [PATCH] HID: wacom: fix out-of-bounds read in wacom_intuos_bt_irq
  2026-03-03 13:58 [PATCH] HID: wacom: fix out-of-bounds read in wacom_intuos_bt_irq Benoît Sevens
  2026-03-06 19:32 ` Gerecke, Jason
@ 2026-03-09 18:34 ` Jiri Kosina
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Kosina @ 2026-03-09 18:34 UTC (permalink / raw)
  To: Benoît Sevens
  Cc: Ping Cheng, Jason Gerecke, Benjamin Tissoires, linux-input,
	linux-kernel

On Tue, 3 Mar 2026, Benoît Sevens wrote:

> The wacom_intuos_bt_irq() function processes Bluetooth HID reports
> without sufficient bounds checking. A maliciously crafted short report
> can trigger an out-of-bounds read when copying data into the wacom
> structure.
> 
> Specifically, report 0x03 requires at least 22 bytes to safely read
> the processed data and battery status, while report 0x04 (which
> falls through to 0x03) requires 32 bytes.
> 
> Add explicit length checks for these report IDs and log a warning if
> a short report is received.
> 
> Signed-off-by: Benoît Sevens <bsevens@google.com>

Applied to hid.git#for-7.0/upstream-fixes, thanks.

-- 
Jiri Kosina
SUSE Labs


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

end of thread, other threads:[~2026-03-09 18:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-03 13:58 [PATCH] HID: wacom: fix out-of-bounds read in wacom_intuos_bt_irq Benoît Sevens
2026-03-06 19:32 ` Gerecke, Jason
2026-03-09 18:34 ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox