diff options
author | Andreas Wellving <andreas.wellving@enea.com> | 2018-10-12 09:36:26 +0200 |
---|---|---|
committer | Adrian Dudau <Adrian.Dudau@enea.com> | 2018-10-16 17:00:22 +0200 |
commit | c8dd6dd3ce75f747da54776c6168372a5cec9a68 (patch) | |
tree | 49eecf160f81da7f48593dc69b151b64224a41b7 | |
parent | 95d84ee1a0a2ed3b39cd6a636d4ebcd3e33cd193 (diff) | |
download | enea-kernel-cache-c8dd6dd3ce75f747da54776c6168372a5cec9a68.tar.gz |
netfilter: CVE-2018-1065
netfilter: add back stackpointer size checks
References:
https://github.com/torvalds/linux/commit/57ebd808a97d7c5b1e1afb937c2db22beba3c1f8
Change-Id: I5ee1c9b8036563602332c41163740dbc90a294fd
Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
-rw-r--r-- | patches/cve/4.9.x.scc | 3 | ||||
-rw-r--r-- | patches/cve/CVE-2018-1065-netfilter-add-back-stackpointer-size-checks.patch | 88 |
2 files changed, 91 insertions, 0 deletions
diff --git a/patches/cve/4.9.x.scc b/patches/cve/4.9.x.scc index 96b6bcd..fd6f5c7 100644 --- a/patches/cve/4.9.x.scc +++ b/patches/cve/4.9.x.scc | |||
@@ -1,3 +1,6 @@ | |||
1 | #CVEs fixed in 4.9.82: | 1 | #CVEs fixed in 4.9.82: |
2 | patch CVE-2017-18344-posix-timer-Properly-check-sigevent-sigev_notify.patch | 2 | patch CVE-2017-18344-posix-timer-Properly-check-sigevent-sigev_notify.patch |
3 | patch CVE-2017-8824-dccp-CVE-2017-8824-use-after-free-in-DCCP-code.patch | 3 | patch CVE-2017-8824-dccp-CVE-2017-8824-use-after-free-in-DCCP-code.patch |
4 | |||
5 | #CVEs fixed in 4.9.88: | ||
6 | patch CVE-2018-1065-netfilter-add-back-stackpointer-size-checks.patch | ||
diff --git a/patches/cve/CVE-2018-1065-netfilter-add-back-stackpointer-size-checks.patch b/patches/cve/CVE-2018-1065-netfilter-add-back-stackpointer-size-checks.patch new file mode 100644 index 0000000..5dc21e3 --- /dev/null +++ b/patches/cve/CVE-2018-1065-netfilter-add-back-stackpointer-size-checks.patch | |||
@@ -0,0 +1,88 @@ | |||
1 | From 57ebd808a97d7c5b1e1afb937c2db22beba3c1f8 Mon Sep 17 00:00:00 2001 | ||
2 | From: Florian Westphal <fw@strlen.de> | ||
3 | Date: Wed, 7 Feb 2018 13:46:25 +0100 | ||
4 | Subject: [PATCH] netfilter: add back stackpointer size checks | ||
5 | |||
6 | The rationale for removing the check is only correct for rulesets | ||
7 | generated by ip(6)tables. | ||
8 | |||
9 | In iptables, a jump can only occur to a user-defined chain, i.e. | ||
10 | because we size the stack based on number of user-defined chains we | ||
11 | cannot exceed stack size. | ||
12 | |||
13 | However, the underlying binary format has no such restriction, | ||
14 | and the validation step only ensures that the jump target is a | ||
15 | valid rule start point. | ||
16 | |||
17 | IOW, its possible to build a rule blob that has no user-defined | ||
18 | chains but does contain a jump. | ||
19 | |||
20 | If this happens, no jump stack gets allocated and crash occurs | ||
21 | because no jumpstack was allocated. | ||
22 | |||
23 | CVE: CVE-2018-1065 | ||
24 | Upstream-Status: Backport | ||
25 | |||
26 | Fixes: 7814b6ec6d0d6 ("netfilter: xtables: don't save/restore jumpstack offset") | ||
27 | Reported-by: syzbot+e783f671527912cd9403@syzkaller.appspotmail.com | ||
28 | Signed-off-by: Florian Westphal <fw@strlen.de> | ||
29 | Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> | ||
30 | Signed-off-by: Andreas Wellving <andreas.wellving@enea.com> | ||
31 | --- | ||
32 | net/ipv4/netfilter/arp_tables.c | 4 ++++ | ||
33 | net/ipv4/netfilter/ip_tables.c | 7 ++++++- | ||
34 | net/ipv6/netfilter/ip6_tables.c | 4 ++++ | ||
35 | 3 files changed, 14 insertions(+), 1 deletion(-) | ||
36 | |||
37 | diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c | ||
38 | index 4ffe302..e3e420f 100644 | ||
39 | --- a/net/ipv4/netfilter/arp_tables.c | ||
40 | +++ b/net/ipv4/netfilter/arp_tables.c | ||
41 | @@ -252,6 +252,10 @@ unsigned int arpt_do_table(struct sk_buff *skb, | ||
42 | } | ||
43 | if (table_base + v | ||
44 | != arpt_next_entry(e)) { | ||
45 | + if (unlikely(stackidx >= private->stacksize)) { | ||
46 | + verdict = NF_DROP; | ||
47 | + break; | ||
48 | + } | ||
49 | jumpstack[stackidx++] = e; | ||
50 | } | ||
51 | |||
52 | diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c | ||
53 | index 9a71f31..e38395a 100644 | ||
54 | --- a/net/ipv4/netfilter/ip_tables.c | ||
55 | +++ b/net/ipv4/netfilter/ip_tables.c | ||
56 | @@ -330,8 +330,13 @@ ipt_do_table(struct sk_buff *skb, | ||
57 | continue; | ||
58 | } | ||
59 | if (table_base + v != ipt_next_entry(e) && | ||
60 | - !(e->ip.flags & IPT_F_GOTO)) | ||
61 | + !(e->ip.flags & IPT_F_GOTO)) { | ||
62 | + if (unlikely(stackidx >= private->stacksize)) { | ||
63 | + verdict = NF_DROP; | ||
64 | + break; | ||
65 | + } | ||
66 | jumpstack[stackidx++] = e; | ||
67 | + } | ||
68 | |||
69 | e = get_entry(table_base, v); | ||
70 | continue; | ||
71 | diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c | ||
72 | index af4c917..62358b9 100644 | ||
73 | --- a/net/ipv6/netfilter/ip6_tables.c | ||
74 | +++ b/net/ipv6/netfilter/ip6_tables.c | ||
75 | @@ -352,6 +352,10 @@ ip6t_do_table(struct sk_buff *skb, | ||
76 | } | ||
77 | if (table_base + v != ip6t_next_entry(e) && | ||
78 | !(e->ipv6.flags & IP6T_F_GOTO)) { | ||
79 | + if (unlikely(stackidx >= private->stacksize)) { | ||
80 | + verdict = NF_DROP; | ||
81 | + break; | ||
82 | + } | ||
83 | jumpstack[stackidx++] = e; | ||
84 | } | ||
85 | |||
86 | -- | ||
87 | |||
88 | |||