netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aaron Conole <aconole@bytheb.org>
To: netfilter-devel@vger.kernel.org, netdev@vger.kernel.org
Cc: Florian Westphal <fw@strlen.de>, Pablo Neira Ayuso <pablo@netfilter.org>
Subject: [PATCH nf-next v3 1/2] netfilter: Fix potential null pointer dereference
Date: Wed, 28 Sep 2016 09:12:47 -0400	[thread overview]
Message-ID: <1475068368-3109-2-git-send-email-aconole@bytheb.org> (raw)
In-Reply-To: <1475068368-3109-1-git-send-email-aconole@bytheb.org>

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.

Signed-off-by: Aaron Conole <aconole@bytheb.org>
---
 net/netfilter/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index 360c63d..e58e420 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;
-- 
2.7.4


  reply	other threads:[~2016-09-28 13:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-28 13:12 [PATCH nf-next v3 0/2] fixes for recent nf_compact hooks Aaron Conole
2016-09-28 13:12 ` Aaron Conole [this message]
2016-09-28 13:35   ` [PATCH nf-next v3 1/2] netfilter: Fix potential null pointer dereference Eric Dumazet
2016-09-28 14:56     ` Aaron Conole
2016-09-28 15:30       ` Eric Dumazet
2016-09-28 15:38         ` Aaron Conole
2016-09-28 13:12 ` [PATCH nf-next v3 2/2] nf_set_hooks_head: accommodate different kconfig Aaron Conole

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1475068368-3109-2-git-send-email-aconole@bytheb.org \
    --to=aconole@bytheb.org \
    --cc=fw@strlen.de \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).