tcp: fix reordering addition overflow in MTU probing
Subsystems (4)
Eric Dumazet
maintainerPATCH 1/1 tcp: fix reordering addition overflow in MTU probing
From: Kyle Zeng <[email protected]>
Commit efb8763d7bbb ("net: ipv4: bound TCP reordering sysctl writes and MTU probe sizes") widened size_needed and the MSS multiplication, but tp->reordering + 1 is still evaluated as u32. RTAX_REORDERING accepts an unrestricted u32, and tcp_init_metrics() can install U32_MAX.
In that case the extra-data requirement becomes zero. A write queue with probe_size - 1 data bytes and a FIN satisfies the sequence-space check. The coalescing walk can pass the queue head to tcp_skb_can_collapse(), and tcp_clone_payload() can produce an skb whose advertised payload exceeds the data in its fragments. Local delivery followed by TCP_ZEROCOPY_RECEIVE can then walk beyond the fragment array. KASAN reports a slab-out-of-bounds read in can_map_frag().
Cast reordering before incrementing it so the arithmetic handles the entire u32 metric range. For U32_MAX, the required size exceeds the 32-bit queue and window limits, so the existing checks skip the probe. The calculation is unchanged for all other reordering values.
--- net/ipv4/tcp_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_output.c +1 -1
@@ -2720,7 +2720,7 @@ static int tcp_mtu_probe(struct sock *sk) mss_now =tcp_current_mss (sk); probe_size =tcp_mtu_to_mss (sk, (icsk->icsk_mtup.search_high + icsk->icsk_mtup.search_low) >>1 ); - size_needed = probe_size + (tp->reordering +1 ) * (u64 )tp->mss_cache; + size_needed = probe_size + ((u64 )tp->reordering +1 ) * tp->mss_cache; interval = icsk->icsk_mtup.search_high - icsk->icsk_mtup.search_low;/* When misfortune happens, we are reprobing actively, * and then reprobe timer has expired. We stick with current
Signature · 1 line
2.53.0
Quoted 37 lines · Eric Dumazet
From: Kyle Zeng <[email protected]>
Commit
efb8763d7bbb("net: ipv4: bound TCP reordering sysctl writes and MTU probe sizes") widenedsize_neededand the MSS multiplication, buttp->reordering+ 1 is still evaluated as u32.RTAX_REORDERINGaccepts an unrestricted u32, andtcp_init_metrics()can installU32_MAX.In that case the extra-data requirement becomes zero. A write queue with
probe_size- 1 data bytes and a FIN satisfies the sequence-space check. The coalescing walk can pass the queue head totcp_skb_can_collapse(), andtcp_clone_payload()can produce an skb whose advertised payload exceeds the data in its fragments. Local delivery followed byTCP_ZEROCOPY_RECEIVEcan then walk beyond the fragment array. KASAN reports a slab-out-of-bounds read incan_map_frag().Cast reordering before incrementing it so the arithmetic handles the entire u32 metric range. For
U32_MAX, the required size exceeds the 32-bit queue and window limits, so the existing checks skip the probe. The calculation is unchanged for all other reordering values.Fixes efb8763d7bbb ("net: ipv4: bound TCP reordering sysctl writes and MTU probe sizes")Cc Wyatt Feng <[email protected]>Cc Ren Wei <[email protected]>Signed-off-by Kyle Zeng <[email protected]>Signed-off-by Eric Dumazet <[email protected]>--- net/ipv4/tcp_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/ipv4/tcp_output.c +0
-0
net/ipv4/tcp_output.c static int tcp_mtu_probe(struct sock *sk)
Quoted 9 lines
net/ipv4/tcp_output.c +1
-2@@ -2720,7 +2720,7 @@ static int tcp_mtu_probe(struct sock *sk) mss_now =tcp_current_mss (sk); probe_size =tcp_mtu_to_mss (sk, (icsk->icsk_mtup.search_high + icsk->icsk_mtup.search_low) >>1 ); - size_needed = probe_size + (tp->reordering +1 ) * (u64 )tp->mss_cache; + size_needed = probe_size + ((u64 )tp->reordering +1 ) * tp->mss_cache; interval = icsk->icsk_mtup.search_high - icsk->icsk_mtup.search_low;/* When misfortune happens, we are reprobing actively, * and then reprobe timer has expired. We stick with current --
Thanks Kyle and Eric!
neal
ps: It also looks good to the frontier LLM I checked with.
Quoted 21 lines · Eric Dumazet
From: Kyle Zeng <[email protected]>
Commit
efb8763d7bbb("net: ipv4: bound TCP reordering sysctl writes and MTU probe sizes") widenedsize_neededand the MSS multiplication, buttp->reordering+ 1 is still evaluated as u32.RTAX_REORDERINGaccepts an unrestricted u32, andtcp_init_metrics()can installU32_MAX.In that case the extra-data requirement becomes zero. A write queue with
probe_size- 1 data bytes and a FIN satisfies the sequence-space check. The coalescing walk can pass the queue head totcp_skb_can_collapse(), andtcp_clone_payload()can produce an skb whose advertised payload exceeds the data in its fragments. Local delivery followed byTCP_ZEROCOPY_RECEIVEcan then walk beyond the fragment array. KASAN reports a slab-out-of-bounds read incan_map_frag().Cast reordering before incrementing it so the arithmetic handles the entire u32 metric range. For
U32_MAX, the required size exceeds the 32-bit queue and window limits, so the existing checks skip the probe. The calculation is unchanged for all other reordering values.
Quoted 6 lines
Fixes efb8763d7bbb ("net: ipv4: bound TCP reordering sysctl writes and MTU probe sizes")Cc Wyatt Feng <[email protected]>Cc Ren Wei <[email protected]>Signed-off-by Kyle Zeng <[email protected]>Signed-off-by Eric Dumazet <[email protected]>
Quoted 21 lines · Eric Dumazet
From: Kyle Zeng <[email protected]>
Commit
efb8763d7bbb("net: ipv4: bound TCP reordering sysctl writes and MTU probe sizes") widenedsize_neededand the MSS multiplication, buttp->reordering+ 1 is still evaluated as u32.RTAX_REORDERINGaccepts an unrestricted u32, andtcp_init_metrics()can installU32_MAX.In that case the extra-data requirement becomes zero. A write queue with
probe_size- 1 data bytes and a FIN satisfies the sequence-space check. The coalescing walk can pass the queue head totcp_skb_can_collapse(), andtcp_clone_payload()can produce an skb whose advertised payload exceeds the data in its fragments. Local delivery followed byTCP_ZEROCOPY_RECEIVEcan then walk beyond the fragment array. KASAN reports a slab-out-of-bounds read incan_map_frag().Cast reordering before incrementing it so the arithmetic handles the entire u32 metric range. For
U32_MAX, the required size exceeds the 32-bit queue and window limits, so the existing checks skip the probe. The calculation is unchanged for all other reordering values.
Quoted 6 lines
Fixes efb8763d7bbb ("net: ipv4: bound TCP reordering sysctl writes and MTU probe sizes")Cc Wyatt Feng <[email protected]>Cc Ren Wei <[email protected]>Signed-off-by Kyle Zeng <[email protected]>Signed-off-by Eric Dumazet <[email protected]>
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 8 lines · On Wed, 28 Oct 2026 17:02:26 +0100 you wrote:
From: Kyle Zeng <[email protected]>
Commit
efb8763d7bbb("net: ipv4: bound TCP reordering sysctl writes and MTU probe sizes") widenedsize_neededand the MSS multiplication, buttp->reordering+ 1 is still evaluated as u32.RTAX_REORDERINGaccepts an unrestricted u32, andtcp_init_metrics()can installU32_MAX.[...]
Here is the summary with links:
- [net] tcp: fix reordering addition overflow in MTU probing
https://git.kernel.org/netdev/net/c/c1df9c0c0536
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html