ipv6: fix memory leak with multiple tables during netns destruction
authorSabrina Dubroca <sd@queasysnail.net>
Fri, 8 Sep 2017 08:26:19 +0000 (10:26 +0200)
committerDanny Wood <danwood76@gmail.com>
Tue, 29 Jan 2019 13:18:35 +0000 (13:18 +0000)
commit6177586abb24c168c0d0de33bd7e007ac5eb0c14
tree1529960aadbc898f222cfd4db37300c334dcbb41
parent6234bebb003c5e1fe6fe04d459f38077221fac69
ipv6: fix memory leak with multiple tables during netns destruction

commit ba1cc08d9488c94cb8d94f545305688b72a2a300 upstream.

fib6_net_exit only frees the main and local tables. If another table was
created with fib6_alloc_table, we leak it when the netns is destroyed.

Fix this in the same way ip_fib_net_exit cleans up tables, by walking
through the whole hashtable of fib6_table's. We can get rid of the
special cases for local and main, since they're also part of the
hashtable.

Reproducer:
    ip netns add x
    ip -net x -6 rule add from 6003:1::/64 table 100
    ip netns del x

Reported-by: Jianlin Shi <jishi@redhat.com>
Fixes: 58f09b78b730 ("[NETNS][IPV6] ip6_fib - make it per network namespace")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
net/ipv6/ip6_fib.c