CVE-2026-143152: tcp: do not coalesce segments after FIN
In the Linux kernel, the following vulnerability has been resolved:
tcp: do not coalesce segments after FIN
A FIN consumes a sequence number. If another FIN segment is coalesced into an skb that already carries FIN, endseq advances to account for the additional FIN, but tcpflags still contains only one FIN bit.
When the preceding gap is filled and tcpofoqueue() processes the coalesced skb, rcvnxt advances to the skb's endseq. When the receive path consumes all data in the skb, copiedseq advances by the data length and one sequence number for FIN. If three or more FIN segments have been coalesced into one skb, tcpinq() can still return a positive value after the receive queue becomes empty and the SOCKDONE adjustment is applied.
TCPZEROCOPYRECEIVE is another consumer affected by this state. tcpzerocopyreceive() takes its length from tcpinq() and follows skb->next without checking for the end of the receive queue.
Software kTLS receive is one consumer affected by this state. When strp->copymode is false, tlsstrpmsgconsume() calls the TCP helper tcpreaddone() to consume the current TLS record. In the reproducer, tcpreaddone() consumed the record data and one FIN before freeing the receive skb.
When kTLS looked for the next record, tcpinq() reported at least TLSHEADERSIZE bytes even though the receive queue was empty. tcprecvskb() returned NULL, so tlsstrploadanchorwithqueue() hit WARNONONCE() and returned without updating the anchor.
Since tcpinq() had reported at least TLSHEADERSIZE, tlsstrpreadsock() proceeded to tlsstrpcheckqueueok(). skbshinfo(strp->anchor)->fraglist still pointed to the freed receive skb. tlsstrpcheckqueueok() then read TCPSKBCB(first)->seq through the stale pointer, causing a use-after-free.
The reproducer followed this call path:
tlsrxrecdone() tlsstrpmsgconsume() tcpreaddone() // frees the receive skb tlsstrpcheckrcv() tlsstrpreadsock() tlsstrploadanchorwithqueue() // returns after WARNONONCE() tcprecvskb() == NULL tlsstrpcheckqueueok() TCPSKBCB(first)->seq // reads the freed receive skb
KASAN reported:
BUG: KASAN: slab-use-after-free in tlsstrpcheckqueueok.isra.0+0x5f/0x100 Read of size 4 at addr ffff888103169ca8 by task ktls-server/71 ... Call Trace: <TASK> ... tlsstrpcheckqueueok.isra.0+0x5f/0x100 tlsstrpcheckrcv+0x2a9/0x400 ... tlsswrecvmsg+0x3ce/0xa10 ... sockrecvmsg+0xea/0x100 sysrecvfrom+0x142/0x1f0 ... x64sysrecvfrom+0x76/0x90 dosyscall64+0xdd/0x4a0 entrySYSCALL64afterhwframe+0x77/0x7f ... </TASK> ... Freed by task 71: ... napiskbcacheput+0x24/0xf0 skbattemptdeferfree+0x183/0x3b0 tcpreaddone+0x2d4/0x340 tlsstrpmsgconsume+0x45/0x80 tlsswrecvmsg+0x3c4/0xa10 ...
In tcptrycoalesce(), skip coalescing when the destination skb already carries FIN. tcpaddbacklog() calls skbtrycoalesce() directly instead of using this helper, so add the same check there. Since both paths check only the destination skb, a final segment carrying data and FIN can still be coalesced into an skb without FIN when the other coalescing checks pass.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In tcp_try_coalesce(), skip coalescing when the destination skb already carries FIN. Apply the same check in tcp_add_backlog(), which calls skb_try_coalesce() directly.