From: Jinmo Yang <jinmo44.yang@gmail.com>
To: ping.cheng@wacom.com, jason.gerecke@wacom.com, jikos@kernel.org,
bentiss@kernel.org
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org, Jinmo Yang <jinmo44.yang@gmail.com>,
stable@vger.kernel.org,
"Claude Opus 4 . 6" <noreply@anthropic.com>
Subject: [PATCH v5 2/6] HID: wacom: check the input devices in the legacy irq handlers
Date: Mon, 23 Nov 2026 04:20:11 +0000 [thread overview]
Message-ID: <1dd28b561f3380cf3b76bfe096ba676a83f33229.1795405057.git.jinmo44.yang@gmail.com> (raw)
In-Reply-To: <cover.1795405057.git.jinmo44.yang@gmail.com>
wacom_penpartner_irq(), wacom_pl_irq(), wacom_ptu_irq(),
wacom_dtu_irq(), wacom_dtus_irq() and wacom_graphire_irq() dereference
pen_input and, for the latter two, pad_input without checking them.
As described in "HID: wacom: check the input device in the shared
report helpers", a partial interface leaves one or two of the three
input devices NULL on a fully successful probe, and wacom_wac_irq()
still dispatches to these handlers. Seven locations fault, each
reproduced on linux-next 20260925 (x86_64, KASAN) from one /dev/uhid
device plus a single UHID_INPUT2 write.
For wacom_dtus_irq() and wacom_graphire_irq(), all hardware served by
these handlers is expected to have both pen and pad on a single
interface, with two exceptions: GRAPHIRE (pen-only) and DTUSX (pen-only,
no pad buttons). Guard the expected input devices at function entry,
skipping the pad_input requirement for those two types. For DTUSX, also
guard the DTUSPAD branch in case a spoofed device sends a pad report
anyway.
wacom_dtu_irq() gets a check too. Its only dereference is in a
dev_dbg(), so it does not fault with CONFIG_DYNAMIC_DEBUG=n, but it is
unconditional in the source.
Fixes: 2a6cdbdd4cc0 ("HID: wacom: Introduce new 'touch_input' device")
Fixes: 862cf5535c0c ("HID: wacom: Introduce a new WACOM_DEVICETYPE_PAD device_type")
Cc: stable@vger.kernel.org
Signed-off-by: Jinmo Yang <jinmo44.yang@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
---
drivers/hid/wacom_wac.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index c7bf0e5988e5..d5c2efcc09b8 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -128,6 +128,12 @@ static int wacom_penpartner_irq(struct wacom_wac *wacom)
unsigned char *data = wacom->data;
struct input_dev *input = wacom->pen_input;
+ if (!input) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: pen_input is NULL\n", __func__);
+ return 0;
+ }
+
switch (data[0]) {
case 1:
if (data[5] & 0x80) {
@@ -174,6 +180,12 @@ static int wacom_pl_irq(struct wacom_wac *wacom)
struct input_dev *input = wacom->pen_input;
int prox, pressure;
+ if (!input) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: pen_input is NULL\n", __func__);
+ return 0;
+ }
+
if (data[0] != WACOM_REPORT_PENABLED) {
dev_dbg(input->dev.parent,
"%s: received unknown report #%d\n", __func__, data[0]);
@@ -233,6 +245,12 @@ static int wacom_ptu_irq(struct wacom_wac *wacom)
unsigned char *data = wacom->data;
struct input_dev *input = wacom->pen_input;
+ if (!input) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: pen_input is NULL\n", __func__);
+ return 0;
+ }
+
if (data[0] != WACOM_REPORT_PENABLED) {
dev_dbg(input->dev.parent,
"%s: received unknown report #%d\n", __func__, data[0]);
@@ -263,6 +281,12 @@ static int wacom_dtu_irq(struct wacom_wac *wacom)
struct input_dev *input = wacom->pen_input;
int prox = data[1] & 0x20;
+ if (!input) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: pen_input is NULL\n", __func__);
+ return 0;
+ }
+
dev_dbg(input->dev.parent,
"%s: received report #%d", __func__, data[0]);
@@ -289,16 +313,26 @@ static int wacom_dtu_irq(struct wacom_wac *wacom)
static int wacom_dtus_irq(struct wacom_wac *wacom)
{
+ struct wacom_features *features = &wacom->features;
unsigned char *data = wacom->data;
struct input_dev *input = wacom->pen_input;
unsigned short prox, pressure = 0;
+ if (!input || (!wacom->pad_input && features->type != DTUSX)) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: missing input device(s)\n",
+ __func__);
+ return 0;
+ }
+
if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
dev_dbg(input->dev.parent,
"%s: received unknown report #%d", __func__, data[0]);
return 0;
} else if (data[0] == WACOM_REPORT_DTUSPAD) {
input = wacom->pad_input;
+ if (!input)
+ return 0;
input_report_key(input, BTN_0, (data[1] & 0x01));
input_report_key(input, BTN_1, (data[1] & 0x02));
input_report_key(input, BTN_2, (data[1] & 0x04));
@@ -349,6 +383,12 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
int rw = 0;
int retval = 0;
+ if (!input || (!pad_input && features->type != GRAPHIRE)) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: missing input device(s)\n", __func__);
+ return 0;
+ }
+
if (features->type == GRAPHIRE_BT) {
if (data[0] != WACOM_REPORT_PENABLED_BT) {
dev_dbg(input->dev.parent,
--
2.43.0
next prev parent reply other threads:[~2026-11-23 4:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 4:20 [PATCH v5 0/6] HID: wacom: guard against NULL input devices on successful probe Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 1/6] HID: wacom: check the input device in the shared report helpers Jinmo Yang
2026-11-23 4:20 ` Jinmo Yang [this message]
2026-11-23 4:20 ` [PATCH v5 3/6] HID: wacom: add NULL input guards to wacom_intuos_irq() and its helpers Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 4/6] HID: wacom: add NULL input guards to wacom_intuos_bt_irq() Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 5/6] HID: wacom: add NULL input guards to Bamboo handlers Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 6/6] HID: wacom: add NULL touch_input guards to remaining touch handlers Jinmo Yang
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=1dd28b561f3380cf3b76bfe096ba676a83f33229.1795405057.git.jinmo44.yang@gmail.com \
--to=jinmo44.yang@gmail.com \
--cc=bentiss@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=jason.gerecke@wacom.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=noreply@anthropic.com \
--cc=ping.cheng@wacom.com \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®