mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/4] HID: wacom: add report length validation in irq handlers
@ 2026-05-17 13:52 Jinmo Yang
  2026-05-17 13:52 ` [PATCH 1/4] HID: wacom: validate report length for PL and PTU handlers Jinmo Yang
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Jinmo Yang @ 2026-05-17 13:52 UTC (permalink / raw)
  To: linux-input; +Cc: jikos, benjamin.tissoires, linux-kernel, stable, Jinmo Yang

Several wacom IRQ handler sub-functions access fixed offsets in the raw
HID report buffer without validating the buffer length. wacom_wac_irq()
receives the length from wacom_raw_event() but does not validate it
before dispatching to the sub-functions, which do not receive the length
parameter.

A malicious USB device can declare a small HID report in its descriptor
and send a matching short report that passes the HID core size check
(csize >= rsize), but the driver assumes a full-size hardware report
layout, leading to slab-out-of-bounds reads.

Note: this is not mitigated by the recent HID core bounds checking
series which validates actual_size >= declared_size. An attacker
controls both the descriptor (declared size) and the sent data (actual
size), so the core check passes. Driver-level validation against the
expected hardware report layout is still necessary.

Tested with KASAN on Linux 7.1-rc3 (slab-out-of-bounds confirmed) and
verified kernel panic on a production device via uhid.

Jinmo Yang (4):
  HID: wacom: validate report length for PL and PTU handlers
  HID: wacom: validate report length for DTU handler
  HID: wacom: validate report length for DTUS handler
  HID: wacom: validate report length for 24HDT and 27QHDT handlers

 drivers/hid/wacom_wac.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

-- 
2.53.0


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

* [PATCH 1/4] HID: wacom: validate report length for PL and PTU handlers
  2026-05-17 13:52 [PATCH 0/4] HID: wacom: add report length validation in irq handlers Jinmo Yang
@ 2026-05-17 13:52 ` Jinmo Yang
  2026-05-17 13:52 ` [PATCH 2/4] HID: wacom: validate report length for DTU handler Jinmo Yang
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Jinmo Yang @ 2026-05-17 13:52 UTC (permalink / raw)
  To: linux-input; +Cc: jikos, benjamin.tissoires, linux-kernel, stable, Jinmo Yang

wacom_pl_irq() and wacom_ptu_irq() access fixed offsets up to data[7]
in the raw HID report buffer without validating the buffer length.
These sub-functions are called from wacom_wac_irq() which receives the
length parameter but does not pass it to the handlers.

A malicious USB device can declare a small HID report in its descriptor
and send a matching short report that passes the HID core size check
(csize >= rsize), but the driver assumes a full-size hardware report
layout, leading to slab-out-of-bounds reads.

Add minimum length checks in wacom_wac_irq() before dispatching to
wacom_pl_irq() and wacom_ptu_irq().

Fixes: 4104d13fe019 ("Input: move USB tablets under drivers/input/tablet")
Cc: stable@vger.kernel.org
Signed-off-by: Jinmo Yang <jinmo44.yang@gmail.com>
---
 drivers/hid/wacom_wac.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index da1f0ea85..6d06842b6 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -3453,6 +3453,8 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
 		break;
 
 	case PL:
+		if (len < 8)
+			return;
 		sync = wacom_pl_irq(wacom_wac);
 		break;
 
@@ -3464,6 +3466,8 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
 		break;
 
 	case PTU:
+		if (len < 8)
+			return;
 		sync = wacom_ptu_irq(wacom_wac);
 		break;
 
-- 
2.53.0


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

* [PATCH 2/4] HID: wacom: validate report length for DTU handler
  2026-05-17 13:52 [PATCH 0/4] HID: wacom: add report length validation in irq handlers Jinmo Yang
  2026-05-17 13:52 ` [PATCH 1/4] HID: wacom: validate report length for PL and PTU handlers Jinmo Yang
