netfilter: ebtables: fix erroneous reject of last rule
authorFlorian Westphal <fw@strlen.de>
Thu, 8 Mar 2018 11:54:19 +0000 (12:54 +0100)
committerStricted <info@stricted.net>
Tue, 6 Aug 2019 11:33:35 +0000 (11:33 +0000)
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.

Change-Id: Idaf15f1b3ad0aabdff3e995131a0fdd8bffb1e4a
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>
Signed-off-by: Jan Altensen <info@stricted.net>
net/bridge/netfilter/ebtables.c

index 924af39089eaded40c405a661407b20780563d4d..cf837ff96ae1f8ee02f55b1007bf81a02175a3bf 100644 (file)
@@ -2070,8 +2070,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])