netfilter: x_tables: assert minimum target size
authorFlorian Westphal <fw@strlen.de>
Fri, 1 Apr 2016 12:17:25 +0000 (14:17 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 Jun 2016 17:18:23 +0000 (10:18 -0700)
commit a08e4e190b866579896c09af59b3bdca821da2cd upstream.

The target size includes the size of the xt_entry_target struct.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/netfilter/x_tables.c

index 24a9dfb51df23ea2369096ade7d216a1bf046e26..e3e2dd4c55bf524234af9a32b13e1e1cae44dc3b 100644 (file)
@@ -567,6 +567,9 @@ int xt_check_entry_offsets(const void *base,
                return -EINVAL;
 
        t = (void *)(e + target_offset);
+       if (t->u.target_size < sizeof(*t))
+               return -EINVAL;
+
        if (target_offset + t->u.target_size > next_offset)
                return -EINVAL;