Linux Input/HID development
 help / color / mirror / Atom feed
From: Jinmo Yang <jinmo44.yang@gmail.com>
To: Ping Cheng <ping.cheng@wacom.com>,
	Jason Gerecke <jason.gerecke@wacom.com>,
	Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <bentiss@kernel.org>
Cc: Jinmo Yang <jinmo44.yang@gmail.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: HID: wacom: battery teardown races with input reports
Date: Sat, 28 Nov 2026 11:04:03 +0000	[thread overview]
Message-ID: <20261128110415.772810-1-jinmo44.yang@gmail.com> (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 with the standalone and syzkaller reproducers.

Kernel: mainline 7.2.0-g66498c75b4f8 (arm64, KASAN)
Files:  drivers/hid/wacom_sys.c, drivers/hid/wacom_wac.c
Impact: use-after-free write; kernel panic
Repro:  standalone C and syzkaller; also reproduced on a Pixel 9 Pro

## Report

The clearest report is a write into a freed struct power_supply:

  BUG: KASAN: slab-use-after-free in test_and_set_bit
  Write of size 8
   queue_work_on
   schedule_work
   power_supply_changed
   wacom_notify_battery
   wacom_status_irq
   wacom_wac_irq
   wacom_raw_event
   __hid_input_report
   uhid_char_write

The object was allocated by devm_power_supply_register() from
wacom_battery_work(), and freed by power_supply_dev_release() through
devres_release_group() in wacom_destroy_battery().  The freeing worker and
the uhid writer were different tasks.

## Analysis

wacom_destroy_battery() releases the devres group before clearing the
published pointer:

  if (wacom->battery.battery) {
          devres_release_group(&wacom->hdev->dev,
                               &wacom->battery.bat_desc);
          wacom->battery.battery = NULL;
  }

At the same time, the input-report path does:

  if (battery->battery)
          power_supply_changed(battery->battery);

This leaves an immediate freed-but-non-NULL window.  Merely reversing the
two statements is not sufficient: an input path can load the old pointer,
be overtaken by teardown, and then call power_supply_changed() on the freed
object.  The create/destroy side and report side need lifetime
serialization, for example using the same exclusion already held by the
input-report path.

The reproducer alternates the wireless-module bit in Wacom status reports,
causing battery creation and destruction while continuing to inject input.
It requires only /dev/uhid.  Besides the KASAN report, the standalone
reproducer caused a Pixel 9 Pro kernel panic in power_supply_uevent() after
about 11 seconds.

## 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.

                 reply	other threads:[~2026-11-28 11:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261128110415.772810-1-jinmo44.yang@gmail.com \
    --to=jinmo44.yang@gmail.com \
    --cc=bentiss@kernel.org \
    --cc=jason.gerecke@wacom.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ping.cheng@wacom.com \
    /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