Skip to contentSkip to conversation

HID: wacom: LED callbacks race with led.groups teardown

DISCUSSION Jinmo Yang 1 participant 1 message Nov 28 HID

lore
Share & tools
lore

Jinmo Yang

author
#0 lore raw

Found by coverage-guided fuzzing of the HID subsystem through /dev/uhid. No patch is attached; I am reporting the lifetime issue first and can test candidate fixes against the existing KASAN setup.

Kernel: mainline 7.2.0-g66498c75b4f8 (arm64, KASAN)
File:   drivers/hid/wacom_sys.c
Impact: NULL pointer dereference; denial of service
Repro:  syzkaller; independently reproduced with linux-next Wacom sources

## Report

  Unable to handle kernel paging request at virtual address dfff800000000000
  KASAN: null-ptr-deref in range [0x0-0x7]
  Workqueue: leds set_brightness_delayed
   wacom_led_control
   wacom_led_brightness_set
   __led_set_brightness_blocking
   set_brightness_delayed_set_brightness
   set_brightness_delayed

The same fault reproduced after replacing the Wacom sources with the linux-next versions; only line numbers changed.

## Analysis

wacom_led_control() checks the shared pointer and uses it later:

  if (!wacom->led.groups)
          return -ENOTSUPP;
  ...
  int led = wacom->led.groups[0].select | 0x4;

The devres teardown action can clear it between those operations:

  static void wacom_led_groups_release(void *data)
  {
          struct wacom *wacom = data;
          wacom->led.groups = NULL;
          wacom->led.count = 0;

}

The reader is an LED-core work item and teardown does not take the lock used by several LED callbacks. Consequently neither the initial NULL check nor the callback-side mutex keeps the array alive. Other callbacks also access the same state, including __wacom_led_brightness_get() and the sysfs show and store methods, some without a NULL check.

This is the same lifetime pattern as the Wacom battery race, but it involves a separate resource, teardown action, and callback family. Rechecking or reordering a pointer assignment does not close the load/use race; teardown must be serialized with all LED callbacks that use the array.

## Upstream status

Rechecked against mainline, linux-next, HID maintainer branches, and lore through 2026-11-28. The defect remains unpatched and I found no matching submission.