aboutsummaryrefslogtreecommitdiffstats
path: root/net/netfilter/core.c
diff options
context:
space:
mode:
authorAaron Conole <aconole@bytheb.org>2016-09-28 11:35:14 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2016-09-30 20:15:26 +0200
commit5119e4381a90fabd3442bde02707cbd9e5d7367a (patch)
treefb9d0cb7d6486870a61abde7274baf05111e3d76 /net/netfilter/core.c
parentmlx5: Add ndo_poll_controller() implementation (diff)
downloadlinux-dev-5119e4381a90fabd3442bde02707cbd9e5d7367a.tar.xz
linux-dev-5119e4381a90fabd3442bde02707cbd9e5d7367a.zip
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: e3b37f11e6e4 ("netfilter: replace list_head with single linked list") Signed-off-by: Aaron Conole <aconole@bytheb.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/netfilter/core.c')
-rw-r--r--net/netfilter/core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index fa6715db4581..e3f68a786afe 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -160,7 +160,7 @@ void nf_unregister_net_hook(struct net *net, const struct nf_hook_ops *reg)
mutex_lock(&nf_hook_mutex);
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_entry_dereference(hooks_entry->next));
goto unlock;