summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Wellving <andreas.wellving@enea.com>2018-10-17 15:33:02 +0200
committerAndreas Wellving <andreas.wellving@enea.com>2018-10-25 13:26:24 +0200
commit10f6ab5aea81a94af751bbdbebbf49303d83879f (patch)
tree68ff29ff9f73f612e3b9fca5b3d2e4c8b3fac204
parent5c82e974204fec2340cd7d24a54a15118fe0f4f9 (diff)
downloadenea-kernel-cache-10f6ab5aea81a94af751bbdbebbf49303d83879f.tar.gz
net: CVE-2017-17712
net: ipv4: fix for a race condition in raw_sendmsg References: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.1.y&id=d61b40939ebdc84dad77dbc78c3e26ad9d2da68b Change-Id: I19651e5496e4eca18e96b6bd7a9d2b542e30ac91 Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
-rw-r--r--patches/cve/4.1.x.scc2
-rw-r--r--patches/cve/CVE-2017-17712-net-ipv4-fix-for-a-race-condition-in-raw_sendmsg.patch80
2 files changed, 82 insertions, 0 deletions
diff --git a/patches/cve/4.1.x.scc b/patches/cve/4.1.x.scc
index f0ed6a8..097fea5 100644
--- a/patches/cve/4.1.x.scc
+++ b/patches/cve/4.1.x.scc
@@ -38,3 +38,5 @@ patch CVE-2016-9793-net-avoid-signed-overflows-for-SO_-SND-RCV-BUFFORCE.patch
38#fixed in 4.1.51 38#fixed in 4.1.51
39patch CVE-2018-1068-netfilter-ebtables-CONFIG_COMPAT-don-t-trust-userlan.patch 39patch CVE-2018-1068-netfilter-ebtables-CONFIG_COMPAT-don-t-trust-userlan.patch
40 40
41#fixed in 4.1.52
42patch CVE-2017-17712-net-ipv4-fix-for-a-race-condition-in-raw_sendmsg.patch
diff --git a/patches/cve/CVE-2017-17712-net-ipv4-fix-for-a-race-condition-in-raw_sendmsg.patch b/patches/cve/CVE-2017-17712-net-ipv4-fix-for-a-race-condition-in-raw_sendmsg.patch
new file mode 100644
index 0000000..fa13430
--- /dev/null
+++ b/patches/cve/CVE-2017-17712-net-ipv4-fix-for-a-race-condition-in-raw_sendmsg.patch
@@ -0,0 +1,80 @@
1From d61b40939ebdc84dad77dbc78c3e26ad9d2da68b Mon Sep 17 00:00:00 2001
2From: Mohamed Ghannam <simo.ghannam@gmail.com>
3Date: Sun, 10 Dec 2017 03:50:58 +0000
4Subject: [PATCH] net: ipv4: fix for a race condition in raw_sendmsg
5
6[ Upstream commit 8f659a03a0ba9289b9aeb9b4470e6fb263d6f483 ]
7
8inet->hdrincl is racy, and could lead to uninitialized stack pointer
9usage, so its value should be read only once.
10
11Fixes: c008ba5bdc9f ("ipv4: Avoid reading user iov twice after raw_probe_proto_opt")
12
13CVE: CVE-2017-17712
14Upstream-Status: Backport
15
16Signed-off-by: Mohamed Ghannam <simo.ghannam@gmail.com>
17Reviewed-by: Eric Dumazet <edumazet@google.com>
18Signed-off-by: David S. Miller <davem@davemloft.net>
19Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
20Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
21---
22 net/ipv4/raw.c | 15 ++++++++++-----
23 1 file changed, 10 insertions(+), 5 deletions(-)
24
25diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
26index 9a2294d..acf09ab 100644
27--- a/net/ipv4/raw.c
28+++ b/net/ipv4/raw.c
29@@ -496,11 +496,16 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
30 int err;
31 struct ip_options_data opt_copy;
32 struct raw_frag_vec rfv;
33+ int hdrincl;
34
35 err = -EMSGSIZE;
36 if (len > 0xFFFF)
37 goto out;
38
39+ /* hdrincl should be READ_ONCE(inet->hdrincl)
40+ * but READ_ONCE() doesn't work with bit fields
41+ */
42+ hdrincl = inet->hdrincl;
43 /*
44 * Check the flags.
45 */
46@@ -575,7 +580,7 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
47 /* Linux does not mangle headers on raw sockets,
48 * so that IP options + IP_HDRINCL is non-sense.
49 */
50- if (inet->hdrincl)
51+ if (hdrincl)
52 goto done;
53 if (ipc.opt->opt.srr) {
54 if (!daddr)
55@@ -597,12 +602,12 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
56
57 flowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos,
58 RT_SCOPE_UNIVERSE,
59- inet->hdrincl ? IPPROTO_RAW : sk->sk_protocol,
60+ hdrincl ? IPPROTO_RAW : sk->sk_protocol,
61 inet_sk_flowi_flags(sk) |
62- (inet->hdrincl ? FLOWI_FLAG_KNOWN_NH : 0),
63+ (hdrincl ? FLOWI_FLAG_KNOWN_NH : 0),
64 daddr, saddr, 0, 0);
65
66- if (!inet->hdrincl) {
67+ if (!hdrincl) {
68 rfv.msg = msg;
69 rfv.hlen = 0;
70
71@@ -627,7 +632,7 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
72 goto do_confirm;
73 back_from_confirm:
74
75- if (inet->hdrincl)
76+ if (hdrincl)
77 err = raw_send_hdrinc(sk, &fl4, msg, len,
78 &rt, msg->msg_flags);
79
80--