Skip to content

Commit a23f89a

Browse files
vaverinummakynes
authored andcommitted
netfilter: conntrack: nf_ct_gre_keymap_flush() removal
nf_ct_gre_keymap_flush() is useless. It is called from nf_conntrack_cleanup_net_list() only and tries to remove nf_ct_gre_keymap entries from pernet gre keymap list. Though: a) at this point the list should already be empty, all its entries were deleted during the conntracks cleanup, because nf_conntrack_cleanup_net_list() executes nf_ct_iterate_cleanup(kill_all) before nf_conntrack_proto_pernet_fini(): nf_conntrack_cleanup_net_list +- nf_ct_iterate_cleanup | nf_ct_put | nf_conntrack_put | nf_conntrack_destroy | destroy_conntrack | destroy_gre_conntrack | nf_ct_gre_keymap_destroy `- nf_conntrack_proto_pernet_fini nf_ct_gre_keymap_flush b) Let's say we find that the keymap list is not empty. This means netns still has a conntrack associated with gre, in which case we should not free its memory, because this will lead to a double free and related crashes. However I doubt it could have gone unnoticed for years, obviously this does not happen in real life. So I think we can remove both nf_ct_gre_keymap_flush() and nf_conntrack_proto_pernet_fini(). Signed-off-by: Vasily Averin <[email protected]> Acked-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 4ca041f commit a23f89a

File tree

4 files changed

+0
-22
lines changed

4 files changed

+0
-22
lines changed

include/net/netfilter/nf_conntrack_core.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ void nf_conntrack_cleanup_net(struct net *net);
3030
void nf_conntrack_cleanup_net_list(struct list_head *net_exit_list);
3131

3232
void nf_conntrack_proto_pernet_init(struct net *net);
33-
void nf_conntrack_proto_pernet_fini(struct net *net);
3433

3534
int nf_conntrack_proto_init(void);
3635
void nf_conntrack_proto_fini(void);

net/netfilter/nf_conntrack_core.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2457,7 +2457,6 @@ void nf_conntrack_cleanup_net_list(struct list_head *net_exit_list)
24572457
}
24582458

24592459
list_for_each_entry(net, net_exit_list, exit_list) {
2460-
nf_conntrack_proto_pernet_fini(net);
24612460
nf_conntrack_ecache_pernet_fini(net);
24622461
nf_conntrack_expect_pernet_fini(net);
24632462
free_percpu(net->ct.stat);

net/netfilter/nf_conntrack_proto.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -697,13 +697,6 @@ void nf_conntrack_proto_pernet_init(struct net *net)
697697
#endif
698698
}
699699

700-
void nf_conntrack_proto_pernet_fini(struct net *net)
701-
{
702-
#ifdef CONFIG_NF_CT_PROTO_GRE
703-
nf_ct_gre_keymap_flush(net);
704-
#endif
705-
}
706-
707700
module_param_call(hashsize, nf_conntrack_set_hashsize, param_get_uint,
708701
&nf_conntrack_htable_size, 0600);
709702

net/netfilter/nf_conntrack_proto_gre.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,6 @@ static inline struct nf_gre_net *gre_pernet(struct net *net)
5555
return &net->ct.nf_ct_proto.gre;
5656
}
5757

58-
void nf_ct_gre_keymap_flush(struct net *net)
59-
{
60-
struct nf_gre_net *net_gre = gre_pernet(net);
61-
struct nf_ct_gre_keymap *km, *tmp;
62-
63-
spin_lock_bh(&keymap_lock);
64-
list_for_each_entry_safe(km, tmp, &net_gre->keymap_list, list) {
65-
list_del_rcu(&km->list);
66-
kfree_rcu(km, rcu);
67-
}
68-
spin_unlock_bh(&keymap_lock);
69-
}
70-
7158
static inline int gre_key_cmpfn(const struct nf_ct_gre_keymap *km,
7259
const struct nf_conntrack_tuple *t)
7360
{

0 commit comments

Comments
 (0)