CVE-2025-38687: comedi: fix race between polling and detaching
In the Linux kernel, the following vulnerability has been resolved:
comedi: fix race between polling and detaching
syzbot reports a use-after-free in comedi in the below link, which is
due to comedi gladly removing the allocated async area even though poll
requests are still active on the wait_queue_head inside of it. This can
cause a use-after-free when the poll entries are later triggered or
removed, as the memory for the wait_queue_head has been freed. We need
to check there are no tasks queued on any of the subdevices' wait queues
before allowing the device to be detached by the `COMEDI_DEVCONFIG`
ioctl.
Tasks will read-lock `dev->attach_lock` before adding themselves to the
subdevice wait queue, so fix the problem in the `COMEDI_DEVCONFIG` ioctl
handler by write-locking `dev->attach_lock` before checking that all of
the subdevices are safe to be deleted. This includes testing for any
sleepers on the subdevices' wait queues. It remains locked until the
device has been detached. This requires the `comedi_device_detach()`
function to be refactored slightly, moving the bulk of it into new
function `comedi_device_detach_locked()`.
Note that the refactor of `comedi_device_detach()` results in
`comedi_device_cancel_all()` now being called while `dev->attach_lock`
is write-locked, which wasn't the case previously, but that does not
matter.
Thanks to Jens Axboe for diagnosing the problem and co-developing this
patch.
Security readout for executives and security teams
Plain-English summary
A race in Linux's Comedi data-acquisition subsystem can free memory while polling operations still reference it. A later event can access that freed memory, potentially causing a kernel crash or corruption. The supplied CVSS assessment indicates local, low-privileged access and user interaction are required. Exposure is specialized rather than universal across Linux systems.
Executive priority
Treat as a high-priority kernel maintenance issue on Comedi-enabled, multi-user, laboratory, industrial, or appliance systems. Use normal expedited patching rather than emergency internet-wide response because the documented path is local and active exploitation is unconfirmed. Establish subsystem exposure before escalating unaffected general-purpose Linux fleets.
Technical view
The Comedi detach path could release an asynchronous area while poll entries remained on its wait queue, producing a use-after-free when entries were triggered or removed. The stable fix write-locks attach_lock, verifies subdevice wait queues have no queued tasks or sleepers, and retains the lock through detachment. The CVSS 3.1 score is 7.3.
Likely exposure
Risk is most relevant where the affected Linux Comedi subsystem is available and local users can access its device-control interface. Systems not using Comedi are less likely to expose the vulnerable path. The bundle marks Linux versions as affected, but its flattened version data does not provide sufficiently reliable ranges for version-only decisions.
Exploitation context
The supplied record does not establish active exploitation and marks the CVE as absent from KEV. Discovery is attributed to syzbot. The vector is local with low privileges and required user interaction, so this is not documented as a remotely reachable flaw. Memory corruption may affect confidentiality, integrity, and availability, but reliable code execution is not demonstrated.
Researcher notes
The vulnerable object is the wait_queue_head within Comedi's allocated asynchronous area. Detachment could free it while poll registrations remained active. The fix serializes registration and detachment through attach_lock and checks for sleepers before deletion. No CWE is supplied. Exact affected and fixed version boundaries should be confirmed against branch commits or distribution advisories.
Mitigation direction
Apply a Linux stable or distribution update containing the cited Comedi locking fix.
Prioritize systems where local untrusted users can access Comedi device controls.
Reboot affected systems into the updated kernel after installation.
If patching is delayed, consult vendor guidance for safely restricting or disabling unused Comedi functionality.
Validation and detection
Map each running kernel build to its distribution advisory or applicable cited stable fix.
Confirm whether Comedi support, modules, and device interfaces are present and accessible.
Verify the updated kernel is running, rather than merely installed.
Review kernel logs for Comedi-related use-after-free, wait-queue, detach, or crash events.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cve · low confidence lookup
CVE-2025-38687 mapping review
Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
1CVSS vectors
3Timeline events
2ADP providers
13Source links
CVSS vector scores
1 official score
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.