@ 2026-05-17 13:52 ` Jinmo Yang
  2026-05-17 13:52 ` [PATCH 3/4] HID: wacom: validate report length for DTUS handler Jinmo Yang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Jinmo Yang @ 2026-05-17 13:52 UTC (permalink / raw)
  To: linux-input; +Cc: jikos, benjamin.tissoires, linux-kernel, stable, Jinmo Yang

wacom_dtu_irq() accesses fixed offsets up to data[7] in the raw HID
report buffer without validating the buffer length. This sub-function
is called from wacom_wac_irq() which receives the length parameter but
does not pass it to the handler.

A malicious USB device can declare a small HID report in its descriptor
and send a matching short report that passes the HID core size check
(csize >= rsize), but the driver assumes a full-size hardware report
layout, leading to slab-out-of-bounds reads.

Add a minimum length check in wacom_wac_irq() before dispatching to
wacom_dtu_irq().

Fixes: c8f2edc56acf ("Input: wacom - add support for DTU2231 and DTU1631")
Cc: stable@vger.kernel.org
Signed-off-by: Jinmo Yang <jinmo44.yang@gmail.com>
---
 drivers/hid/wacom_wac.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 6d06842b6..873d58a6d 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -3472,6 +3472,8 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
 		break;
 
 	case DTU:
+		if (len < 8)
+			return;
 		sync = wacom_dtu_irq(wacom_wac);
 		break;
 
-- 
2.53.0


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

* [PATCH 3/4] HID: wacom: validate report length for DTUS handler
  2026-05-17 13:52 [PATCH 0/4] HID: wacom: add report length validation in irq handlers Jinmo Yang
  2026-05-17 13:52 ` [PATCH 1/4] HID: wacom: validate report length for PL and PTU handlers Jinmo Yang
  2026-05-17 13:52 ` [PATCH 2/4] HID: wacom: validate report length for DTU handler Jinmo Yang
