Commit 7266a6b028384bec87fe23128266f00589580f74

Authored by Pablo Neira Ayuso
Committed by Greg Kroah-Hartman
1 parent 513c668203

netfilter: nfnetlink: validate nfnetlink header from batch

commit 9ea2aa8b7dba9e99544c4187cc298face254569f upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff

net/netfilter/nfnetlink.c
... ... @@ -321,7 +321,8 @@
321 321 nlh = nlmsg_hdr(skb);
322 322 err = 0;
323 323  
324   - if (nlh->nlmsg_len < NLMSG_HDRLEN) {
  324 + if (nlmsg_len(nlh) < sizeof(struct nfgenmsg) ||
  325 + skb->len < nlh->nlmsg_len) {
325 326 err = -EINVAL;
326 327 goto ack;
327 328 }