summaryrefslogtreecommitdiffstats
path: root/patches/cve/CVE-2019-11478-tcp-tcp_fragment-should-apply-sane-memory-limits.patch
diff options
context:
space:
mode:
authorAndreas Wellving <andreas.wellving@enea.com>2019-07-10 15:10:41 +0200
committerAdrian Stratulat <adrian.stratulat@enea.com>2019-07-12 11:18:48 +0200
commit427e88c46aab55b5291fecf4fbb317c7d60ca8c9 (patch)
tree3e75b34e0c710feba5e192ec45009518a5570adf /patches/cve/CVE-2019-11478-tcp-tcp_fragment-should-apply-sane-memory-limits.patch
parentfa0a35e4363e7c58c0f0fd3566fa72b9a561f16d (diff)
downloadenea-kernel-cache-427e88c46aab55b5291fecf4fbb317c7d60ca8c9.tar.gz
tcp: CVE-2019-11478
tcp: tcp_fragment() should apply sane memory limits tcp: refine memory limit test in tcp_fragment() References: https://nvd.nist.gov/vuln/detail/CVE-2019-11478 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.9.y&id=e358f4af19db46ca25cc9a8a78412b09ba98859d https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.9.y&id=caa51edc7e9606418611e68de624efbd0042adf5 Change-Id: I9630c20a11d9a92095d475f2a6d27e627fd7bbff Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
Diffstat (limited to 'patches/cve/CVE-2019-11478-tcp-tcp_fragment-should-apply-sane-memory-limits.patch')
-rw-r--r--patches/cve/CVE-2019-11478-tcp-tcp_fragment-should-apply-sane-memory-limits.patch86
1 files changed, 86 insertions, 0 deletions
diff --git a/patches/cve/CVE-2019-11478-tcp-tcp_fragment-should-apply-sane-memory-limits.patch b/patches/cve/CVE-2019-11478-tcp-tcp_fragment-should-apply-sane-memory-limits.patch
new file mode 100644
index 0000000..7d0c4f4
--- /dev/null
+++ b/patches/cve/CVE-2019-11478-tcp-tcp_fragment-should-apply-sane-memory-limits.patch
@@ -0,0 +1,86 @@
1From e358f4af19db46ca25cc9a8a78412b09ba98859d Mon Sep 17 00:00:00 2001
2From: Eric Dumazet <edumazet@google.com>
3Date: Sat, 15 Jun 2019 17:40:56 -0700
4Subject: [PATCH] tcp: tcp_fragment() should apply sane memory limits
5
6commit f070ef2ac66716357066b683fb0baf55f8191a2e upstream.
7
8Jonathan Looney reported that a malicious peer can force a sender
9to fragment its retransmit queue into tiny skbs, inflating memory
10usage and/or overflow 32bit counters.
11
12TCP allows an application to queue up to sk_sndbuf bytes,
13so we need to give some allowance for non malicious splitting
14of retransmit queue.
15
16A new SNMP counter is added to monitor how many times TCP
17did not allow to split an skb if the allowance was exceeded.
18
19Note that this counter might increase in the case applications
20use SO_SNDBUF socket option to lower sk_sndbuf.
21
22CVE-2019-11478 : tcp_fragment, prevent fragmenting a packet when the
23 socket is already using more than half the allowed space
24
25CVE: CVE-2019-11478
26Upstream-Status: Backport [https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.9.y&id=e358f4af19db46ca25cc9a8a78412b09ba98859d]
27
28Signed-off-by: Eric Dumazet <edumazet@google.com>
29Reported-by: Jonathan Looney <jtl@netflix.com>
30Acked-by: Neal Cardwell <ncardwell@google.com>
31Acked-by: Yuchung Cheng <ycheng@google.com>
32Reviewed-by: Tyler Hicks <tyhicks@canonical.com>
33Cc: Bruce Curtis <brucec@netflix.com>
34Cc: Jonathan Lemon <jonathan.lemon@gmail.com>
35Signed-off-by: David S. Miller <davem@davemloft.net>
36Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
37Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
38---
39 include/uapi/linux/snmp.h | 1 +
40 net/ipv4/proc.c | 1 +
41 net/ipv4/tcp_output.c | 5 +++++
42 3 files changed, 7 insertions(+)
43
44diff --git a/include/uapi/linux/snmp.h b/include/uapi/linux/snmp.h
45index 3442a26d36d9..56e3460d1f9f 100644
46--- a/include/uapi/linux/snmp.h
47+++ b/include/uapi/linux/snmp.h
48@@ -282,6 +282,7 @@ enum
49 LINUX_MIB_TCPKEEPALIVE, /* TCPKeepAlive */
50 LINUX_MIB_TCPMTUPFAIL, /* TCPMTUPFail */
51 LINUX_MIB_TCPMTUPSUCCESS, /* TCPMTUPSuccess */
52+ LINUX_MIB_TCPWQUEUETOOBIG, /* TCPWqueueTooBig */
53 __LINUX_MIB_MAX
54 };
55
56diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
57index ec48d8eafc7e..8b221398534b 100644
58--- a/net/ipv4/proc.c
59+++ b/net/ipv4/proc.c
60@@ -306,6 +306,7 @@ static const struct snmp_mib snmp4_net_list[] = {
61 SNMP_MIB_ITEM("TCPKeepAlive", LINUX_MIB_TCPKEEPALIVE),
62 SNMP_MIB_ITEM("TCPMTUPFail", LINUX_MIB_TCPMTUPFAIL),
63 SNMP_MIB_ITEM("TCPMTUPSuccess", LINUX_MIB_TCPMTUPSUCCESS),
64+ SNMP_MIB_ITEM("TCPWqueueTooBig", LINUX_MIB_TCPWQUEUETOOBIG),
65 SNMP_MIB_SENTINEL
66 };
67
68diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
69index 2f166662682e..123b2d8fde46 100644
70--- a/net/ipv4/tcp_output.c
71+++ b/net/ipv4/tcp_output.c
72@@ -1185,6 +1185,11 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len,
73 if (nsize < 0)
74 nsize = 0;
75
76+ if (unlikely((sk->sk_wmem_queued >> 1) > sk->sk_sndbuf)) {
77+ NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPWQUEUETOOBIG);
78+ return -ENOMEM;
79+ }
80+
81 if (skb_unclone(skb, gfp))
82 return -ENOMEM;
83
84--
852.20.1
86