@ 2026-05-17 13:52 ` Jinmo Yang
  2026-05-17 13:52 ` [PATCH 4/4] HID: wacom: validate report length for 24HDT and 27QHDT handlers Jinmo Yang
  2026-06-10 15:47 ` [PATCH 0/4] HID: wacom: add report length validation in irq handlers Jiri Kosina
  4 siblings, 0 replies; 7+ messages in thread
From: Jinmo Yang @ 2026-05-17 13:52 UTC (permalink / raw)
  To: linux-input; +Cc: jikos, benjamin.tissoires, linux-kernel, stable, Jinmo Yang

wacom_dtus_irq() accesses fixed offsets up to data[6] in the raw HID
report buffer without validating the buffer length. This sub-function
is called from wacom_wac_irq() which receives the length parameter but
does not pass it to the handler.

A malicious USB device can declare a small HID report in its descriptor
and send a matching short report that passes the HID core size check
(csize >= rsize), but the driver assumes a full-size hardware report
layout, leading to slab-out-of-bounds reads.

Add a minimum length check in wacom_wac_irq() before dispatching to
wacom_dtus_irq().

Fixes: 497ab1f290a2 ("Input: wacom - add support for DTU-1031")
Cc: stable@vger.kernel.org
Signed-off-by: Jinmo Yang <jinmo44.yang@gmail.com>
---
 drivers/hid/wacom_wac.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 873d58a6d..269e8318f 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -3479,6 +3479,8 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
 
 	case DTUS:
 	case DTUSX:
+		if (len < 7)
+			return;
 		sync = wacom_dtus_irq(wacom_wac);
 		break;
 
-- 
2.53.0


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

* [PATCH 4/4] HID: wacom: validate report length for 24HDT and 27QHDT handlers
  2026-05-17 13:52 [PATCH 0/4] HID: wacom: add report length validation in irq handlers Jinmo Yang
                   ` (2 preceding siblings ...)
  2026-05-17 13:52 ` [PATCH 3/4] HID: wacom: validate report length for DTUS handler Jinmo Yang
@ 2026-05-17 13:52 ` Jinmo Yang
  2026-06-10 15:47 ` [PATCH 0/4] HID: wacom: add report length validation in irq handlers Jiri Kosina
  4 siblings, 0 replies; 7+ messages in thread
From: Jinmo Yang @ 2026-05-17 13:52 UTC (permalink / raw)
  To: linux-input; +Cc: jikos, benjamin.tissoires, linux-kernel, stable, Jinmo Yang

wacom_24hdt_irq() accesses data[61] for WACOM_24HDT and data[63] for
WACOM_27QHDT in the raw HID report buffer without validating the buffer
length. This sub-function is called from wacom_wac_irq() which receives
the length parameter but does not pass it to the handler.

A malicious USB device can declare a small HID report in its descriptor
and send a matching short report that passes the HID core size check
(csize >= rsize), but the driver assumes a full-size hardware report
layout, leading to slab-out-of-bounds reads.

Add minimum length checks in wacom_wac_irq() before dispatching to
wacom_24hdt_irq() for both device types.

Fixes: b1e4279e4ef5 ("Input: wacom - add touch sensor support for Cintiq 24HD touch")
Cc: stable@vger.kernel.org
Signed-off-by: Jinmo Yang <jinmo44.yang@gmail.com>
---
 drivers/hid/wacom_wac.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 269e8318f..2fd1c4e80 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -3509,7 +3509,14 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
 		break;
 
 	case WACOM_24HDT:
+		if (len < 62)
+			return;
+		sync = wacom_24hdt_irq(wacom_wac);
+		break;
+
 	case WACOM_27QHDT:
+		if (len < 64)
+			return;
 		sync = wacom_24hdt_irq(wacom_wac);
 		break;
 
-- 
2.53.0


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

* Re: [PATCH 0/4] HID: wacom: add report length validation in irq handlers
  2026-05-17 13:52 [PATCH 0/4] HID: wacom: add report length validation in irq handlers Jinmo Yang
                   ` (3 preceding siblings ...)
  2026-05-17 13:52 ` [PATCH 4/4] HID: wacom: validate report length for 24HDT and 27QHDT handlers Jinmo Yang
@ 2026-06-10 15:47 ` Jiri Kosina
  2026-06-17 15:55   ` Jason Gerecke
  4 siblings, 1 reply; 7+ messages in thread
From: Jiri Kosina @ 2026-06-10 15:47 UTC (permalink / raw)
  To: Jinmo Yang
  Cc: linux-input, benjamin.tissoires, linux-kernel, stable,
	Ping Cheng, Jason Gerecke

On Sun, 17 May 2026, Jinmo Yang wrote:

> Several wacom IRQ handler sub-functions access fixed offsets in the raw
> HID report buffer without validating the buffer length. wacom_wac_irq()
> receives the length from wacom_raw_event() but does not validate it
> before dispatching to the sub-functions, which do not receive the length
> parameter.
> 
> A malicious USB device can declare a small HID report in its descriptor
> and send a matching short report that passes the HID core size check
> (csize >= rsize), but the driver assumes a full-size hardware report
> layout, leading to slab-out-of-bounds reads.
> 
> Note: this is not mitigated by the recent HID core bounds checking
> series which validates actual_size >= declared_size. An attacker
> controls both the descriptor (declared size) and the sent data (actual
> size), so the core check passes. Driver-level validation against the
> expected hardware report layout is still necessary.
> 
> Tested with KASAN on Linux 7.1-rc3 (slab-out-of-bounds confirmed) and
> verified kernel panic on a production device via uhid.
> 
> Jinmo Yang (4):
>   HID: wacom: validate report length for PL and PTU handlers
>   HID: wacom: validate report length for DTU handler
>   HID: wacom: validate report length for DTUS handler
>   HID: wacom: validate report length for 24HDT and 27QHDT handlers
> 
>  drivers/hid/wacom_wac.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)

CCing Ping and Jason for their review. Thanks in advance,

-- 
Jiri Kosina
SUSE Labs


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

* Re: [PATCH 0/4] HID: wacom: add report length validation in irq handlers
  2026-06-10 15:47 ` [PATCH 0/4] HID: wacom: add report length validation in irq handlers Jiri Kosina
