Commit 1e47ee8367babe6a5e8adf44a714c7086657b87e
1 parent
4610476d89
netfilter: nf_conntrack: fix BUG_ON while removing nf_conntrack with netns
canqun zhang reported that we're hitting BUG_ON in the nf_conntrack_destroy path when calling kfree_skb while rmmod'ing the nf_conntrack module. Currently, the nf_ct_destroy hook is being set to NULL in the destroy path of conntrack.init_net. However, this is a problem since init_net may be destroyed before any other existing netns (we cannot assume any specific ordering while releasing existing netns according to what I read in recent emails). Thanks to Gao feng for initial patch to address this issue. Reported-by: canqun zhang <canqunzhang@gmail.com> Acked-by: Gao feng <gaofeng@cn.fujitsu.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Showing 3 changed files with 8 additions and 4 deletions Side-by-side Diff
include/net/netfilter/nf_conntrack_core.h
net/netfilter/nf_conntrack_core.c
... | ... | @@ -1376,11 +1376,12 @@ |
1376 | 1376 | synchronize_net(); |
1377 | 1377 | nf_conntrack_proto_fini(net); |
1378 | 1378 | nf_conntrack_cleanup_net(net); |
1379 | +} | |
1379 | 1380 | |
1380 | - if (net_eq(net, &init_net)) { | |
1381 | - RCU_INIT_POINTER(nf_ct_destroy, NULL); | |
1382 | - nf_conntrack_cleanup_init_net(); | |
1383 | - } | |
1381 | +void nf_conntrack_cleanup_end(void) | |
1382 | +{ | |
1383 | + RCU_INIT_POINTER(nf_ct_destroy, NULL); | |
1384 | + nf_conntrack_cleanup_init_net(); | |
1384 | 1385 | } |
1385 | 1386 | |
1386 | 1387 | void *nf_ct_alloc_hashtable(unsigned int *sizep, int nulls) |
net/netfilter/nf_conntrack_standalone.c