Skip to content

HID: wacom: guard against NULL input devices on successful probe

Jinmo Yang linux-input lkml stable 5 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest6 patches 0 repliesNew
  2. v46 patches 3 repliesSuperseded
  3. v36 patches 2 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v25 patches0 repliesSuperseded
v15 patches7 repliesSuperseded

Changes in v5 from the cover letter

- Rebased onto hid.git#for-7.4/upstream-fixes (Jiri).
- Reworked 3/6. Commit 2f985de0afbe removed the 'input' local and the dev_dbg(input->dev.parent, ...) deref from wacom_intuos_irq(), so the pen_input guard there now exists solely to protect wacom_intuos_inout() and wacom_intuos_general(), which are its only callers. The guard therefore reads wacom_wac->pen_input and uses the struct wacom that 2f985de0afbe made a local, and it now sits below the pad block rather than at the top of the function, so a device with a valid pad but no pen keeps reporting pad events.
- No functional change to 1/6, 2/6, 4/6, 5/6 or 6/6.

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6HID: wacom: check the input device in the shared report helpersdrivers/hid/wacom_wac.c+14 -10 replies
2/6HID: wacom: check the input devices in the legacy irq handlersdrivers/hid/wacom_wac.c+40 -00 replies
3/6HID: wacom: add NULL input guards to wacom_intuos_irq() and its helpersdrivers/hid/wacom_wac.c+14 -20 replies
4/6HID: wacom: add NULL input guards to wacom_intuos_bt_irq()drivers/hid/wacom_wac.c+7 -00 replies
5/6HID: wacom: add NULL input guards to Bamboo handlersdrivers/hid/wacom_wac.c+29 -20 replies
6/6HID: wacom: add NULL touch_input guards to remaining touch handlersdrivers/hid/wacom_wac.c+18 -00 replies

Reviews trailers per patch

5 of 6 patches have a Reviewed-by or Acked-by.

PatchJason GereckeClaude Opus 4.6
1/6R-b
2/6R-b Co-Authored-By
3/6Co-Authored-By
4/6R-b Co-Authored-By
5/6R-b Co-Authored-By
6/6R-b Co-Authored-By

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH v5 0/6] HID: wacom: guard against NULL input devices on successful probe

When wacom_setup_{pen,touch,pad}_input_capabilities() returns -ENODEV, the corresponding input pointer is set to NULL but probe still succeeds. Subsequent irq handlers dereference those pointers unconditionally, causing NULL-pointer dereferences reachable from a spoofed HID device.

This series adds per-function NULL guards across all affected handlers.

v4 was generated against a tree that predates commit 2f985de0afbe ("HID: wacom: fix wacom_intuos_irq NULL pen_input deref"), so patch 3/6 no longer applied and was dropped. This respin is against hid.git#for-7.4/upstream-fixes (10bc1d627c29).

Jason's Reviewed-by from v4 is carried on the five patches that are unchanged. It is not carried on 3/6, which was reworked.

Changes in v5:
- Rebased onto hid.git#for-7.4/upstream-fixes (Jiri).
- Reworked 3/6. Commit 2f985de0afbe removed the 'input' local and the dev_dbg(input->dev.parent, ...) deref from wacom_intuos_irq(), so the pen_input guard there now exists solely to protect wacom_intuos_inout() and wacom_intuos_general(), which are its only callers. The guard therefore reads wacom_wac->pen_input and uses the struct wacom that 2f985de0afbe made a local, and it now sits below the pad block rather than at the top of the function, so a device with a valid pad but no pen keeps reporting pad events.
- No functional change to 1/6, 2/6, 4/6, 5/6 or 6/6.

Changes in v4:
- wacom_intuos_pad() now returns 2 for the normal path, 1 for the NULL-guard path; wacom_intuos_irq() applies "result - 1" uniformly, suppressing the spurious input_sync() the old "return 1" would trigger (Jason).
- Added pen_input NULL guard at the top of wacom_intuos_irq() to protect its helpers wacom_intuos_inout() and wacom_intuos_general() (Jason).
- Added pen_input NULL guard to wacom_bpt_pen() (Jason).

Changes in v3:
- Fixed wacom_dtus_irq(): DTUSX is pen-only, so do not require pad_input for it (sashiko-bot).
- Added patch 6: touch_input guards for wacom_intuos_pro2_bt_touch(),

    wacom_24hdt_irq(), and wacom_bamboo_pad_touch_event().

Changes in v2:
- Restructured per Jason's review: per-function checks for dtus_irq, graphire_irq, and the Bamboo handlers.
- wacom_intuos_pad() returns non-zero when pad_input is NULL so the report does not fall through to wacom_intuos_inout() (sashiko-bot).
- wacom_intuos_bt_irq() guards both pen_input and pad_input (Jason).
- Added dev_warn_once at every guard (Jason).
- Dropped the cp2112 patch (Benjamin prefers Dmitry's series).

Jinmo Yang (6):
HID: wacom: check the input device in the shared report helpers
HID: wacom: check the input devices in the legacy irq handlers
HID: wacom: add NULL input guards to wacom_intuos_irq() and its
helpers
HID: wacom: add NULL input guards to wacom_intuos_bt_irq()
HID: wacom: add NULL input guards to Bamboo handlers
HID: wacom: add NULL touch_input guards to remaining touch handlers

 drivers/hid/wacom_wac.c | 127 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 122 insertions(+), 5 deletions(-)

base-commit: 10bc1d627c297097cfdc099377f8a13efdfffd86

Signature · 1 line
2.43.0