comedi: fix race between polling and detaching
Summary
| CVE | CVE-2025-38687 |
|---|---|
| State | PUBLISHED |
| Assigner | Linux |
| Source Priority | CVE Program / NVD first with legacy fallback |
| Published | 2025-09-04 16:15:36 UTC |
| Updated | 2026-05-12 13:16:55 UTC |
| Description | 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. |
Risk And Classification
Primary CVSS: v3.1 4.7 MEDIUM from [email protected]
CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H
Problem Types: CWE-362
CVSS v3.1 Breakdown
Attack Vector
LocalAttack Complexity
HighPrivileges Required
LowUser Interaction
NoneScope
UnchangedConfidentiality
NoneIntegrity
NoneAvailability
HighCVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H
NVD Known Affected Configurations (CPE 2.3)
| Type | Vendor | Product | Version | Update | Edition | Language |
|---|---|---|---|---|---|---|
| Operating System | Linux | Linux Kernel | All | All | All | All |
Vendor Declared Affected Products
| Source | Vendor | Product | Version | Platforms |
|---|---|---|---|---|
| CNA | Linux | Linux | affected 2f3fdcd7ce935f6f2899ceab57dc8fe5286db3e1 fe67122ba781df44a1a9716eb1dfd751321ab512 git | Not specified |
| CNA | Linux | Linux | affected 2f3fdcd7ce935f6f2899ceab57dc8fe5286db3e1 cd4286123d6948ff638ea9cd5818ae4796d5d252 git | Not specified |
| CNA | Linux | Linux | affected 2f3fdcd7ce935f6f2899ceab57dc8fe5286db3e1 d85fac8729c9acfd72368faff1d576ec585e5c8f git | Not specified |
| CNA | Linux | Linux | affected 2f3fdcd7ce935f6f2899ceab57dc8fe5286db3e1 0f989f9d05492028afd2bded4b42023c57d8a76e git | Not specified |
| CNA | Linux | Linux | affected 2f3fdcd7ce935f6f2899ceab57dc8fe5286db3e1 5c4a2ffcbd052c69bbf4680677d4c4eaa5a252d4 git | Not specified |
| CNA | Linux | Linux | affected 2f3fdcd7ce935f6f2899ceab57dc8fe5286db3e1 017198079551a2a5cf61eae966af3c4b145e1f3b git | Not specified |
| CNA | Linux | Linux | affected 2f3fdcd7ce935f6f2899ceab57dc8fe5286db3e1 71ca60d2e631cf9c63bcbc7017961c61ff04e419 git | Not specified |
| CNA | Linux | Linux | affected 2f3fdcd7ce935f6f2899ceab57dc8fe5286db3e1 5724e82df4f9a4be62908362c97d522d25de75dd git | Not specified |
| CNA | Linux | Linux | affected 2f3fdcd7ce935f6f2899ceab57dc8fe5286db3e1 35b6fc51c666fc96355be5cd633ed0fe4ccf68b2 git | Not specified |
| CNA | Linux | Linux | affected 3.14 | Not specified |
| CNA | Linux | Linux | unaffected 3.14 semver | Not specified |
| CNA | Linux | Linux | unaffected 5.4.297 5.4.* semver | Not specified |
| CNA | Linux | Linux | unaffected 5.10.241 5.10.* semver | Not specified |
| CNA | Linux | Linux | unaffected 5.15.190 5.15.* semver | Not specified |
| CNA | Linux | Linux | unaffected 6.1.149 6.1.* semver | Not specified |
| CNA | Linux | Linux | unaffected 6.6.103 6.6.* semver | Not specified |
| CNA | Linux | Linux | unaffected 6.12.43 6.12.* semver | Not specified |
| CNA | Linux | Linux | unaffected 6.15.11 6.15.* semver | Not specified |
| CNA | Linux | Linux | unaffected 6.16.2 6.16.* semver | Not specified |
| CNA | Linux | Linux | unaffected 6.17 * original_commit_for_fix | Not specified |
| ADP | Siemens | SIMATIC CN 4100 | affected V5.0 custom | Not specified |
References
| Reference | Source | Link | Tags |
|---|---|---|---|
| lists.debian.org/debian-lts-announce/2025/10/msg00008.html | af854a3a-2127-422b-91ae-364da2661108 | lists.debian.org | Third Party Advisory |
| git.kernel.org/stable/c/cd4286123d6948ff638ea9cd5818ae4796d5d252 | 416baaa9-dc9f-4396-8d5f-8c081fb06d67 | git.kernel.org | Patch |
| git.kernel.org/stable/c/017198079551a2a5cf61eae966af3c4b145e1f3b | 416baaa9-dc9f-4396-8d5f-8c081fb06d67 | git.kernel.org | Patch |
| git.kernel.org/stable/c/5c4a2ffcbd052c69bbf4680677d4c4eaa5a252d4 | 416baaa9-dc9f-4396-8d5f-8c081fb06d67 | git.kernel.org | Patch |
| git.kernel.org/stable/c/35b6fc51c666fc96355be5cd633ed0fe4ccf68b2 | 416baaa9-dc9f-4396-8d5f-8c081fb06d67 | git.kernel.org | Patch |
| git.kernel.org/stable/c/0f989f9d05492028afd2bded4b42023c57d8a76e | 416baaa9-dc9f-4396-8d5f-8c081fb06d67 | git.kernel.org | Patch |
| git.kernel.org/stable/c/d85fac8729c9acfd72368faff1d576ec585e5c8f | 416baaa9-dc9f-4396-8d5f-8c081fb06d67 | git.kernel.org | Patch |
| git.kernel.org/stable/c/5724e82df4f9a4be62908362c97d522d25de75dd | 416baaa9-dc9f-4396-8d5f-8c081fb06d67 | git.kernel.org | Patch |
| cert-portal.siemens.com/productcert/html/ssa-032379.html | 0b142b55-0307-4c5a-b3c9-f314f3fb7c5e | cert-portal.siemens.com | |
| git.kernel.org/stable/c/fe67122ba781df44a1a9716eb1dfd751321ab512 | 416baaa9-dc9f-4396-8d5f-8c081fb06d67 | git.kernel.org | Patch |
| lists.debian.org/debian-lts-announce/2025/10/msg00007.html | af854a3a-2127-422b-91ae-364da2661108 | lists.debian.org | Third Party Advisory |
| git.kernel.org/stable/c/71ca60d2e631cf9c63bcbc7017961c61ff04e419 | 416baaa9-dc9f-4396-8d5f-8c081fb06d67 | git.kernel.org | Patch |
| CVE Program record | CVE.ORG | www.cve.org | canonical |
| NVD vulnerability detail | NVD | nvd.nist.gov | canonical, analysis |
No vendor comments have been submitted for this CVE.
There are currently no legacy QID mappings associated with this CVE.