]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
tcp: zero ca_priv area when switching cc algorithms
authorFlorian Westphal <fw@strlen.de>
Mon, 21 Nov 2016 09:08:37 +0000 (10:08 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 21 Nov 2016 18:13:56 +0000 (13:13 -0500)
We need to zero out the private data area when application switches
connection to different algorithm (TCP_CONGESTION setsockopt).

When congestion ops get assigned at connect time everything is already
zeroed because sk_alloc uses GFP_ZERO flag.  But in the setsockopt case
this contains whatever previous cc placed there.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp_cong.c

index 1294af4e0127b7a9b98d6e9cfa9e3979c7d7086e..f9038d6b109eb41b2d8a3898a2c7ff6519f2c49b 100644 (file)
@@ -200,8 +200,10 @@ static void tcp_reinit_congestion_control(struct sock *sk,
        icsk->icsk_ca_ops = ca;
        icsk->icsk_ca_setsockopt = 1;
 
-       if (sk->sk_state != TCP_CLOSE)
+       if (sk->sk_state != TCP_CLOSE) {
+               memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv));
                tcp_init_congestion_control(sk);
+       }
 }
 
 /* Manage refcounts on socket close. */