Skip to contentSkip to conversation

tcp: fix a potential NULL pointer dereference in tcp_sk_exit

PATCH Eric Dumazet 2 participants 2 messages Apr 1, 2019 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 8 lines · dust.li

From: Dust Li <[email protected]>

When tcp_sk_init() failed in inet_ctl_sock_create(), 'net->ipv4.tcp_congestion_control' will be left uninitialized, but tcp_sk_exit() hasn't check for that.

Quoted 4 lines

This patch add checking on 'net->ipv4.tcp_congestion_control' in tcp_sk_exit() to prevent NULL-ptr dereference.

Fixes 6670e1524477 ("tcp: Namespace-ify sysctl_tcp_default_congestion_control")

Thanks.

Quoted 21 lines
---
 net/ipv4/tcp_ipv4.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv4/tcp_ipv4.c +2 -2
index 277d71239d75..2f8039a26b08 100644
@@ -2578,7 +2578,8 @@ static void __net_exit tcp_sk_exit(struct net *net)
 {
        int cpu;
 
-       module_put(net->ipv4.tcp_congestion_control->owner);
+       if (net->ipv4.tcp_congestion_control)
+               module_put(net->ipv4.tcp_congestion_control->owner);
 
        for_each_possible_cpu(cpu)
                inet_ctl_sock_destroy(*per_cpu_ptr(net->ipv4.tcp_sk, cpu));
--

2.14.4.44.g2045bb6

maintainer
#2 lore raw

From: Eric Dumazet <[email protected]>
Date: Mon, 1 Apr 2019 02:23:39 -0700

Quoted 9 lines · dust.li
Quoted 8 lines

From: Dust Li <[email protected]>

When tcp_sk_init() failed in inet_ctl_sock_create(), 'net->ipv4.tcp_congestion_control' will be left uninitialized, but tcp_sk_exit() hasn't check for that.

Quoted 7 lines
Quoted 4 lines

This patch add checking on 'net->ipv4.tcp_congestion_control' in tcp_sk_exit() to prevent NULL-ptr dereference.

Fixes 6670e1524477 ("tcp: Namespace-ify sysctl_tcp_default_congestion_control")

This patch didn't make it to the list for whatever reason, but I applied it and have it queued up for -stable.

Thanks.