Message ID | 20221011220748.3801134-1-eric.dumazet@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 72e560cb8c6f80fc2b4afc5d3634a32465e13a51 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] tcp: cdg: allow tcp_cdg_release() to be called multiple times | expand |
Hello: This patch was applied to netdev/net.git (master) by David S. Miller <davem@davemloft.net>: On Tue, 11 Oct 2022 15:07:48 -0700 you wrote: > From: Eric Dumazet <edumazet@google.com> > > Apparently, mptcp is able to call tcp_disconnect() on an already > disconnected flow. This is generally fine, unless current congestion > control is CDG, because it might trigger a double-free [1] > > Instead of fixing MPTCP, and future bugs, we can make tcp_disconnect() > more resilient. > > [...] Here is the summary with links: - [net] tcp: cdg: allow tcp_cdg_release() to be called multiple times https://git.kernel.org/netdev/net/c/72e560cb8c6f You are awesome, thank you!
diff --git a/net/ipv4/tcp_cdg.c b/net/ipv4/tcp_cdg.c index ddc7ba0554bddaa5df2fffdb61faba1f3cfbde5c..112f28f9369349a54ac719af3de353577a830cf1 100644 --- a/net/ipv4/tcp_cdg.c +++ b/net/ipv4/tcp_cdg.c @@ -375,6 +375,7 @@ static void tcp_cdg_init(struct sock *sk) struct cdg *ca = inet_csk_ca(sk); struct tcp_sock *tp = tcp_sk(sk); + ca->gradients = NULL; /* We silently fall back to window = 1 if allocation fails. */ if (window > 1) ca->gradients = kcalloc(window, sizeof(ca->gradients[0]), @@ -388,6 +389,7 @@ static void tcp_cdg_release(struct sock *sk) struct cdg *ca = inet_csk_ca(sk); kfree(ca->gradients); + ca->gradients = NULL; } static struct tcp_congestion_ops tcp_cdg __read_mostly = {