Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf218ff9 authored by Eric Dumazet's avatar Eric Dumazet Committed by Greg Kroah-Hartman
Browse files

tcp: fix over estimation in sk_forced_mem_schedule()



commit c4ee118561a0f74442439b7b5b486db1ac1ddfeb upstream.

sk_forced_mem_schedule() has a bug similar to ones fixed
in commit 7c80b038d23e ("net: fix sk_wmem_schedule() and
sk_rmem_schedule() errors")

While this bug has little chance to trigger in old kernels,
we need to fix it before the following patch.

Fixes: d83769a5 ("tcp: fix possible deadlock in tcp_send_fin()")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Acked-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
Reviewed-by: default avatarShakeel Butt <shakeelb@google.com>
Reviewed-by: default avatarWei Wang <weiwan@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8cdba919
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -3143,11 +3143,12 @@ void tcp_xmit_retransmit_queue(struct sock *sk)
 */
void sk_forced_mem_schedule(struct sock *sk, int size)
{
	int amt;
	int delta, amt;

	if (size <= sk->sk_forward_alloc)
	delta = size - sk->sk_forward_alloc;
	if (delta <= 0)
		return;
	amt = sk_mem_pages(size);
	amt = sk_mem_pages(delta);
	sk->sk_forward_alloc += amt * SK_MEM_QUANTUM;
	sk_memory_allocated_add(sk, amt);