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 13c2e17..c6619d4 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;
                }