CVE-2026-31530

Source
https://cve.org/CVERecord?id=CVE-2026-31530
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2026-31530.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2026-31530
Downstream
Published
2026-04-22T13:54:42.563Z
Modified
2026-07-11T03:54:15.860688073Z
Summary
cxl/port: Fix use after free of parent_port in cxl_detach_ep()
Details

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

cxl/port: Fix use after free of parentport in cxldetach_ep()

cxldetachep() is called during bottom-up removal when all CXL memory devices beneath a switch port have been removed. For each port in the hierarchy it locks both the port and its parent, removes the endpoint, and if the port is now empty, marks it dead and unregisters the port by calling deleteswitchport(). There are two places during this work where the parent_port may be used after freeing:

First, a concurrent detach may have already processed a port by the time a second worker finds it via busfinddevice(). Without pinning parentport, it may already be freed when we discover port->dead and attempt to unlock the parentport. In a production kernel that's a silent memory corruption, with lock debug, it looks like this:

[]DEBUGLOCKSWARN_ON(__ownertask(owner) != getcurrent()) []WARNING: kernel/locking/mutex.c:949 at _mutexunlockslowpath+0x1ee/0x310 []Call Trace: []mutexunlock+0xd/0x20 []cxldetachep+0x180/0x400 [cxlcore] []devmactionrelease+0x10/0x20 []devresreleaseall+0xa8/0xe0 []deviceunbindcleanup+0xd/0xa0 []reallyprobe+0x1a6/0x3e0

Second, deleteswitchport() releases three devm actions registered against parentport. The last of those is unregisterport() and it calls deviceunregister() on the child port, which can cascade. If parentport is now also empty the device core may unregister and free it too. So by the time deleteswitchport() returns, parentport may be free, and the subsequent deviceunlock(&parentport->dev) operates on freed memory. The kernel log looks same as above, with a different offset in cxldetach_ep().

Both of these issues stem from the absence of a lifetime guarantee between a child port and its parent port.

Establish a lifetime rule for ports: child ports hold a reference to their parent device until release. Take the reference when the port is allocated and drop it when released. This ensures the parent is valid for the full lifetime of the child and eliminates the use after free window in cxldetachep().

This is easily reproduced with a reload of cxl_acpi in QEMU with CXL devices present.

Database specific
{
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/31xxx/CVE-2026-31530.json",
    "cna_assigner": "Linux"
}
References

Affected packages

Git / git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

Affected ranges

Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
2345df54249c6fb7779e2a72b427ee79ed3eaad5
Fixed
d216a4bd138eb57cc4ae7c43b2f709e3482af7e2
Fixed
2c32141462045cf93d54a5146a0ba572b83533dd
Fixed
f7dc6f381a1e5f068333f1faa9265d6af1df4235
Fixed
19d2f0b97a131198efc2c4ca3eb7f980bba8c2b4

Database specific

source
"https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2026-31530.json"

Linux / Kernel

Package

Name
Kernel

Affected ranges

Type
ECOSYSTEM
Events
Introduced
6.3.0
Fixed
6.12.80
Type
ECOSYSTEM
Events
Introduced
6.13.0
Fixed
6.18.21
Type
ECOSYSTEM
Events
Introduced
6.19.0
Fixed
6.19.11

Database specific

source
"https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2026-31530.json"