HIGH Introduced in 6.11
hid-bpf DeviceRef UAF
CVE-2026-90001
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
KernelScan AI7.7HIGH
01Description
In the Linux kernel, the following vulnerability has been resolved: HID: bpf: serialize device reference release in struct_ops destroy path __hid_bpf_ops_destroy_device() and hid_bpf_unreg() can race on the same registration reference, double-putting struct hid_device and freeing it while hid_destroy_device() still uses it. Serialize the remove/NULL decision under hdev->bpf.prog_list_lock 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 put_device() 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 (hid_bpf_ops_reg) acquires one device reference (hid_get_device()). Two paths can release it: - device destruction: hid_destroy_device() -> hid_bpf_destroy_device() -> __hid_bpf_ops_destroy_device(), which walks hdev->bpf.prog_list under rcu_read_lock() and drops one reference per attached program; - BPF link release: bpf map delete (no BPF_F_LINK) synchronously calls st_ops->unreg() -> hid_bpf_unreg(), 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 (rcu_read_lock vs prog_list_lock), so a concurrent unreg can read ops->hdev as non-NULL, block on prog_list_lock, 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 refcount_t saturation fires: the device is simply freed while the transport is still inside hid_destroy_device(), and subsequent teardown touches freed memory. The fix serializes the remove/NULL decision under prog_list_lock 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 READ_ONCE/WRITE_ONCE are added, keeping the patch minimal. Unlocked-read safety: the unlocked read of ops->hdev at the top of hid_bpf_unreg() cannot touch a freed device, because the unreg path itself still holds this registration's reference (released only by its own hid_put_device() 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.
02KernelScan AI Analysis
Risk summary
A race condition in the HID-BPF struct_ops subsystem allows a local attacker with BPF loading privileges to double-free a HID device structure, leading to use-after-free kernel memory corruption. On systems where unprivileged BPF or user namespaces are enabled, this is reachable from inside a container and can enable container escape. The bug requires winning a narrow race window but yields full kernel read/write capability on success.
Vulnerability analysis
The HID-BPF subsystem acquires a reference on the HID device for each attached BPF program, and two separate code paths can release that same reference: one during device destruction and another when a BPF program is detached through a map deletion. Because these paths coordinate using a check-then-act pattern across different lock domains, a concurrent detach can observe the device pointer as valid, then proceed to drop its reference after the destruction path has already done so. Both decrements are individually legitimate, so no refcount saturation fires—the device is simply freed while the transport layer is still tearing it down, and subsequent teardown touches freed memory. The fix serializes both release decisions under a single lock so that exactly one path releases each reference, and moves all reference drops outside the lock to avoid holding it during potentially blocking operations. An attacker with the ability to load HID-BPF programs—which requires CAP_BPF, obtainable in a user namespace on systems where unprivileged BPF is not disabled—can trigger this race locally by detaching a program while the target device is being removed, potentially corrupting kernel heap memory for privilege escalation or container escape.
Lifecycle
03Fix Versions
| Branch | Introduced | Fixed in | Patch commit |
|---|---|---|---|
| 6.12 | 6.11 | 6.12.110 | 401359684620 |
| 6.18 | 6.11 | 6.18.51 | c7f927aa8b55 |
| 7.2 | 6.11 | 7.2.5 | bfb7939788f3 |
| mainline | 6.11 | 7.3 | 9cdc7e6dc7a9 |
| cip/6.12 | 6.11 | 6.12.111-cip32 | 401359684620 |
04CIP Kernels
State of the newest release of each Civil Infrastructure Platform SLTS tree, from CIP's own fix records.
| CIP tree | State |
|---|---|
| cip/6.12 | Fixed in 6.12.111-cip32 |