Skip to content

Commit 613d077

Browse files
vaverinummakynes
authored andcommitted
netfilter: exit_net cleanup check added
Be sure that lists initialized in net_init hook was return to initial state. Signed-off-by: Vasily Averin <vvs@virtuozzo.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 07dc8bc commit 613d077

5 files changed

Lines changed: 27 additions & 0 deletions

File tree

‎net/ipv4/netfilter/ipt_CLUSTERIP.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,7 @@ static void clusterip_net_exit(struct net *net)
819819
cn->procdir = NULL;
820820
#endif
821821
nf_unregister_net_hook(net, &cip_arp_ops);
822+
WARN_ON_ONCE(!list_empty(&cn->configs));
822823
}
823824

824825
static struct pernet_operations clusterip_net_ops = {

‎net/netfilter/nf_tables_api.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5847,6 +5847,12 @@ static int __net_init nf_tables_init_net(struct net *net)
58475847
return 0;
58485848
}
58495849

5850+
static void __net_exit nf_tables_exit_net(struct net *net)
5851+
{
5852+
WARN_ON_ONCE(!list_empty(&net->nft.af_info));
5853+
WARN_ON_ONCE(!list_empty(&net->nft.commit_list));
5854+
}
5855+
58505856
int __nft_release_basechain(struct nft_ctx *ctx)
58515857
{
58525858
struct nft_rule *rule, *nr;
@@ -5917,6 +5923,7 @@ static void __nft_release_afinfo(struct net *net, struct nft_af_info *afi)
59175923

59185924
static struct pernet_operations nf_tables_net_ops = {
59195925
.init = nf_tables_init_net,
5926+
.exit = nf_tables_exit_net,
59205927
};
59215928

59225929
static int __init nf_tables_module_init(void)

‎net/netfilter/nfnetlink_log.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,10 +1093,15 @@ static int __net_init nfnl_log_net_init(struct net *net)
10931093

10941094
static void __net_exit nfnl_log_net_exit(struct net *net)
10951095
{
1096+
struct nfnl_log_net *log = nfnl_log_pernet(net);
1097+
unsigned int i;
1098+
10961099
#ifdef CONFIG_PROC_FS
10971100
remove_proc_entry("nfnetlink_log", net->nf.proc_netfilter);
10981101
#endif
10991102
nf_log_unset(net, &nfulnl_logger);
1103+
for (i = 0; i < INSTANCE_BUCKETS; i++)
1104+
WARN_ON_ONCE(!hlist_empty(&log->instance_table[i]));
11001105
}
11011106

11021107
static struct pernet_operations nfnl_log_net_ops = {

‎net/netfilter/nfnetlink_queue.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,10 +1512,15 @@ static int __net_init nfnl_queue_net_init(struct net *net)
15121512

15131513
static void __net_exit nfnl_queue_net_exit(struct net *net)
15141514
{
1515+
struct nfnl_queue_net *q = nfnl_queue_pernet(net);
1516+
unsigned int i;
1517+
15151518
nf_unregister_queue_handler(net);
15161519
#ifdef CONFIG_PROC_FS
15171520
remove_proc_entry("nfnetlink_queue", net->nf.proc_netfilter);
15181521
#endif
1522+
for (i = 0; i < INSTANCE_BUCKETS; i++)
1523+
WARN_ON_ONCE(!hlist_empty(&q->instance_table[i]));
15191524
}
15201525

15211526
static void nfnl_queue_net_exit_batch(struct list_head *net_exit_list)

‎net/netfilter/x_tables.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,8 +1729,17 @@ static int __net_init xt_net_init(struct net *net)
17291729
return 0;
17301730
}
17311731

1732+
static void __net_exit xt_net_exit(struct net *net)
1733+
{
1734+
int i;
1735+
1736+
for (i = 0; i < NFPROTO_NUMPROTO; i++)
1737+
WARN_ON_ONCE(!list_empty(&net->xt.tables[i]));
1738+
}
1739+
17321740
static struct pernet_operations xt_net_ops = {
17331741
.init = xt_net_init,
1742+
.exit = xt_net_exit,
17341743
};
17351744

17361745
static int __init xt_init(void)

0 commit comments

Comments
 (0)