Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jinmo Yang" <jinmo44.yang@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH 3/5] HID: wacom: check the input device in wacom_intuos_pad()
Date: Sun, 27 Sep 2026 04:24:35 +0000	[thread overview]
Message-ID: <20260927042436.616A01F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260927041138.4112920-4-jinmo44.yang@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] HID: wacom: unintended fall-through for pad packets causes data corruption or crash
--

commit b724787c53f0eff408a5ebd5d5a4bed152ed7f82
Author: Jinmo Yang <jinmo44.yang@gmail.com>

    HID: wacom: check the input device in wacom_intuos_pad()
    
    wacom_intuos_pad() takes wacom->pad_input without checking it. An
    interface that declares no pad leaves the pointer NULL on a fully
    successful probe, and wacom_intuos_irq() still calls this function for
    pad report ids.

    [ ... ]
    
    Fixes: 10059cdc0ad0 ("Input: wacom - split out the pad device for Intuos/Cintiq")
    Cc: stable@vger.kernel.org
    Signed-off-by: Jinmo Yang <jinmo44.yang@gmail.com>

> diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
> index 794c2865064aa..48a58a6672c21 100644
> --- a/drivers/hid/wacom_wac.c
> +++ b/drivers/hid/wacom_wac.c
> @@ -553,6 +553,9 @@ static int wacom_intuos_pad(struct wacom_wac *wacom)
>  	bool wrench = false, keyboard = false, mute_touch = false, menu = false,
>  	     info = false;
>  
> +	if (!input)
> +		return 0;
> +

[Severity: High]
Does returning 0 here for a pad packet cause it to fall through and be misparsed
by other handlers?

In wacom_intuos_irq(), if wacom_intuos_pad() returns 0, the packet falls through
to wacom_intuos_inout():

drivers/hid/wacom_wac.c:wacom_intuos_irq() {
	...
	/* process pad events */
	result = wacom_intuos_pad(wacom);
	if (result)
		return result;

	/* process in/out prox events */
	result = wacom_intuos_inout(wacom);
	...
}

Because wacom_intuos_inout() only checks data[1] and doesn't verify the report
ID in data[0]:

drivers/hid/wacom_wac.c:wacom_intuos_inout() {
	...
	if (!(((data[1] & 0xfc) == 0xc0) ||  /* in prox */
	    ((data[1] & 0xfe) == 0x20) ||    /* in range */
	    ((data[1] & 0xfe) == 0x80)))     /* out prox */
		return 0;
	...
}

If data[1] of the unhandled pad packet happens to match one of these proximity
bitmasks (like 0x80 for out-prox), wacom_intuos_inout() will misparse the
packet. If it hits the out-prox case, it calls wacom_exit_report() which
dereferences wacom->pen_input. If pen_input is NULL (e.g. on a touch-only
interface), could this cause another NULL pointer dereference?

Should this !input check be placed after validating data[0], and return 1 to
correctly consume the report without falling through?

>  	/* pad packets. Works as a second tool and is always in prox */
>  	if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD ||
>  	      data[0] == WACOM_REPORT_CINTIQPAD))
>  		return 0;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260927041138.4112920-1-jinmo44.yang@gmail.com?part=3

  reply	other threads:[~2026-09-27  4:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-23 15:01 [PATCH] HID: wacom: fix NULL pointer dereference in wacom_intuos_pad() Jinmo Yang
2026-05-23 15:06 ` [PATCH v2] " Jinmo Yang
2026-05-23 15:50   ` sashiko-bot
2026-05-29 21:44   ` Dmitry Torokhov
2026-06-10 15:48     ` Jiri Kosina
2026-09-26 18:37       ` Jinmo Yang
2026-09-27  4:11       ` [PATCH 0/5] HID: wacom: check input devices in the report handlers Jinmo Yang
2026-09-27  4:11         ` [PATCH 1/5] HID: wacom: check the input device in the shared report helpers Jinmo Yang
2026-09-27  4:11         ` [PATCH 2/5] HID: wacom: check the input devices in the legacy irq handlers Jinmo Yang
2026-09-27  4:11         ` [PATCH 3/5] HID: wacom: check the input device in wacom_intuos_pad() Jinmo Yang
2026-09-27  4:24           ` sashiko-bot [this message]
2026-09-27  4:11         ` [PATCH 4/5] HID: wacom: check the input device in wacom_intuos_bt_irq() Jinmo Yang
2026-09-27  4:11         ` [PATCH 5/5] HID: wacom: check the input devices in the Bamboo handlers Jinmo Yang
2026-05-23 15:45 ` [PATCH] HID: wacom: fix NULL pointer dereference in wacom_intuos_pad() sashiko-bot

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=20260927042436.616A01F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jinmo44.yang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox