summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Wellving <andreas.wellving@enea.com>2018-10-12 09:38:58 +0200
committerAdrian Dudau <Adrian.Dudau@enea.com>2018-10-16 17:33:36 +0200
commit8fcc60e5208dbcf4a2ed3ad04cb0397869befb3b (patch)
tree8f57dda0459386f736273efb612bc6f575da1926
parentc8dd6dd3ce75f747da54776c6168372a5cec9a68 (diff)
downloadenea-kernel-cache-8fcc60e5208dbcf4a2ed3ad04cb0397869befb3b.tar.gz
netfilter: CVE-2018-1068
netfilter: ebtables: CONFIG_COMPAT: don't trust userland offsets References: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b71812168571fa55e44cdd0254471331b9c4c4c6 Change-Id: I4b658659993380dc9a3aeee4620061ac0e9d5a63 Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
-rw-r--r--patches/cve/4.9.x.scc1
-rw-r--r--patches/cve/CVE-2018-1068-netfilter-ebtables-CONFIG_COMPAT-don-t-trust-userlan.patch62
2 files changed, 63 insertions, 0 deletions
diff --git a/patches/cve/4.9.x.scc b/patches/cve/4.9.x.scc
index fd6f5c7..51591c7 100644
--- a/patches/cve/4.9.x.scc
+++ b/patches/cve/4.9.x.scc
@@ -4,3 +4,4 @@ patch CVE-2017-8824-dccp-CVE-2017-8824-use-after-free-in-DCCP-code.patch
4 4
5#CVEs fixed in 4.9.88: 5#CVEs fixed in 4.9.88:
6patch CVE-2018-1065-netfilter-add-back-stackpointer-size-checks.patch 6patch CVE-2018-1065-netfilter-add-back-stackpointer-size-checks.patch
7patch CVE-2018-1068-netfilter-ebtables-CONFIG_COMPAT-don-t-trust-userlan.patch
diff --git a/patches/cve/CVE-2018-1068-netfilter-ebtables-CONFIG_COMPAT-don-t-trust-userlan.patch b/patches/cve/CVE-2018-1068-netfilter-ebtables-CONFIG_COMPAT-don-t-trust-userlan.patch
new file mode 100644
index 0000000..7723764
--- /dev/null
+++ b/patches/cve/CVE-2018-1068-netfilter-ebtables-CONFIG_COMPAT-don-t-trust-userlan.patch
@@ -0,0 +1,62 @@
1From b71812168571fa55e44cdd0254471331b9c4c4c6 Mon Sep 17 00:00:00 2001
2From: Florian Westphal <fw@strlen.de>
3Date: Mon, 19 Feb 2018 01:24:15 +0100
4Subject: [PATCH] netfilter: ebtables: CONFIG_COMPAT: don't trust userland
5 offsets
6
7We need to make sure the offsets are not out of range of the
8total size.
9Also check that they are in ascending order.
10
11The WARN_ON triggered by syzkaller (it sets panic_on_warn) is
12changed to also bail out, no point in continuing parsing.
13
14Briefly tested with simple ruleset of
15-A INPUT --limit 1/s' --log
16plus jump to custom chains using 32bit ebtables binary.
17
18CVE: CVE-2018-1068
19Upstream-Status: Backport
20
21Reported-by: <syzbot+845a53d13171abf8bf29@syzkaller.appspotmail.com>
22Signed-off-by: Florian Westphal <fw@strlen.de>
23Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
24Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
25---
26 net/bridge/netfilter/ebtables.c | 13 ++++++++++++-
27 1 file changed, 12 insertions(+), 1 deletion(-)
28
29diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
30index 61f8787..254ef9f 100644
31--- a/net/bridge/netfilter/ebtables.c
32+++ b/net/bridge/netfilter/ebtables.c
33@@ -2060,7 +2060,9 @@ static int ebt_size_mwt(struct compat_ebt_entry_mwt *match32,
34 if (match_kern)
35 match_kern->match_size = ret;
36
37- WARN_ON(type == EBT_COMPAT_TARGET && size_left);
38+ if (WARN_ON(type == EBT_COMPAT_TARGET && size_left))
39+ return -EINVAL;
40+
41 match32 = (struct compat_ebt_entry_mwt *) buf;
42 }
43
44@@ -2116,6 +2118,15 @@ static int size_entry_mwt(struct ebt_entry *entry, const unsigned char *base,
45 *
46 * offsets are relative to beginning of struct ebt_entry (i.e., 0).
47 */
48+ for (i = 0; i < 4 ; ++i) {
49+ if (offsets[i] >= *total)
50+ return -EINVAL;
51+ if (i == 0)
52+ continue;
53+ if (offsets[i-1] > offsets[i])
54+ return -EINVAL;
55+ }
56+
57 for (i = 0, j = 1 ; j < 4 ; j++, i++) {
58 struct compat_ebt_entry_mwt *match32;
59 unsigned int size;
60--
61
62