CVE-2026-64363 PUBLISHED

HID: appleir: fix UAF on pending key_up_timer in remove()

Assigner: Linux
Reserved: 19.07.2026 Published: 25.07.2026 Updated: 25.07.2026

In the Linux kernel, the following vulnerability has been resolved:

HID: appleir: fix UAF on pending key_up_timer in remove()

appleir_remove() runs hid_hw_stop() before timer_delete_sync(). hid_hw_stop() synchronously unregisters the HID input device via hid_disconnect() -> hidinput_disconnect() -> input_unregister_device(), which drops the last reference and frees the underlying input_dev when no userspace handle holds it open.

key_up_tick() reads appleir->input_dev and calls input_report_key() / input_sync() on it. The timer is armed from appleir_raw_event() with a HZ/8 (~125 ms) timeout on every keydown and key-repeat report. If a key was pressed shortly before the device is disconnected, the timer can fire after hid_hw_stop() has freed input_dev but before the teardown drains it.

A simple reorder is not sufficient. Putting the timer drain first still leaves a window where a USB URB completion (raw_event) running during hid_hw_stop() can call mod_timer() and re-arm the timer, which then fires after hidinput_disconnect() has freed input_dev. The same URB-completion window also lets raw_event() reach key_up(), key_down() and battery_flat() directly, all of which dereference appleir->input_dev.

Introduce a 'removing' flag on struct appleir, gated by the existing spinlock. appleir_remove() sets the flag under the lock and then shuts down the timer with timer_shutdown_sync(), which both drains any in-flight callback and permanently disables further mod_timer() calls. appleir_raw_event() and key_up_tick() bail out early if the flag is set, so no path can arm or run the timer, or dereference appleir->input_dev, after remove() has started tearing down.

The keyrepeat and flatbattery branches of appleir_raw_event() previously called into the input layer without holding the spinlock; take it now so the flag check is well-defined. This incidentally closes a pre-existing read-side race on appleir->current_key in the keyrepeat branch.

This bug is structurally a sibling of commit 4db2af929279 ("HID: appletb-kbd: fix UAF in inactivity-timer cleanup path") and has been present since the driver was introduced.

Product Status

Vendor Linux
Product Linux
Versions Default: unaffected
  • affected from 9a4a5574ce427c364d81746fc7fb82d86b5f1a7e to 89ef67359672bf4cd6921524e39f61648fe38c0f (excl.)
  • affected from 9a4a5574ce427c364d81746fc7fb82d86b5f1a7e to 3d30a0bb0e79621ae921b487835c56198adfafa3 (excl.)
  • affected from 9a4a5574ce427c364d81746fc7fb82d86b5f1a7e to 37a52c61d4f78153c38ae1f7491dfcc8ac828dcf (excl.)
  • affected from 9a4a5574ce427c364d81746fc7fb82d86b5f1a7e to 05e3decc55d1deca9410e0eb36466651fcbe57a5 (excl.)
  • affected from 9a4a5574ce427c364d81746fc7fb82d86b5f1a7e to 3755f6e25776b8b12ddf062f9b573f05090e4034 (excl.)
  • affected from 9a4a5574ce427c364d81746fc7fb82d86b5f1a7e to b363d964ca829c1761c9f04188dfa28f90b0f2d4 (excl.)
  • affected from 9a4a5574ce427c364d81746fc7fb82d86b5f1a7e to 6b0838e86da88b1d3bff86f19761ff25af73eaca (excl.)
  • affected from 9a4a5574ce427c364d81746fc7fb82d86b5f1a7e to 75fe87e19d8aff81eb2c64d15d244ab8da4de945 (excl.)
Vendor Linux
Product Linux
Versions Default: affected
  • Version 3.10 is affected
  • unaffected from 0 to 3.10 (excl.)
  • unaffected from 5.10.261 to 5.10.* (incl.)
  • unaffected from 5.15.212 to 5.15.* (incl.)
  • unaffected from 6.1.178 to 6.1.* (incl.)
  • unaffected from 6.6.145 to 6.6.* (incl.)
  • unaffected from 6.12.97 to 6.12.* (incl.)
  • unaffected from 6.18.39 to 6.18.* (incl.)
  • unaffected from 7.1.4 to 7.1.* (incl.)
  • unaffected from 7.2-rc3 to * (incl.)

References