CVE-2026-90001: HID: bpf: serialize device reference release in struct_ops destroy path

Published Sep 16, 2026
·
Updated

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

HID: bpf: serialize device reference release in structops destroy path

hidbpfopsdestroydevice() and hidbpfunreg() can race on the same registration reference, double-putting struct hiddevice and freeing it while hiddestroydevice() still uses it. Serialize the remove/NULL decision under hdev->bpf.proglistlock so exactly one path releases each registration reference: unreg re-checks ops->hdev under the lock and returns without putting when the destroy path already cleared it; all putdevice() calls happen after the lock is dropped, which is safe because a concurrent unreg then observes ops->hdev == NULL under the lock.

Background: each successful attach (hidbpfopsreg) acquires one device reference (hidgetdevice()). Two paths can release it:

- device destruction: hiddestroydevice() -> hidbpfdestroydevice() -> hidbpfopsdestroydevice(), which walks hdev->bpf.proglist under rcureadlock() and drops one reference per attached program; - BPF link release: bpf map delete (no BPFFLINK) synchronously calls stops->unreg() -> hidbpfunreg(), which drops the reference for its own registration.

The coordination handshake (e->hdev = NULL on the destroy side vs "if (!hdev) return" on the unreg side) is a TOCTOU check: the two paths run under different lock domains (rcureadlock vs proglistlock), so a concurrent unreg can read ops->hdev as non-NULL, block on proglistlock, and then proceed while the destroy traversal executes - both paths then drop the same reference. The refcount reaches zero legitimately (each decrement is individually valid), so no refcountt saturation fires: the device is simply freed while the transport is still inside hiddestroydevice(), and subsequent teardown touches freed memory.

The fix serializes the remove/NULL decision under proglistlock on both sides and moves the destroy-side puts outside the lock. With the lock held, plain reads/writes of ops->hdev are sufficient; no READONCE/WRITEONCE are added, keeping the patch minimal.

Unlocked-read safety: the unlocked read of ops->hdev at the top of hidbpfunreg() cannot touch a freed device, because the unreg path itself still holds this registration's reference (released only by its own hidputdevice() after the lock is dropped), and a destroy traversal that already cleared ops->hdev makes the lock-internal re-check return early without any put. At most one of the two paths releases each registration reference.

Affected Software

1 affected component
Linux Linux kernel

Event History

Sep 16, 2026
CVE Published
via MITRE·10:33 AM
Data Sourced
via MITRE·10:33 AM
Description

Frequently Asked Questions

1

What conditions are required to trigger the race?

A HID BPF program must have been successfully attached, which gives it a device reference. The race occurs when device destruction and BPF link release through BPF map deletion without BPF_F_LINK concurrently release the same registration reference.

2

What is the likely impact of successful exploitation?

The same struct hid_device reference can be released twice, freeing the device while hid_destroy_device() is still using it. This is a use-after-free condition in the Linux kernel.

3

How can I tell whether an environment is exposed to this issue?

Exposure requires use of HID BPF attachments to HID devices and the possibility of concurrent HID device destruction and removal of the associated BPF registration. Systems not using successful HID BPF attachments do not have the described registration reference to race over.

4

What behavior does the fix introduce?

The fix serializes the decision to remove or clear the device reference under hdev->bpf.prog_list_lock. It ensures only one path releases each registration reference, while the actual put_device() call occurs after releasing the lock.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203