提交 5119e438 编写于 作者: A Aaron Conole 提交者: Pablo Neira Ayuso

netfilter: Fix potential null pointer dereference

It's possible for nf_hook_entry_head to return NULL.  If two
nf_unregister_net_hook calls happen simultaneously with a single hook
entry in the list, both will enter the nf_hook_mutex critical section.
The first will successfully delete the head, but the second will see
this NULL pointer and attempt to dereference.

This fix ensures that no null pointer dereference could occur when such
a condition happens.

Fixes: e3b37f11 ("netfilter: replace list_head with single linked list")
Signed-off-by: NAaron Conole <aconole@bytheb.org>
Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
上级 80378384
...@@ -160,7 +160,7 @@ void nf_unregister_net_hook(struct net *net, const struct nf_hook_ops *reg) ...@@ -160,7 +160,7 @@ void nf_unregister_net_hook(struct net *net, const struct nf_hook_ops *reg)
mutex_lock(&nf_hook_mutex); mutex_lock(&nf_hook_mutex);
hooks_entry = nf_hook_entry_head(net, reg); hooks_entry = nf_hook_entry_head(net, reg);
if (hooks_entry->orig_ops == reg) { if (hooks_entry && hooks_entry->orig_ops == reg) {
nf_set_hooks_head(net, reg, nf_set_hooks_head(net, reg,
nf_entry_dereference(hooks_entry->next)); nf_entry_dereference(hooks_entry->next));
goto unlock; goto unlock;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册