Patchwork [17/18] netfilter: nfnetlink: check callbacks before using those in nfnetlink_rcv_msg

login
register
mail settings
Submitter Pablo Neira
Date July 6, 2012, 11:17 a.m.
Message ID <1341573428-3204-18-git-send-email-pablo@netfilter.org>
Download mbox | patch
Permalink /patch/169425/
State Accepted
Headers show

Comments

Pablo Neira - July 6, 2012, 11:17 a.m.
From: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>

nfnetlink_rcv_msg() might call a NULL callback which will cause NULL pointer
dereference.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nfnetlink.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch

diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 3e797d1..4acdd76 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -184,9 +184,11 @@  replay:
 					lockdep_is_held(&nfnl_mutex)) != ss ||
 			    nfnetlink_find_client(type, ss) != nc)
 				err = -EAGAIN;
-			else
+			else if (nc->call)
 				err = nc->call(net->nfnl, skb, nlh,
 						   (const struct nlattr **)cda);
+			else
+				err = -EINVAL;
 			nfnl_unlock();
 		}
 		if (err == -EAGAIN)