Commit 32263dd1 authored by Vitaly E. Lavrov's avatar Vitaly E. Lavrov Committed by Pablo Neira Ayuso

netfilter: xt_hashlimit: fix namespace destroy path

recent_net_exit() is called before recent_mt_destroy() in the
destroy path of network namespaces. Make sure there are no entries
in the parent proc entry xt_recent before removing it.
Signed-off-by: default avatarVitaly E. Lavrov <lve@guap.ru>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 665e205c
...@@ -329,7 +329,10 @@ static void htable_destroy(struct xt_hashlimit_htable *hinfo) ...@@ -329,7 +329,10 @@ static void htable_destroy(struct xt_hashlimit_htable *hinfo)
parent = hashlimit_net->ipt_hashlimit; parent = hashlimit_net->ipt_hashlimit;
else else
parent = hashlimit_net->ip6t_hashlimit; parent = hashlimit_net->ip6t_hashlimit;
if(parent != NULL)
remove_proc_entry(hinfo->pde->name, parent); remove_proc_entry(hinfo->pde->name, parent);
htable_selective_cleanup(hinfo, select_all); htable_selective_cleanup(hinfo, select_all);
vfree(hinfo); vfree(hinfo);
} }
...@@ -873,6 +876,27 @@ static int __net_init hashlimit_proc_net_init(struct net *net) ...@@ -873,6 +876,27 @@ static int __net_init hashlimit_proc_net_init(struct net *net)
static void __net_exit hashlimit_proc_net_exit(struct net *net) static void __net_exit hashlimit_proc_net_exit(struct net *net)
{ {
struct xt_hashlimit_htable *hinfo;
struct hlist_node *pos;
struct proc_dir_entry *pde;
struct hashlimit_net *hashlimit_net = hashlimit_pernet(net);
/* recent_net_exit() is called before recent_mt_destroy(). Make sure
* that the parent xt_recent proc entry is is empty before trying to
* remove it.
*/
mutex_lock(&hashlimit_mutex);
pde = hashlimit_net->ipt_hashlimit;
if (pde == NULL)
pde = hashlimit_net->ip6t_hashlimit;
hlist_for_each_entry(hinfo, pos, &hashlimit_net->htables, node)
remove_proc_entry(hinfo->pde->name, pde);
hashlimit_net->ipt_hashlimit = NULL;
hashlimit_net->ip6t_hashlimit = NULL;
mutex_unlock(&hashlimit_mutex);
proc_net_remove(net, "ipt_hashlimit"); proc_net_remove(net, "ipt_hashlimit");
#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES) #if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
proc_net_remove(net, "ip6t_hashlimit"); proc_net_remove(net, "ip6t_hashlimit");
...@@ -889,9 +913,6 @@ static int __net_init hashlimit_net_init(struct net *net) ...@@ -889,9 +913,6 @@ static int __net_init hashlimit_net_init(struct net *net)
static void __net_exit hashlimit_net_exit(struct net *net) static void __net_exit hashlimit_net_exit(struct net *net)
{ {
struct hashlimit_net *hashlimit_net = hashlimit_pernet(net);
BUG_ON(!hlist_empty(&hashlimit_net->htables));
hashlimit_proc_net_exit(net); hashlimit_proc_net_exit(net);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment