CVE-2025-38016: HID: bpf: abort dispatch if device destroyed
In the Linux kernel, the following vulnerability has been resolved:
HID: bpf: abort dispatch if device destroyed
The current HID bpf implementation assumes no output report/request will go through it after hidbpfdestroydevice() has been called. This leads to a bug that unplugging certain types of HID devices causes a cleaned- up SRCU to be accessed. The bug was previously a hidden failure until a recent x86 percpu change [1] made it access not-present pages.
The bug will be triggered if the conditions below are met:
A) a device under the driver has some LEDs on B) hidlldriver->request() is uninplemented (e.g., logitech-djreceiver)
If condition A is met, hidinputledworker() is always scheduled after hidbpfdestroydevice().
hiddestroydevice hidbpfdestroydevice cleanupsrcustruct(&hdev->bpf.srcu) hidremovedevice ... ledclassdevunregister ledtriggerset(ledcdev, NULL) ledsetbrightness(ledcdev, LEDOFF) ... inputinjectevent inputeventdispose hidinputinputevent schedulework(&hid->ledwork) [hidinputledworker]
This is fine when condition B is not met, where hidinputledworker() calls hidlldriver->request(). This is the case for most HID drivers, which implement it or use the generic one from usbhid. The driver itself or an underlying driver will then abort processing the request.
Otherwise, hidinputledworker() tries hidhwoutputreport() and leads to the bug.
hidinputledworker hidhwoutputreport dispatchhidbpfoutputreport srcureadlock(&hdev->bpf.srcu) srcureadunlock(&hdev->bpf.srcu, idx)
The bug has existed since the introduction [2] of dispatchhidbpfoutputreport(). However, the same bug also exists in dispatchhidbpfrawrequests(), and I've reproduced (no visible effect because of the lack of [1], but confirmed bpf.destroyed == 1) the bug against the commit (i.e., the Fixes:) introducing the function. This is because hidinputledworker() falls back to hidhwrawrequest() when hidlldriver->outputreport() is uninplemented (e.g., logitech- djreceiver).
hidinputledworker hidhwoutputreport: -ENOSYS hidhwrawrequest dispatchhidbpfrawrequests srcureadlock(&hdev->bpf.srcu) srcureadunlock(&hdev->bpf.srcu, idx)
Fix the issue by returning early in the two mentioned functions if hidbpf has been marked as destroyed. Though dispatchhidbpfdeviceevent() handles input events, and there is no evidence that it may be called after the destruction, the same check, as a safety net, is also added to it to maintain the consistency among all dispatch functions.
The impact of the bug on other architectures is unclear. Even if it acts as a hidden failure, this is still dangerous because it corrupts whatever is on the address calculated by SRCU. Thus, CC'ing the stable list.
[1]: commit 9d7de2aa8b41 ("x86/percpu/64: Use relative percpu offsets") [2]: commit 9286675a2aed ("HID: bpf: add HID-BPF hooks for hidhwoutputreport")
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Configuration
Add/enable a safety check in HID-BPF so dispatch_hid_bpf_output_report() / dispatch_hid_bpf_raw_requests() abort dispatch when the HID device has been destroyed (described as “HID: bpf: abort dispatch if device destroyed”).
Linux kernel HID-BPF abort dispatch if device destroyed = enabled - Configuration
In the two mentioned functions, fix the use-after-destroy bug by returning early when HID-BPF indicates the device has been destroyed (the material specifies “returning early in the two mentioned functions if … HID: bpf: abort dispatch if device destroyed”).
Linux kernel HID-BPF return early in the two mentioned functions = return early - Compensating control
Ensure affected systems run kernels built with the referenced fix so that hidinput_led_worker() does not call hid_hw_output_report()/hid_hw_raw_request() after hid_bpf_destroy_device() has completed; otherwise schedule_work(&hid->led_work) may occur after destruction (per the provided call path).
Event History
Frequently Asked Questions
What is the severity of CVE-2025-38016?
CVE-2025-38016 has been rated as a low-severity vulnerability in the Linux kernel.
How do I fix CVE-2025-38016?
To resolve CVE-2025-38016, upgrade to a patched version of the Linux kernel that addresses this vulnerability.
Which versions of Linux kernel are affected by CVE-2025-38016?
CVE-2025-38016 affects Linux kernel versions between 6.11 and 6.12.30, 6.13 to 6.14.8, and specific release candidate versions of 6.15.
What components are involved in CVE-2025-38016?
CVE-2025-38016 involves the Human Interface Device (HID) and its bpf implementation within the Linux kernel.
Is there a known exploit for CVE-2025-38016?
As of now, there are no known public exploits targeting CVE-2025-38016.