CVE-2025-39945

Source
https://nvd.nist.gov/vuln/detail/CVE-2025-39945
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2025-39945.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2025-39945
Downstream
Related
Published
2025-10-04T07:31:07.109Z
Modified
2025-11-28T02:35:41.861526Z
Summary
cnic: Fix use-after-free bugs in cnic_delete_task
Details

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

cnic: Fix use-after-free bugs in cnicdeletetask

The original code uses canceldelayedwork() in cniccmstopbnx2xhw(), which does not guarantee that the delayed work item 'deletetask' has fully completed if it was already running. Additionally, the delayed work item is cyclic, the flushworkqueue() in cniccmstopbnx2xhw() only blocks and waits for work items that were already queued to the workqueue prior to its invocation. Any work items submitted after flushworkqueue() is called are not included in the set of tasks that the flush operation awaits. This means that after the cyclic work items have finished executing, a delayed work item may still exist in the workqueue. This leads to use-after-free scenarios where the cnicdev is deallocated by cnicfreedev(), while deletetask remains active and attempt to dereference cnicdev in cnicdeletetask().

A typical race condition is illustrated below:

CPU 0 (cleanup) | CPU 1 (delayed work callback) cnicnetdevevent() | cnicstophw() | cnicdeletetask() cniccmstopbnx2xhw() | ... canceldelayedwork() | /* the queuedelayedwork() flushworkqueue() | executes after flushworkqueue()*/ | queuedelayedwork() cnicfreedev(dev)//free | cnicdeletetask() //new instance | dev = cp->dev; //use

Replace canceldelayedwork() with canceldelayedworksync() to ensure that the cyclic delayed work item is properly canceled and that any ongoing execution of the work item completes before the cnicdev is deallocated. Furthermore, since canceldelayedworksync() uses _flushwork(work, true) to synchronously wait for any currently executing instance of the work item to finish, the flushworkqueue() becomes redundant and should be removed.

This bug was identified through static analysis. To reproduce the issue and validate the fix, I simulated the cnic PCI device in QEMU and introduced intentional delays — such as inserting calls to ssleep() within the cnicdeletetask() function — to increase the likelihood of triggering the bug.

Database specific
{
    "cna_assigner": "Linux",
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/39xxx/CVE-2025-39945.json"
}
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
fdf24086f4752aee5dfb40143c736250df017820
Fixed
fde6e73189f40ebcf0633aed2b68e731c25f3aa3
Fixed
7b6a5b0a6b392263c3767fc945b311ea04b34bbd
Fixed
0405055930264ea8fd26f4131466fa7652e5e47d
Fixed
e1fcd4a9c09feac0902a65615e866dbf22616125
Fixed
8eeb2091e72d75df8ceaa2172638d61b4cf8929a
Fixed
6e33a7eed587062ca8161ad1f4584882a860d697
Fixed
0627e1481676669cae2df0d85b5ff13e7d24c390
Fixed
cfa7d9b1e3a8604afc84e9e51d789c29574fb216

Linux / Kernel

Package

Name
Kernel

Affected ranges

Type
ECOSYSTEM
Events
Introduced
2.6.37
Fixed
5.4.300
Type
ECOSYSTEM
Events
Introduced
5.5.0
Fixed
5.10.245
Type
ECOSYSTEM
Events
Introduced
5.11.0
Fixed
5.15.194
Type
ECOSYSTEM
Events
Introduced
5.16.0
Fixed
6.1.154
Type
ECOSYSTEM
Events
Introduced
6.2.0
Fixed
6.6.108
Type
ECOSYSTEM
Events
Introduced
6.7.0
Fixed
6.12.49
Type
ECOSYSTEM
Events
Introduced
6.13.0
Fixed
6.16.9