CVE-2025-39945

Severity CVSS v4.0:
Pending analysis
Type:
CWE-416 Use After Free
Publication date:
04/10/2025
Last modified:
23/01/2026

Description

In the Linux kernel, the following vulnerability has been resolved:<br /> <br /> cnic: Fix use-after-free bugs in cnic_delete_task<br /> <br /> The original code uses cancel_delayed_work() in cnic_cm_stop_bnx2x_hw(),<br /> which does not guarantee that the delayed work item &amp;#39;delete_task&amp;#39; has<br /> fully completed if it was already running. Additionally, the delayed work<br /> item is cyclic, the flush_workqueue() in cnic_cm_stop_bnx2x_hw() only<br /> blocks and waits for work items that were already queued to the<br /> workqueue prior to its invocation. Any work items submitted after<br /> flush_workqueue() is called are not included in the set of tasks that the<br /> flush operation awaits. This means that after the cyclic work items have<br /> finished executing, a delayed work item may still exist in the workqueue.<br /> This leads to use-after-free scenarios where the cnic_dev is deallocated<br /> by cnic_free_dev(), while delete_task remains active and attempt to<br /> dereference cnic_dev in cnic_delete_task().<br /> <br /> A typical race condition is illustrated below:<br /> <br /> CPU 0 (cleanup) | CPU 1 (delayed work callback)<br /> cnic_netdev_event() |<br /> cnic_stop_hw() | cnic_delete_task()<br /> cnic_cm_stop_bnx2x_hw() | ...<br /> cancel_delayed_work() | /* the queue_delayed_work()<br /> flush_workqueue() | executes after flush_workqueue()*/<br /> | queue_delayed_work()<br /> cnic_free_dev(dev)//free | cnic_delete_task() //new instance<br /> | dev = cp-&gt;dev; //use<br /> <br /> Replace cancel_delayed_work() with cancel_delayed_work_sync() to ensure<br /> that the cyclic delayed work item is properly canceled and that any<br /> ongoing execution of the work item completes before the cnic_dev is<br /> deallocated. Furthermore, since cancel_delayed_work_sync() uses<br /> __flush_work(work, true) to synchronously wait for any currently<br /> executing instance of the work item to finish, the flush_workqueue()<br /> becomes redundant and should be removed.<br /> <br /> This bug was identified through static analysis. To reproduce the issue<br /> and validate the fix, I simulated the cnic PCI device in QEMU and<br /> introduced intentional delays — such as inserting calls to ssleep()<br /> within the cnic_delete_task() function — to increase the likelihood<br /> of triggering the bug.

Vulnerable products and versions

CPE From Up to
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 2.6.37 (including) 5.4.300 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.5 (including) 5.10.245 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.11 (including) 5.15.194 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.16 (including) 6.1.154 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 6.2 (including) 6.6.108 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 6.7 (including) 6.12.49 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 6.13 (including) 6.16.9 (excluding)
cpe:2.3:o:linux:linux_kernel:6.17:rc1:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.17:rc2:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.17:rc3:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.17:rc4:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.17:rc5:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.17:rc6:*:*:*:*:*:*