summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Wellving <andreas.wellving@enea.com>2019-07-10 12:12:49 +0200
committerAdrian Stratulat <Adrian.Stratulat@enea.com>2019-07-12 14:53:24 +0200
commitda9b21cafedbe210b4d6b399e513a21017fee7c1 (patch)
treeac8cf2a1e16ef4b9cecdf4214b2e08a481aeb947
parentf095fec9a8e21c24ebdc61341bed46d469bd1384 (diff)
downloadenea-kernel-cache-da9b21cafedbe210b4d6b399e513a21017fee7c1.tar.gz
tcp: CVE-2019-11479
tcp: add tcp_min_snd_mss sysctl tcp: enforce tcp_min_snd_mss in tcp_mtu_probing() References: https://nvd.nist.gov/vuln/detail/CVE-2019-11479 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.9.y&id=8e39cbc03dafa3731d22533f869bf326c0e6e6f8 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.9.y&id=7e9096287352d0416f3caa0919c90bd9ed2f68d3 Change-Id: I75cade9036c762b5a2cc4512b87fcf96a66f11a0 Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
-rw-r--r--patches/cve/4.9.x.scc2
-rw-r--r--patches/cve/CVE-2019-11479-tcp-add-tcp_min_snd_mss-sysctl.patch142
-rw-r--r--patches/cve/CVE-2019-11479-tcp-enforce-tcp_min_snd_mss-in-tcp_mtu_probing.patch46
3 files changed, 190 insertions, 0 deletions
diff --git a/patches/cve/4.9.x.scc b/patches/cve/4.9.x.scc
index ad03493..18412cb 100644
--- a/patches/cve/4.9.x.scc
+++ b/patches/cve/4.9.x.scc
@@ -48,3 +48,5 @@ patch CVE-2018-20836-scsi-libsas-fix-a-race-condition-when-smp-task-timeo.patch
48patch CVE-2019-11477-tcp-limit-payload-size-of-sacked-skbs.patch 48patch CVE-2019-11477-tcp-limit-payload-size-of-sacked-skbs.patch
49patch CVE-2019-11478-tcp-tcp_fragment-should-apply-sane-memory-limits.patch 49patch CVE-2019-11478-tcp-tcp_fragment-should-apply-sane-memory-limits.patch
50patch CVE-2019-11478-tcp-refine-memory-limit-test-in-tcp_fragment.patch 50patch CVE-2019-11478-tcp-refine-memory-limit-test-in-tcp_fragment.patch
51patch CVE-2019-11479-tcp-add-tcp_min_snd_mss-sysctl.patch
52patch CVE-2019-11479-tcp-enforce-tcp_min_snd_mss-in-tcp_mtu_probing.patch
diff --git a/patches/cve/CVE-2019-11479-tcp-add-tcp_min_snd_mss-sysctl.patch b/patches/cve/CVE-2019-11479-tcp-add-tcp_min_snd_mss-sysctl.patch
new file mode 100644
index 0000000..9cb6467
--- /dev/null
+++ b/patches/cve/CVE-2019-11479-tcp-add-tcp_min_snd_mss-sysctl.patch
@@ -0,0 +1,142 @@
1From 8e39cbc03dafa3731d22533f869bf326c0e6e6f8 Mon Sep 17 00:00:00 2001
2From: Eric Dumazet <edumazet@google.com>
3Date: Sat, 15 Jun 2019 17:44:24 -0700
4Subject: [PATCH] tcp: add tcp_min_snd_mss sysctl
5
6commit 5f3e2bf008c2221478101ee72f5cb4654b9fc363 upstream.
7
8Some TCP peers announce a very small MSS option in their SYN and/or
9SYN/ACK messages.
10
11This forces the stack to send packets with a very high network/cpu
12overhead.
13
14Linux has enforced a minimal value of 48. Since this value includes
15the size of TCP options, and that the options can consume up to 40
16bytes, this means that each segment can include only 8 bytes of payload.
17
18In some cases, it can be useful to increase the minimal value
19to a saner value.
20
21We still let the default to 48 (TCP_MIN_SND_MSS), for compatibility
22reasons.
23
24Note that TCP_MAXSEG socket option enforces a minimal value
25of (TCP_MIN_MSS). David Miller increased this minimal value
26in commit c39508d6f118 ("tcp: Make TCP_MAXSEG minimum more correct.")
27from 64 to 88.
28
29We might in the future merge TCP_MIN_SND_MSS and TCP_MIN_MSS.
30
31CVE-2019-11479 -- tcp mss hardcoded to 48
32
33CVE: CVE-2019-11479
34Upstream-Status: Backport [https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.9.y&id=8e39cbc03dafa3731d22533f869bf326c0e6e6f8]
35
36Signed-off-by: Eric Dumazet <edumazet@google.com>
37Suggested-by: Jonathan Looney <jtl@netflix.com>
38Acked-by: Neal Cardwell <ncardwell@google.com>
39Cc: Yuchung Cheng <ycheng@google.com>
40Cc: Tyler Hicks <tyhicks@canonical.com>
41Cc: Bruce Curtis <brucec@netflix.com>
42Cc: Jonathan Lemon <jonathan.lemon@gmail.com>
43Signed-off-by: David S. Miller <davem@davemloft.net>
44Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
45Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
46---
47 Documentation/networking/ip-sysctl.txt | 8 ++++++++
48 include/net/netns/ipv4.h | 1 +
49 net/ipv4/sysctl_net_ipv4.c | 11 +++++++++++
50 net/ipv4/tcp_ipv4.c | 1 +
51 net/ipv4/tcp_output.c | 3 +--
52 5 files changed, 22 insertions(+), 2 deletions(-)
53
54diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
55index 0335285f3918..49935d5bb5c6 100644
56--- a/Documentation/networking/ip-sysctl.txt
57+++ b/Documentation/networking/ip-sysctl.txt
58@@ -230,6 +230,14 @@ tcp_base_mss - INTEGER
59 Path MTU discovery (MTU probing). If MTU probing is enabled,
60 this is the initial MSS used by the connection.
61
62+tcp_min_snd_mss - INTEGER
63+ TCP SYN and SYNACK messages usually advertise an ADVMSS option,
64+ as described in RFC 1122 and RFC 6691.
65+ If this ADVMSS option is smaller than tcp_min_snd_mss,
66+ it is silently capped to tcp_min_snd_mss.
67+
68+ Default : 48 (at least 8 bytes of payload per segment)
69+
70 tcp_congestion_control - STRING
71 Set the congestion control algorithm to be used for new
72 connections. The algorithm "reno" is always available, but
73diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
74index 7adf4386ac8f..bf619a67ec03 100644
75--- a/include/net/netns/ipv4.h
76+++ b/include/net/netns/ipv4.h
77@@ -94,6 +94,7 @@ struct netns_ipv4 {
78 #endif
79 int sysctl_tcp_mtu_probing;
80 int sysctl_tcp_base_mss;
81+ int sysctl_tcp_min_snd_mss;
82 int sysctl_tcp_probe_threshold;
83 u32 sysctl_tcp_probe_interval;
84
85diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
86index 85713adf2770..e202babb14d6 100644
87--- a/net/ipv4/sysctl_net_ipv4.c
88+++ b/net/ipv4/sysctl_net_ipv4.c
89@@ -35,6 +35,8 @@ static int ip_local_port_range_min[] = { 1, 1 };
90 static int ip_local_port_range_max[] = { 65535, 65535 };
91 static int tcp_adv_win_scale_min = -31;
92 static int tcp_adv_win_scale_max = 31;
93+static int tcp_min_snd_mss_min = TCP_MIN_SND_MSS;
94+static int tcp_min_snd_mss_max = 65535;
95 static int ip_ttl_min = 1;
96 static int ip_ttl_max = 255;
97 static int tcp_syn_retries_min = 1;
98@@ -838,6 +840,15 @@ static struct ctl_table ipv4_net_table[] = {
99 .mode = 0644,
100 .proc_handler = proc_dointvec,
101 },
102+ {
103+ .procname = "tcp_min_snd_mss",
104+ .data = &init_net.ipv4.sysctl_tcp_min_snd_mss,
105+ .maxlen = sizeof(int),
106+ .mode = 0644,
107+ .proc_handler = proc_dointvec_minmax,
108+ .extra1 = &tcp_min_snd_mss_min,
109+ .extra2 = &tcp_min_snd_mss_max,
110+ },
111 {
112 .procname = "tcp_probe_threshold",
113 .data = &init_net.ipv4.sysctl_tcp_probe_threshold,
114diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
115index 82c1064ff4aa..848f2c1da8a5 100644
116--- a/net/ipv4/tcp_ipv4.c
117+++ b/net/ipv4/tcp_ipv4.c
118@@ -2456,6 +2456,7 @@ static int __net_init tcp_sk_init(struct net *net)
119 net->ipv4.sysctl_tcp_ecn_fallback = 1;
120
121 net->ipv4.sysctl_tcp_base_mss = TCP_BASE_MSS;
122+ net->ipv4.sysctl_tcp_min_snd_mss = TCP_MIN_SND_MSS;
123 net->ipv4.sysctl_tcp_probe_threshold = TCP_PROBE_THRESHOLD;
124 net->ipv4.sysctl_tcp_probe_interval = TCP_PROBE_INTERVAL;
125
126diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
127index 123b2d8fde46..d8c6b833f0ce 100644
128--- a/net/ipv4/tcp_output.c
129+++ b/net/ipv4/tcp_output.c
130@@ -1360,8 +1360,7 @@ static inline int __tcp_mtu_to_mss(struct sock *sk, int pmtu)
131 mss_now -= icsk->icsk_ext_hdr_len;
132
133 /* Then reserve room for full set of TCP options and 8 bytes of data */
134- if (mss_now < TCP_MIN_SND_MSS)
135- mss_now = TCP_MIN_SND_MSS;
136+ mss_now = max(mss_now, sock_net(sk)->ipv4.sysctl_tcp_min_snd_mss);
137 return mss_now;
138 }
139
140--
1412.20.1
142
diff --git a/patches/cve/CVE-2019-11479-tcp-enforce-tcp_min_snd_mss-in-tcp_mtu_probing.patch b/patches/cve/CVE-2019-11479-tcp-enforce-tcp_min_snd_mss-in-tcp_mtu_probing.patch
new file mode 100644
index 0000000..5576fcf
--- /dev/null
+++ b/patches/cve/CVE-2019-11479-tcp-enforce-tcp_min_snd_mss-in-tcp_mtu_probing.patch
@@ -0,0 +1,46 @@
1From 7e9096287352d0416f3caa0919c90bd9ed2f68d3 Mon Sep 17 00:00:00 2001
2From: Eric Dumazet <edumazet@google.com>
3Date: Sat, 15 Jun 2019 17:47:27 -0700
4Subject: [PATCH] tcp: enforce tcp_min_snd_mss in tcp_mtu_probing()
5
6commit 967c05aee439e6e5d7d805e195b3a20ef5c433d6 upstream.
7
8If mtu probing is enabled tcp_mtu_probing() could very well end up
9with a too small MSS.
10
11Use the new sysctl tcp_min_snd_mss to make sure MSS search
12is performed in an acceptable range.
13
14CVE-2019-11479 -- tcp mss hardcoded to 48
15
16CVE: CVE-2019-11479 fix
17Upstream-Status: Backport [https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.9.y&id=7e9096287352d0416f3caa0919c90bd9ed2f68d3]
18
19Signed-off-by: Eric Dumazet <edumazet@google.com>
20Reported-by: Jonathan Lemon <jonathan.lemon@gmail.com>
21Cc: Jonathan Looney <jtl@netflix.com>
22Acked-by: Neal Cardwell <ncardwell@google.com>
23Cc: Yuchung Cheng <ycheng@google.com>
24Cc: Tyler Hicks <tyhicks@canonical.com>
25Cc: Bruce Curtis <brucec@netflix.com>
26Signed-off-by: David S. Miller <davem@davemloft.net>
27Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
29---
30 net/ipv4/tcp_timer.c | 1 +
31 1 file changed, 1 insertion(+)
32
33diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
34index 69523389f067..d9e364c4863a 100644
35--- a/net/ipv4/tcp_timer.c
36+++ b/net/ipv4/tcp_timer.c
37@@ -140,6 +140,7 @@ static void tcp_mtu_probing(struct inet_connection_sock *icsk, struct sock *sk)
38 mss = tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_low) >> 1;
39 mss = min(net->ipv4.sysctl_tcp_base_mss, mss);
40 mss = max(mss, 68 - tp->tcp_header_len);
41+ mss = max(mss, net->ipv4.sysctl_tcp_min_snd_mss);
42 icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, mss);
43 tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
44 }
45--
462.20.1