netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 4/6] netfilter: nfnetlink: validate nfnetlink header from batch
Date: Sat, 10 Jan 2015 19:50:06 +0100	[thread overview]
Message-ID: <1420915808-7160-5-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1420915808-7160-1-git-send-email-pablo@netfilter.org>

Make sure there is enough room for the nfnetlink header in the
netlink messages that are part of the batch. There is a similar
check in netlink_rcv_skb().

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nfnetlink.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 13c2e17..c6619d4 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -321,7 +321,8 @@ replay:
 		nlh = nlmsg_hdr(skb);
 		err = 0;
 
-		if (nlh->nlmsg_len < NLMSG_HDRLEN) {
+		if (nlmsg_len(nlh) < sizeof(struct nfgenmsg) ||
+		    skb->len < nlh->nlmsg_len) {
 			err = -EINVAL;
 			goto ack;
 		}
-- 
1.7.10.4

  parent reply	other threads:[~2015-01-10 18:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-10 18:50 [PATCH 0/6] netfilter/ipvs fixes for net Pablo Neira Ayuso
2015-01-10 18:50 ` [PATCH 1/6] ipvs: uninitialized data with IP_VS_IPV6 Pablo Neira Ayuso
2015-01-10 18:50 ` [PATCH 2/6] netfilter: nf_tables: fix port natting in little endian archs Pablo Neira Ayuso
2015-01-10 18:50 ` [PATCH 3/6] netfilter: conntrack: fix race between confirmation and flush Pablo Neira Ayuso
2015-01-10 18:50 ` Pablo Neira Ayuso [this message]
2015-01-10 18:50 ` [PATCH 5/6] netfilter: nfnetlink: relax strict multicast group check from netlink_bind Pablo Neira Ayuso
2015-01-10 18:50 ` [PATCH 6/6] netfilter: nf_tables: fix flush ruleset chain dependencies Pablo Neira Ayuso
2015-01-12  5:15 ` [PATCH 0/6] netfilter/ipvs fixes for net David Miller

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=1420915808-7160-5-git-send-email-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.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).