Skip to content

Commit 16ef4da

Browse files
Florian WestphalBrian Maly
authored andcommitted
netfilter: ebtables: CONFIG_COMPAT: don't trust userland offsets
We need to make sure the offsets are not out of range of the total size. Also check that they are in ascending order. The WARN_ON triggered by syzkaller (it sets panic_on_warn) is changed to also bail out, no point in continuing parsing. Briefly tested with simple ruleset of -A INPUT --limit 1/s' --log plus jump to custom chains using 32bit ebtables binary. Reported-by: <[email protected]> Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]> (cherry picked from commit b718121) Orabug: 27774010 CVE: CVE-2018-1068 Signed-off-by: Tim Tianyang Chen <[email protected]> Reviewed-by: Chuck Anderson <[email protected]> Signed-off-by: Brian Maly <[email protected]>
1 parent 36e7527 commit 16ef4da

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

net/bridge/netfilter/ebtables.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2007,7 +2007,9 @@ static int ebt_size_mwt(struct compat_ebt_entry_mwt *match32,
20072007
if (match_kern)
20082008
match_kern->match_size = ret;
20092009

2010-
WARN_ON(type == EBT_COMPAT_TARGET && size_left);
2010+
if (WARN_ON(type == EBT_COMPAT_TARGET && size_left))
2011+
return -EINVAL;
2012+
20112013
match32 = (struct compat_ebt_entry_mwt *) buf;
20122014
}
20132015

@@ -2064,6 +2066,15 @@ static int size_entry_mwt(struct ebt_entry *entry, const unsigned char *base,
20642066
*
20652067
* offsets are relative to beginning of struct ebt_entry (i.e., 0).
20662068
*/
2069+
for (i = 0; i < 4 ; ++i) {
2070+
if (offsets[i] >= *total)
2071+
return -EINVAL;
2072+
if (i == 0)
2073+
continue;
2074+
if (offsets[i-1] > offsets[i])
2075+
return -EINVAL;
2076+
}
2077+
20672078
for (i = 0, j = 1 ; j < 4 ; j++, i++) {
20682079
struct compat_ebt_entry_mwt *match32;
20692080
unsigned int size;

0 commit comments

Comments
 (0)