summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSona Sarmadi <sona.sarmadi@enea.com>2016-08-30 11:52:49 (GMT)
committerMartin Borg <martin.borg@enea.com>2016-08-30 13:58:53 (GMT)
commitbac630923de2f10b62e8f2635f192b7fec8165ba (patch)
tree4c6bc5c8f26ac0dcec3bcf1219bea14c3393b6a4
parent40894e99a839ce0e337bb3a7b83327bd64417d56 (diff)
downloadmeta-enea-bsp-common-bac630923de2f10b62e8f2635f192b7fec8165ba.tar.gz
kernel-net: CVE-2016-5696
tcp: make challenge acks less predictable net/ipv4/tcp_input.c in the Linux kernel before 4.7 does not properly determine the rate of challenge ACK segments, which makes it easier for man-in-the-middle attackers to hijack TCP sessions via a blind in-window attack. References: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-5696 https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ patch/?id=5413f1a526d2d51d7a5768133c90936c017165c6 https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ patch/?id=72c2d3bccaba4a0a4de354f9d2d24eccd05bfccf (This a follow-up to "tcp: make challenge acks less predictable) Signen-off-by: Sona Sarmadi <sona.sarmadi@enea.com> Signed-off-by: Martin Borg <martin.borg@enea.com>
-rw-r--r--recipes-kernel/linux/files/CVE-2016-5696-limiting-of-all-challenge.patch109
-rw-r--r--recipes-kernel/linux/files/CVE-2016-5696-make-challenge-acks-less-predictable.patch88
-rw-r--r--recipes-kernel/linux/linux-yocto_4.%.bbappend2
3 files changed, 199 insertions, 0 deletions
diff --git a/recipes-kernel/linux/files/CVE-2016-5696-limiting-of-all-challenge.patch b/recipes-kernel/linux/files/CVE-2016-5696-limiting-of-all-challenge.patch
new file mode 100644
index 0000000..f2c2364
--- /dev/null
+++ b/recipes-kernel/linux/files/CVE-2016-5696-limiting-of-all-challenge.patch
@@ -0,0 +1,109 @@
1From 5413f1a526d2d51d7a5768133c90936c017165c6 Mon Sep 17 00:00:00 2001
2From: Jason Baron <jbaron@akamai.com>
3Date: Thu, 14 Jul 2016 11:38:40 -0400
4Subject: [PATCH] tcp: enable per-socket rate limiting of all 'challenge acks'
5
6[ Upstream commit 083ae308280d13d187512b9babe3454342a7987e ]
7
8The per-socket rate limit for 'challenge acks' was introduced in the
9context of limiting ack loops:
10
11commit f2b2c582e824 ("tcp: mitigate ACK loops for connections as tcp_sock")
12
13And I think it can be extended to rate limit all 'challenge acks' on a
14per-socket basis.
15
16Since we have the global tcp_challenge_ack_limit, this patch allows for
17tcp_challenge_ack_limit to be set to a large value and effectively rely on
18the per-socket limit, or set tcp_challenge_ack_limit to a lower value and
19still prevents a single connections from consuming the entire challenge ack
20quota.
21
22It further moves in the direction of eliminating the global limit at some
23point, as Eric Dumazet has suggested. This a follow-up to:
24Subject: tcp: make challenge acks less predictable
25
26CVE: CVE-2016-5696
27Upstream-Status: Backport
28
29Cc: Eric Dumazet <edumazet@google.com>
30Cc: David S. Miller <davem@davemloft.net>
31Cc: Neal Cardwell <ncardwell@google.com>
32Cc: Yuchung Cheng <ycheng@google.com>
33Cc: Yue Cao <ycao009@ucr.edu>
34Signed-off-by: Jason Baron <jbaron@akamai.com>
35Signed-off-by: David S. Miller <davem@davemloft.net>
36Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
37Signed-off-by: Sona Sarmadi <sona.sarmadi@enea.com>
38---
39 net/ipv4/tcp_input.c | 39 ++++++++++++++++++++++-----------------
40 1 file changed, 22 insertions(+), 17 deletions(-)
41
42diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
43index 05f10df..12b98e2 100644
44--- a/net/ipv4/tcp_input.c
45+++ b/net/ipv4/tcp_input.c
46@@ -3390,6 +3390,23 @@ static int tcp_ack_update_window(struct sock *sk, const struct sk_buff *skb, u32
47 return flag;
48 }
49
50+static bool __tcp_oow_rate_limited(struct net *net, int mib_idx,
51+ u32 *last_oow_ack_time)
52+{
53+ if (*last_oow_ack_time) {
54+ s32 elapsed = (s32)(tcp_time_stamp - *last_oow_ack_time);
55+
56+ if (0 <= elapsed && elapsed < sysctl_tcp_invalid_ratelimit) {
57+ NET_INC_STATS_BH(net, mib_idx);
58+ return true; /* rate-limited: don't send yet! */
59+ }
60+ }
61+
62+ *last_oow_ack_time = tcp_time_stamp;
63+
64+ return false; /* not rate-limited: go ahead, send dupack now! */
65+}
66+
67 /* Return true if we're currently rate-limiting out-of-window ACKs and
68 * thus shouldn't send a dupack right now. We rate-limit dupacks in
69 * response to out-of-window SYNs or ACKs to mitigate ACK loops or DoS
70@@ -3403,21 +3420,9 @@ bool tcp_oow_rate_limited(struct net *net, const struct sk_buff *skb,
71 /* Data packets without SYNs are not likely part of an ACK loop. */
72 if ((TCP_SKB_CB(skb)->seq != TCP_SKB_CB(skb)->end_seq) &&
73 !tcp_hdr(skb)->syn)
74- goto not_rate_limited;
75-
76- if (*last_oow_ack_time) {
77- s32 elapsed = (s32)(tcp_time_stamp - *last_oow_ack_time);
78-
79- if (0 <= elapsed && elapsed < sysctl_tcp_invalid_ratelimit) {
80- NET_INC_STATS_BH(net, mib_idx);
81- return true; /* rate-limited: don't send yet! */
82- }
83- }
84-
85- *last_oow_ack_time = tcp_time_stamp;
86+ return false;
87
88-not_rate_limited:
89- return false; /* not rate-limited: go ahead, send dupack now! */
90+ return __tcp_oow_rate_limited(net, mib_idx, last_oow_ack_time);
91 }
92
93 /* RFC 5961 7 [ACK Throttling] */
94@@ -3430,9 +3435,9 @@ static void tcp_send_challenge_ack(struct sock *sk, const struct sk_buff *skb)
95 u32 count, now;
96
97 /* First check our per-socket dupack rate limit. */
98- if (tcp_oow_rate_limited(sock_net(sk), skb,
99- LINUX_MIB_TCPACKSKIPPEDCHALLENGE,
100- &tp->last_oow_ack_time))
101+ if (__tcp_oow_rate_limited(sock_net(sk),
102+ LINUX_MIB_TCPACKSKIPPEDCHALLENGE,
103+ &tp->last_oow_ack_time))
104 return;
105
106 /* Then check host-wide RFC 5961 rate limit. */
107--
1081.9.1
109
diff --git a/recipes-kernel/linux/files/CVE-2016-5696-make-challenge-acks-less-predictable.patch b/recipes-kernel/linux/files/CVE-2016-5696-make-challenge-acks-less-predictable.patch
new file mode 100644
index 0000000..fe67b3b
--- /dev/null
+++ b/recipes-kernel/linux/files/CVE-2016-5696-make-challenge-acks-less-predictable.patch
@@ -0,0 +1,88 @@
1From 72c2d3bccaba4a0a4de354f9d2d24eccd05bfccf Mon Sep 17 00:00:00 2001
2From: Eric Dumazet <edumazet@google.com>
3Date: Sun, 10 Jul 2016 10:04:02 +0200
4Subject: [PATCH] tcp: make challenge acks less predictable
5
6[ Upstream commit 75ff39ccc1bd5d3c455b6822ab09e533c551f758 ]
7
8Yue Cao claims that current host rate limiting of challenge ACKS
9(RFC 5961) could leak enough information to allow a patient attacker
10to hijack TCP sessions. He will soon provide details in an academic
11paper.
12
13This patch increases the default limit from 100 to 1000, and adds
14some randomization so that the attacker can no longer hijack
15sessions without spending a considerable amount of probes.
16
17Based on initial analysis and patch from Linus.
18
19Note that we also have per socket rate limiting, so it is tempting
20to remove the host limit in the future.
21
22v2: randomize the count of challenge acks per second, not the period.
23
24CVE: CVE-2016-5696
25Upstream-Status: Backport
26
27Fixes: 282f23c6ee34 ("tcp: implement RFC 5961 3.2")
28Reported-by: Yue Cao <ycao009@ucr.edu>
29Signed-off-by: Eric Dumazet <edumazet@google.com>
30Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
31Cc: Yuchung Cheng <ycheng@google.com>
32Cc: Neal Cardwell <ncardwell@google.com>
33Acked-by: Neal Cardwell <ncardwell@google.com>
34Acked-by: Yuchung Cheng <ycheng@google.com>
35Signed-off-by: David S. Miller <davem@davemloft.net>
36Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
37Signed-off-by: Sona Sarmadi <sona.sarmadi@enea.com>
38---
39 net/ipv4/tcp_input.c | 15 ++++++++++-----
40 1 file changed, 10 insertions(+), 5 deletions(-)
41
42diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
43index d4c5115..05f10df 100644
44--- a/net/ipv4/tcp_input.c
45+++ b/net/ipv4/tcp_input.c
46@@ -89,7 +89,7 @@ int sysctl_tcp_adv_win_scale __read_mostly = 1;
47 EXPORT_SYMBOL(sysctl_tcp_adv_win_scale);
48
49 /* rfc5961 challenge ack rate limiting */
50-int sysctl_tcp_challenge_ack_limit = 100;
51+int sysctl_tcp_challenge_ack_limit = 1000;
52
53 int sysctl_tcp_stdurg __read_mostly;
54 int sysctl_tcp_rfc1337 __read_mostly;
55@@ -3427,7 +3427,7 @@ static void tcp_send_challenge_ack(struct sock *sk, const struct sk_buff *skb)
56 static u32 challenge_timestamp;
57 static unsigned int challenge_count;
58 struct tcp_sock *tp = tcp_sk(sk);
59- u32 now;
60+ u32 count, now;
61
62 /* First check our per-socket dupack rate limit. */
63 if (tcp_oow_rate_limited(sock_net(sk), skb,
64@@ -3435,13 +3435,18 @@ static void tcp_send_challenge_ack(struct sock *sk, const struct sk_buff *skb)
65 &tp->last_oow_ack_time))
66 return;
67
68- /* Then check the check host-wide RFC 5961 rate limit. */
69+ /* Then check host-wide RFC 5961 rate limit. */
70 now = jiffies / HZ;
71 if (now != challenge_timestamp) {
72+ u32 half = (sysctl_tcp_challenge_ack_limit + 1) >> 1;
73+
74 challenge_timestamp = now;
75- challenge_count = 0;
76+ WRITE_ONCE(challenge_count, half +
77+ prandom_u32_max(sysctl_tcp_challenge_ack_limit));
78 }
79- if (++challenge_count <= sysctl_tcp_challenge_ack_limit) {
80+ count = READ_ONCE(challenge_count);
81+ if (count > 0) {
82+ WRITE_ONCE(challenge_count, count - 1);
83 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPCHALLENGEACK);
84 tcp_send_ack(sk);
85 }
86--
871.9.1
88
diff --git a/recipes-kernel/linux/linux-yocto_4.%.bbappend b/recipes-kernel/linux/linux-yocto_4.%.bbappend
index 2ae6b4b..d0c4e98 100644
--- a/recipes-kernel/linux/linux-yocto_4.%.bbappend
+++ b/recipes-kernel/linux/linux-yocto_4.%.bbappend
@@ -3,6 +3,8 @@ require recipes-kernel/linux/enea-common.inc
3FILESEXTRAPATHS_prepend := "${THISDIR}/files:" 3FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
4 4
5SRC_URI += "file://hid-CVE-2016-5829.patch \ 5SRC_URI += "file://hid-CVE-2016-5829.patch \
6 file://CVE-2016-5696-limiting-of-all-challenge.patch \
7 file://CVE-2016-5696-make-challenge-acks-less-predictable.patch \
6 " 8 "
7 9
8ENEA_KERNEL_FRAGMENTS += "\ 10ENEA_KERNEL_FRAGMENTS += "\