netfilter: nfnetlink: validate nfnetlink header from batch
authorPablo Neira Ayuso <pablo@netfilter.org>
Sun, 4 Jan 2015 14:20:29 +0000 (15:20 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 6 Jan 2015 21:27:46 +0000 (22:27 +0100)
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

index 13c2e17bbe279e6660a0a04fc804a6e1dd0a7707..c6619d4bcc32c7a5d8a3a1034ebfadb3cc7aa85c 100644 (file)
@@ -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;
                }