netfilter: ebtables: fix erroneous reject of last rule
authorFlorian Westphal <fw@strlen.de>
Thu, 8 Mar 2018 11:54:19 +0000 (12:54 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sun, 11 Mar 2018 20:24:00 +0000 (21:24 +0100)
The last rule in the blob has next_entry offset that is same as total size.
This made "ebtables32 -A OUTPUT -d de:ad:be:ef:01:02" fail on 64 bit kernel.

Fixes: b71812168571fa ("netfilter: ebtables: CONFIG_COMPAT: don't trust userland offsets")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/bridge/netfilter/ebtables.c

index 254ef9f4956790655652d92bd0b91b1a81f184d4..a94d23b0a9af30babff7469c09e9acbf51c1c260 100644 (file)
@@ -2119,8 +2119,12 @@ static int size_entry_mwt(struct ebt_entry *entry, const unsigned char *base,
         * offsets are relative to beginning of struct ebt_entry (i.e., 0).
         */
        for (i = 0; i < 4 ; ++i) {
-               if (offsets[i] >= *total)
+               if (offsets[i] > *total)
                        return -EINVAL;
+
+               if (i < 3 && offsets[i] == *total)
+                       return -EINVAL;
+
                if (i == 0)
                        continue;
                if (offsets[i-1] > offsets[i])