CVE-2026-142949: tcp: fix NULL pointer dereference when restarting a Fast Open listener
In the Linux kernel, the following vulnerability has been resolved:
tcp: fix NULL pointer dereference when restarting a Fast Open listener
When a valid RST is received for a Fast Open child accepted before the three-way handshake completes, reqskfastopenremove() adds the requestsock to the listener's RST list if the listener is in TCPLISTEN.
An application can call shutdown(SHUTRD) on a listener socket. inetcsklistenstop() checks rskqrsthead without holding fastopenq.lock. If rskqrsthead is NULL, it does not acquire the lock and therefore does not synchronize with an insertion by reqskfastopenremove() after that function has passed the TCPLISTEN check.
The more likely outcome of this race, even without a subsequent listen(), is a leak. If reqskfastopenremove() inserts a requestsock after inetcsklistenstop() observes an empty list and returns, the requestsock is stranded in rskqrsthead and keeps a reference on the listener. The socket is already in TCPCLOSE, so a subsequent close() does not call inetcsklistenstop() again.
If listen() is called again on the same socket before the delayed list insertion, the insertion can overlap the queue initialization in reqskqueuealloc(). If it occurs after rskqrsthead is set to NULL but before rskqrsttail is set to NULL, rskqrsthead points to the requestsock while rskqrsttail is NULL.
When a valid RST is later received for another accepted Fast Open child, rskqrsthead is not NULL, so reqskfastopenremove() attempts to write the requestsock pointer to rskqrsttail->dlnext while rskqrsttail is NULL. KASAN reports:
BUG: KASAN: null-ptr-deref in reqskfastopenremove+0x147/0x210 Write of size 8 at addr 0000000000000088 by task swapper/3/0 ... Call Trace: <IRQ> ... reqskfastopenremove+0x147/0x210 tcpcheckreq+0xa70/0x1060 ... tcprcvstateprocess+0x1cb/0x2ae0 ... tcpv4dorcv+0x1fe/0x740 tcpv4rcv+0x1744/0x2070 ... ipprotocoldeliverrcu+0x5c/0x280 iplocaldeliverfinish+0x171/0x330 iplocaldeliver+0x107/0x370 ... </IRQ>
To widen the race window, the issue was reproduced after adding mdelay(3000) immediately after reqskfastopenremove() checks that the listener is in TCPLISTEN and immediately after reqskqueuealloc() sets rskqrsthead to NULL.
Make inetcsklistenstop() acquire fastopenq.lock regardless of the value of rskqrsthead and detach the list while holding the lock. With this synchronization, reqskfastopenremove() either inserts the requestsock before inetcsklistenstop() acquires the lock, in which case inetcsklistenstop() reclaims it, or sees that the listener is not in TCPLISTEN and does not insert anything.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
Modify inet_csk_listen_stop() to acquire fastopenq.lock regardless of whether rskq_rst_head is NULL.
Event History
Frequently Asked Questions
Which systems are exposed to this race?
Exposure requires a Linux TCP Fast Open listener with a child connection accepted before the three-way handshake completes. The problematic path involves shutting down read access on the listener and, for the NULL dereference outcome, calling listen() again on the same socket while a delayed request insertion overlaps queue initialization.
What network condition is needed to trigger the affected path?
A valid TCP RST must be received for a Fast Open child before the three-way handshake completes. That RST can cause reqsk_fastopen_remove() to add the request to the listener's RST list while listener shutdown is occurring.
Is a crash the only possible outcome?
No. The description states that the more likely outcome, even without calling listen() again, is a leaked request_sock that remains stranded in the RST list and retains a reference to the listener. Re-listening on the same socket during the delayed insertion creates the NULL-pointer-dereference race.
Does the provided information identify affected kernel versions or an interim workaround?
No. The provided data identifies the Linux kernel and includes stable-tree fix references, but it does not list affected or fixed version ranges or a workaround.