Skip to content

Commit 52bed09

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: 27774015 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 660579f commit 52bed09

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
@@ -2012,7 +2012,9 @@ static int ebt_size_mwt(struct compat_ebt_entry_mwt *match32,
20122012
if (match_kern)
20132013
match_kern->match_size = ret;
20142014

2015-
WARN_ON(type == EBT_COMPAT_TARGET && size_left);
2015+
if (WARN_ON(type == EBT_COMPAT_TARGET && size_left))
2016+
return -EINVAL;
2017+
20162018
match32 = (struct compat_ebt_entry_mwt *) buf;
20172019
}
20182020

@@ -2069,6 +2071,15 @@ static int size_entry_mwt(struct ebt_entry *entry, const unsigned char *base,
20692071
*
20702072
* offsets are relative to beginning of struct ebt_entry (i.e., 0).
20712073
*/
2074+
for (i = 0; i < 4 ; ++i) {
2075+
if (offsets[i] >= *total)
2076+
return -EINVAL;
2077+
if (i == 0)
2078+
continue;
2079+
if (offsets[i-1] > offsets[i])
2080+
return -EINVAL;
2081+
}
2082+
20722083
for (i = 0, j = 1 ; j < 4 ; j++, i++) {
20732084
struct compat_ebt_entry_mwt *match32;
20742085
unsigned int size;

0 commit comments

Comments
 (0)