OSDN Git Service

tcp: avoid collapses in tcp_prune_queue() if possible
authorEric Dumazet <edumazet@google.com>
Fri, 27 Jul 2018 10:08:54 +0000 (12:08 +0200)
committerGreg Kroah-Hartman <gregkh@google.com>
Fri, 27 Jul 2018 10:42:44 +0000 (12:42 +0200)
commit0137be2a2eab38381b5760c760139427ecd649b3
tree41ccdfea45ccfe990f12a923271433b7701311ba
parent56b516c5e343439b0a33c797de1bed012d679fe0
tcp: avoid collapses in tcp_prune_queue() if possible

[ Upstream commit f4a3313d8e2ca9fd8d8f45e40a2903ba782607e7 ]

Right after a TCP flow is created, receiving tiny out of order
packets allways hit the condition :

if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf)
tcp_clamp_window(sk);

tcp_clamp_window() increases sk_rcvbuf to match sk_rmem_alloc
(guarded by tcp_rmem[2])

Calling tcp_collapse_ofo_queue() in this case is not useful,
and offers a O(N^2) surface attack to malicious peers.

Better not attempt anything before full queue capacity is reached,
forcing attacker to spend lots of resource and allow us to more
easily detect the abuse.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
Acked-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
net/ipv4/tcp_input.c