@ 2026-06-17 15:55   ` Jason Gerecke
  0 siblings, 0 replies; 7+ messages in thread
From: Jason Gerecke @ 2026-06-17 15:55 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Jinmo Yang, linux-input, benjamin.tissoires, linux-kernel,
	stable, Ping Cheng, Jason Gerecke

On Wed, Jun 10, 2026 at 9:19 AM Jiri Kosina <jikos@kernel.org> wrote:
>
> On Sun, 17 May 2026, Jinmo Yang wrote:
>
> > Several wacom IRQ handler sub-functions access fixed offsets in the raw
> > HID report buffer without validating the buffer length. wacom_wac_irq()
> > receives the length from wacom_raw_event() but does not validate it
> > before dispatching to the sub-functions, which do not receive the length
> > parameter.
> >
> > A malicious USB device can declare a small HID report in its descriptor
> > and send a matching short report that passes the HID core size check
> > (csize >= rsize), but the driver assumes a full-size hardware report
> > layout, leading to slab-out-of-bounds reads.
> >
> > Note: this is not mitigated by the recent HID core bounds checking
> > series which validates actual_size >= declared_size. An attacker
> > controls both the descriptor (declared size) and the sent data (actual
> > size), so the core check passes. Driver-level validation against the
> > expected hardware report layout is still necessary.
> >
> > Tested with KASAN on Linux 7.1-rc3 (slab-out-of-bounds confirmed) and
> > verified kernel panic on a production device via uhid.
> >
> > Jinmo Yang (4):
> >   HID: wacom: validate report length for PL and PTU handlers
> >   HID: wacom: validate report length for DTU handler
> >   HID: wacom: validate report length for DTUS handler
> >   HID: wacom: validate report length for 24HDT and 27QHDT handlers
> >

Two main comments:

1) I would prefer each of these commits to pass 'len' as a value into
the sub-functions and perform the checks there. We already do this
with several of the sub-functions, and it would be good to be
consistent in where the checks are performed.

2) Please define new WACOM_PKGLEN_* values in drivers/hid/wacom_wac.h
and use these definitions rather than magic numbers. E.g. `#define
WACOM_PKGLEN_PL 8` to cover the PL case.

Jason (she/they)
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one  /
(That is to say, eight) to the two,     /
But you can’t take seven from three,    /
So you look at the sixty-fours....


> >  drivers/hid/wacom_wac.c | 15 +++++++++++++++
> >  1 file changed, 15 insertions(+)
>
> CCing Ping and Jason for their review. Thanks in advance,
>
> --
> Jiri Kosina
> SUSE Labs
>
>

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

end of thread, other threads:[~2026-06-17 15:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-17 13:52 [PATCH 0/4] HID: wacom: add report length validation in irq handlers Jinmo Yang
2026-05-17 13:52 ` [PATCH 1/4] HID: wacom: validate report length for PL and PTU handlers Jinmo Yang
2026-05-17 13:52 ` [PATCH 2/4] HID: wacom: validate report length for DTU handler Jinmo Yang
2026-05-17 13:52 ` [PATCH 3/4] HID: wacom: validate report length for DTUS handler Jinmo Yang
2026-05-17 13:52 ` [PATCH 4/4] HID: wacom: validate report length for 24HDT and 27QHDT handlers Jinmo Yang
2026-06-10 15:47 ` [PATCH 0/4] HID: wacom: add report length validation in irq handlers Jiri Kosina
2026-06-17 15:55   ` Jason Gerecke

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

Powered by JetHome