netfilter: ebtables: fix erroneous reject of last rule

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: I9e6cb77554a6f782e120059e25364ae9e80ebf7f
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: Kevin F. Haggerty <haggertk@lineageos.org>
This commit is contained in:
Florian Westphal 2018-03-08 12:54:19 +01:00 committed by Francescodario Cuzzocrea
parent dd8e1fcf8a
commit bfbeec226e
1 changed files with 5 additions and 1 deletions

View File

@ -2068,8 +2068,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])