Commit b597b30e authored by Yuchung Cheng's avatar Yuchung Cheng Committed by Ben Hutchings

tcp: avoid fragmenting peculiar skbs in SACK

commit b451e5d2 upstream.

This patch fixes a bug in splitting an SKB during SACK
processing. Specifically if an skb contains multiple
packets and is only partially sacked in the higher sequences,
tcp_match_sack_to_skb() splits the skb and marks the second fragment
as SACKed.

The current code further attempts rounding up the first fragment
to MSS boundaries. But it misses a boundary condition when the
rounded-up fragment size (pkt_len) is exactly skb size.  Spliting
such an skb is pointless and causses a kernel warning and aborts
the SACK processing. This patch universally checks such over-split
before calling tcp_fragment to prevent these unnecessary warnings.

Fixes: adb92db8 ("tcp: Make SACK code to split only at mss boundaries")
Signed-off-by: default avatarYuchung Cheng <ycheng@google.com>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
Acked-by: default avatarNeal Cardwell <ncardwell@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 682f39d1
...@@ -1160,13 +1160,14 @@ static int tcp_match_skb_to_sack(struct sock *sk, struct sk_buff *skb, ...@@ -1160,13 +1160,14 @@ static int tcp_match_skb_to_sack(struct sock *sk, struct sk_buff *skb,
*/ */
if (pkt_len > mss) { if (pkt_len > mss) {
unsigned int new_len = (pkt_len / mss) * mss; unsigned int new_len = (pkt_len / mss) * mss;
if (!in_sack && new_len < pkt_len) { if (!in_sack && new_len < pkt_len)
new_len += mss; new_len += mss;
if (new_len >= skb->len)
return 0;
}
pkt_len = new_len; pkt_len = new_len;
} }
if (pkt_len >= skb->len && !in_sack)
return 0;
err = tcp_fragment(sk, skb, pkt_len, mss, GFP_ATOMIC); err = tcp_fragment(sk, skb, pkt_len, mss, GFP_ATOMIC);
if (err < 0) if (err < 0)
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment