Skip to content

Commit ad9852a

Browse files
gfreewindummakynes
authored andcommitted
netfilter: nf_ct_helper: Fix possible panic after nf_conntrack_helper_unregister
The helper module would be unloaded after nf_conntrack_helper_unregister, so it may cause a possible panic caused by race. nf_ct_iterate_destroy(unhelp, me) reset the helper of conntrack as NULL, but maybe someone has gotten the helper pointer during this period. Then it would panic, when it accesses the helper and the module was unloaded. Take an example as following: CPU0 CPU1 ctnetlink_dump_helpinfo helper = rcu_dereference(help->helper); unhelp set helper as NULL unload helper module helper->to_nlattr(skb, ct); As above, the cpu0 tries to access the helper and its module is unloaded, then the panic happens. Signed-off-by: Gao Feng <gfree.wind@vip.163.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 9ce7bc0 commit ad9852a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

net/netfilter/nf_conntrack_helper.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,11 @@ void nf_conntrack_helper_unregister(struct nf_conntrack_helper *me)
465465

466466
nf_ct_expect_iterate_destroy(expect_iter_me, NULL);
467467
nf_ct_iterate_destroy(unhelp, me);
468+
469+
/* Maybe someone has gotten the helper already when unhelp above.
470+
* So need to wait it.
471+
*/
472+
synchronize_rcu();
468473
}
469474
EXPORT_SYMBOL_GPL(nf_conntrack_helper_unregister);
470475

0 commit comments

Comments
 (0)