tcp: ipv6: clamp default adverting MSS to avoid GSO_BY_FRAGS (0xFFFF)
Subsystems (3)
PATCH 1/1 tcp: ipv6: clamp default adverting MSS to avoid GSO_BY_FRAGS (0xFFFF)
When MTU is large, ip6_default_advmss() can return IPV6_MAXPLEN (65535). This is interpreted by TCP as mss_clamp, allowing the MSS to reach 65535.
However, 0xFFFF is also used as a magic value GSO_BY_FRAGS in the kernel. If a TCP packet with gso_size=0xFFFF is passed to skb_segment(), it will be mistakenly treated as GSO_BY_FRAGS, leading to a NULL pointer dereference because local TCP packets do not use frag_list.
Fix this by returning min(IPV6_MAXPLEN, GSO_BY_FRAGS - 1) (65534) from ip6_default_advmss() when MTU is large.
Also update the stale comment in ip6_default_advmss() which suggested that IPV6_MAXPLEN is returned to mean "any MSS".
---
Cc: Marcelo Ricardo Leitner <[email protected]>
Cc: Xin Long <[email protected]>
--- net/ipv6/route.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/ipv6/route.c +3 -3
@@ -3275,11 +3275,11 @@ static unsigned int ip6_default_advmss(const struct dst_entry *dst)/* * Maximal non-jumbo IPv6 payload is IPV6_MAXPLEN and * corresponding MSS is IPV6_MAXPLEN - tcp_header_size. -* IPV6_MAXPLEN is also valid and means: "any MSS, -* rely only on pmtu discovery" +* Limit the default MSS to GSO_BY_FRAGS - 1 to avoid +* collision with the GSO_BY_FRAGS magic value (0xFFFF). */ if (mtu >IPV6_MAXPLEN -sizeof (struct tcphdr )) - mtu =IPV6_MAXPLEN ; + mtu = min_t(unsigned int, IPV6_MAXPLEN, GSO_BY_FRAGS - 1);return mtu; }
Signature · 1 line
2.54.0.1136.gdb2ca164c4-goog
Quoted 12 lines · Eric Dumazet
When MTU is large,
ip6_default_advmss()can returnIPV6_MAXPLEN(65535). This is interpreted by TCP asmss_clamp, allowing the MSS to reach 65535.However,
0xFFFFis also used as a magic valueGSO_BY_FRAGSin the kernel. If a TCP packet with gso_size=0xFFFF is passed toskb_segment(), it will be mistakenly treated asGSO_BY_FRAGS, leading to a NULL pointer dereference because local TCP packets do not usefrag_list.Fix this by returning
min(IPV6_MAXPLEN, GSO_BY_FRAGS - 1)(65534) fromip6_default_advmss()when MTU is large.
Quoted 7 lines
Also update the stale comment in
ip6_default_advmss()which suggested thatIPV6_MAXPLENis returned to mean "any MSS".Fixes 3953c46c3ac7 ("sk_buff: allow segmenting based on frag sizes")Reported-by [email protected]Signed-off-by Eric Dumazet <[email protected]>
Interesting !
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Fri, 12 Jun 2026 16:25:17 +0000 you wrote:
When MTU is large,
ip6_default_advmss()can returnIPV6_MAXPLEN(65535). This is interpreted by TCP asmss_clamp, allowing the MSS to reach 65535.However,
0xFFFFis also used as a magic valueGSO_BY_FRAGSin the kernel. If a TCP packet with gso_size=0xFFFF is passed toskb_segment(), it will be mistakenly treated asGSO_BY_FRAGS, leading to a NULL pointer dereference because local TCP packets do not usefrag_list.[...]
Here is the summary with links:
- [net] tcp: ipv6: clamp default adverting MSS to avoid GSO_BY_FRAGS (0xFFFF)
https://git.kernel.org/netdev/net/c/2bf43d0e2e6a
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html