CVE-2025-40003: net: mscc: ocelot: Fix use-after-free caused by cyclic delayed work

Published Oct 18, 2025
·
Updated

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

net: mscc: ocelot: Fix use-after-free caused by cyclic delayed work

The origin code calls canceldelayedwork() in ocelotstatsdeinit() to cancel the cyclic delayed work item ocelot->statswork. However, canceldelayedwork() may fail to cancel the work item if it is already executing. While destroyworkqueue() does wait for all pending work items in the work queue to complete before destroying the work queue, it cannot prevent the delayed work item from being rescheduled within the ocelotcheckstatswork() function. This limitation exists because the delayed work item is only enqueued into the work queue after its timer expires. Before the timer expiration, destroyworkqueue() has no visibility of this pending work item. Once the work queue appears empty, destroyworkqueue() proceeds with destruction. When the timer eventually expires, the delayed work item gets queued again, leading to the following warning:

workqueue: cannot queue ocelotcheckstatswork on wq ocelot-switch-stats WARNING: CPU: 2 PID: 0 at kernel/workqueue.c:2255 queuework+0x875/0xaf0 ... RIP: 0010:queuework+0x875/0xaf0 ... RSP: 0018:ffff88806d108b10 EFLAGS: 00010086 RAX: 0000000000000000 RBX: 0000000000000101 RCX: 0000000000000027 RDX: 0000000000000027 RSI: 0000000000000004 RDI: ffff88806d123e88 RBP: ffffffff813c3170 R08: 0000000000000000 R09: ffffed100da247d2 R10: ffffed100da247d1 R11: ffff88806d123e8b R12: ffff88800c00f000 R13: ffff88800d7285c0 R14: ffff88806d0a5580 R15: ffff88800d7285a0 FS: 0000000000000000(0000) GS:ffff8880e5725000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fe18e45ea10 CR3: 0000000005e6c000 CR4: 00000000000006f0 Call Trace: <IRQ> ? kasanreport+0xc6/0xf0 ? pfxdelayedworktimerfn+0x10/0x10 ? pfxdelayedworktimerfn+0x10/0x10 calltimerfn+0x25/0x1c0 runtimerbase.part.0+0x3be/0x8c0 ? pfxdelayedworktimerfn+0x10/0x10 ? rcuschedclockirq+0xb06/0x27d0 ? pfxruntimerbase.part.0+0x10/0x10 ? trytowakeup+0xb15/0x1960 ? rawspinlockirq+0x80/0xe0 ? pfxrawspinlockirq+0x10/0x10 tmigrhandleremoteup+0x603/0x7e0 ? pfxtmigrhandleremoteup+0x10/0x10 ? schedbalancetrigger+0x1c0/0x9f0 ? schedtick+0x221/0x5a0 ? rawspinlockirq+0x80/0xe0 ? pfxrawspinlockirq+0x10/0x10 ? ticknohzhandler+0x339/0x440 ? pfxtmigrhandleremoteup+0x10/0x10 walkgroups.isra.0+0x42/0x150 tmigrhandleremote+0x1f4/0x2e0 ? pfxtmigrhandleremote+0x10/0x10 ? ktimeget+0x60/0x140 ? lapicnextevent+0x11/0x20 ? clockeventsprogramevent+0x1d4/0x2a0 ? hrtimerinterrupt+0x322/0x780 handlesoftirqs+0x16a/0x550 irqexitrcu+0xaf/0xe0 sysvecapictimerinterrupt+0x70/0x80 </IRQ> ...

The following diagram reveals the cause of the above warning:

CPU 0 (remove) | CPU 1 (delayed work callback) msccocelotremove() | ocelotdeinit() | ocelotcheckstatswork() ocelotstatsdeinit() | canceldelayedwork()| ... | queuedelayedwork() destroyworkqueue() | (wait a time) | queuework() //UAF

The above scenario actually constitutes a UAF vulnerability.

The ocelotstatsdeinit() is only invoked when initialization failure or resource destruction, so we must ensure that any delayed work items cannot be rescheduled.

Replace canceldelayedwork() with disabledelayedworksync() to guarantee proper cancellation of the delayed work item and ensure completion of any currently executing work before the workqueue is deallocated.

A deadlock concern was considered: ocelotstatsdeinit() is called in a process context and is not holding any locks that the delayed work item might also need. Therefore, the use of the sync() variant is safe here.

This bug was identified through static analysis. To reproduce the issue and validate the fix, I simulated ocelot-swit ---truncated---

Affected Software

5 affected components
Linux Kernel
Microsoft azl3 kernel 6.6.104.2-4
Microsoft azl3 kernel 6.6.96.2-2
Microsoft azl3 kernel 6.6.112.1-2
Microsoft azl3 kernel 6.6.117.1-1

Event History

Oct 18, 2025
CVE Published
via MITRE·08:03 AM
Data Sourced
via MITRE·08:03 AM
Description
Data Sourced
via NVD·08:15 AM
Description
Oct 19, 2025
Data Sourced
via Microsoft·01:01 AM
DescriptionSeverityWeaknessAffected Software
Updated
via Microsoft·01:01 AM
Affected Software
Updated
via Microsoft·01:01 AM
DescriptionSeverity
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2025-40003?

CVE-2025-40003 is classified as a high severity vulnerability due to the potential for a use-after-free condition in the Linux kernel.

2

How do I fix CVE-2025-40003?

To fix CVE-2025-40003, update your Linux kernel to the latest version that addresses this vulnerability.

3

What components are affected by CVE-2025-40003?

CVE-2025-40003 affects the Linux kernel, specifically the mscc ocelot networking driver.

4

What is the impact of CVE-2025-40003?

The impact of CVE-2025-40003 is that it may lead to a denial of service or malicious code execution due to the use-after-free issue.

5

Is there a public exploit available for CVE-2025-40003?

As of now, there are no public exploits for CVE-2025-40003, but it is recommended to apply patches promptly to mitigate risks.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203