]> git.proxmox.com Git - pve-kernel.git/blame - CVE-2017-9242-ipv6-fix-out-of-bound-writes-in-__ip6_append_data.patch
update abi-previous after ABI bump
[pve-kernel.git] / CVE-2017-9242-ipv6-fix-out-of-bound-writes-in-__ip6_append_data.patch
CommitLineData
0f831b3c
FG
1From 2bb2c56a2089211713a7b1fb379cce741f65ea9e Mon Sep 17 00:00:00 2001
2From: Eric Dumazet <edumazet@google.com>
3Date: Fri, 19 May 2017 14:17:48 -0700
4Subject: [PATCH] ipv6: fix out of bound writes in __ip6_append_data()
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Andrey Konovalov and idaifish@gmail.com reported crashes caused by
10one skb shared_info being overwritten from __ip6_append_data()
11
12Andrey program lead to following state :
13
14copy -4200 datalen 2000 fraglen 2040
15maxfraglen 2040 alloclen 2048 transhdrlen 0 offset 0 fraggap 6200
16
17The skb_copy_and_csum_bits(skb_prev, maxfraglen, data + transhdrlen,
18fraggap, 0); is overwriting skb->head and skb_shared_info
19
20Since we apparently detect this rare condition too late, move the
21code earlier to even avoid allocating skb and risking crashes.
22
23Once again, many thanks to Andrey and syzkaller team.
24
25Signed-off-by: Eric Dumazet <edumazet@google.com>
26Reported-by: Andrey Konovalov <andreyknvl@google.com>
27Tested-by: Andrey Konovalov <andreyknvl@google.com>
28Reported-by: <idaifish@gmail.com>
29Signed-off-by: David S. Miller <davem@davemloft.net>
30
31CVE-2017-9242
32
33(cherry-picked from 232cd35d0804cc241eb887bb8d4d9b3b9881c64a)
34Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
35Acked-by: Colin King <colin.king@canonical.com>
36Acked-by: Andy Whitcroft <andy.whitcroft@canonical.com>
37Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
38
39Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
40---
41 net/ipv6/ip6_output.c | 15 ++++++++-------
42 1 file changed, 8 insertions(+), 7 deletions(-)
43
44diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
45index 8f0814d301aa..135ee573eaef 100644
46--- a/net/ipv6/ip6_output.c
47+++ b/net/ipv6/ip6_output.c
48@@ -1463,6 +1463,11 @@ static int __ip6_append_data(struct sock *sk,
49 */
50 alloclen += sizeof(struct frag_hdr);
51
52+ copy = datalen - transhdrlen - fraggap;
53+ if (copy < 0) {
54+ err = -EINVAL;
55+ goto error;
56+ }
57 if (transhdrlen) {
58 skb = sock_alloc_send_skb(sk,
59 alloclen + hh_len,
60@@ -1512,13 +1517,9 @@ static int __ip6_append_data(struct sock *sk,
61 data += fraggap;
62 pskb_trim_unique(skb_prev, maxfraglen);
63 }
64- copy = datalen - transhdrlen - fraggap;
65-
66- if (copy < 0) {
67- err = -EINVAL;
68- kfree_skb(skb);
69- goto error;
70- } else if (copy > 0 && getfrag(from, data + transhdrlen, offset, copy, fraggap, skb) < 0) {
71+ if (copy > 0 &&
72+ getfrag(from, data + transhdrlen, offset,
73+ copy, fraggap, skb) < 0) {
74 err = -EFAULT;
75 kfree_skb(skb);
76 goto error;
77--
782.11.0
79