CVE-2025-40258: mptcp: fix race condition in mptcp_schedule_work()
In the Linux kernel, the following vulnerability has been resolved:
mptcp: fix race condition in mptcpschedulework()
syzbot reported use-after-free in mptcpschedulework() [1]
Issue here is that mptcpschedulework() schedules a work, then gets a refcount on sk->skrefcnt if the work was scheduled. This refcount will be released by mptcpworker().
[A] if (schedulework(...)) { [B] sockhold(sk); return true; }
Problem is that mptcpworker() can run immediately and complete before [B]
We need instead :
sockhold(sk); if (schedulework(...)) return true; sockput(sk);
[1] refcountt: addition on 0; use-after-free. WARNING: CPU: 1 PID: 29 at lib/refcount.c:25 refcountwarnsaturate+0xfa/0x1d0 lib/refcount.c:25 Call Trace: <TASK> refcountadd include/linux/refcount.h:-1 [inline] refcountinc include/linux/refcount.h:366 [inline] refcountinc include/linux/refcount.h:383 [inline] sockhold include/net/sock.h:816 [inline] mptcpschedulework+0x164/0x1a0 net/mptcp/protocol.c:943 mptcptouttimer+0x21/0xa0 net/mptcp/protocol.c:2316 calltimerfn+0x17e/0x5f0 kernel/time/timer.c:1747 expiretimers kernel/time/timer.c:1798 [inline] runtimers kernel/time/timer.c:2372 [inline] runtimerbase+0x648/0x970 kernel/time/timer.c:2384 runtimerbase kernel/time/timer.c:2393 [inline] runtimersoftirq+0xb7/0x180 kernel/time/timer.c:2403 handlesoftirqs+0x22f/0x710 kernel/softirq.c:622 dosoftirq kernel/softirq.c:656 [inline] runktimerd+0xcf/0x190 kernel/softirq.c:1138 smpbootthreadfn+0x542/0xa60 kernel/smpboot.c:160 kthread+0x711/0x8a0 kernel/kthread.c:463 retfromfork+0x4bc/0x870 arch/x86/kernel/process.c:158 retfromforkasm+0x1a/0x30 arch/x86/entry/entry64.S:245
Other sources
In the Linux kernel, the following vulnerability has been resolved:
mptcp: fix race condition in mptcpschedulework()
syzbot reported use-after-free in mptcpschedulework() [1]
Issue here is that mptcpschedulework() schedules a work, then gets a refcount on sk-skrefcnt if the work was scheduled. This refcount will be released by mptcpworker().
[A] if (schedulework(...)) { [B] sockhold(sk); return true; }
Problem is that mptcpworker() can run immediately and complete before [B]
We need instead :
sockhold(sk); if (schedulework(...)) return true; sockput(sk);
[1] refcountt: addition on 0; use-after-free. WARNING: CPU: 1 PID: 29 at lib/refcount.c:25 refcountwarnsaturate+0xfa/0x1d0 lib/refcount.c:25 Call Trace: TASK refcountadd include/linux/refcount.h:-1 [inline] refcountinc include/linux/refcount.h:366 [inline] refcountinc include/linux/refcount.h:383 [inline] sockhold include/net/sock.h:816 [inline] mptcpschedulework+0x164/0x1a0 net/mptcp/protocol.c:943 mptcptouttimer+0x21/0xa0 net/mptcp/protocol.c:2316 calltimerfn+0x17e/0x5f0 kernel/time/timer.c:1747 expiretimers kernel/time/timer.c:1798 [inline] runtimers kernel/time/timer.c:2372 [inline] runtimerbase+0x648/0x970 kernel/time/timer.c:2384 runtimerbase kernel/time/timer.c:2393 [inline] runtimersoftirq+0xb7/0x180 kernel/time/timer.c:2403 handlesoftirqs+0x22f/0x710 kernel/softirq.c:622 dosoftirq kernel/softirq.c:656 [inline] runktimerd+0xcf/0x190 kernel/softirq.c:1138 smpbootthreadfn+0x542/0xa60 kernel/smpboot.c:160 kthread+0x711/0x8a0 kernel/kthread.c:463 retfromfork+0x4bc/0x870 arch/x86/kernel/process.c:158 retfromforkasm+0x1a/0x30 arch/x86/entry/entry64.S:245
— IBM
Affected Software
Event History
Frequently Asked Questions
What is the severity of CVE-2025-40258?
CVE-2025-40258 has a medium severity rating due to its potential for exploitation via a race condition.
How do I fix CVE-2025-40258?
To fix CVE-2025-40258, update the Linux kernel to the latest version where the vulnerability has been addressed.
What impact does CVE-2025-40258 have on system security?
CVE-2025-40258 can lead to a use-after-free condition, potentially allowing for remote code execution.
Is CVE-2025-40258 specific to certain Linux kernel versions?
CVE-2025-40258 affects multiple versions of the Linux kernel, so it is crucial to check if your version is vulnerable.
How was CVE-2025-40258 discovered?
CVE-2025-40258 was reported by syzbot, which revealed a use-after-free in the mptcp_schedule_work() function.