]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.9/tcp-refine-memory-limit-test-in-tcp_fragment.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.9 / tcp-refine-memory-limit-test-in-tcp_fragment.patch
1 From b6653b3629e5b88202be3c9abc44713973f5c4b4 Mon Sep 17 00:00:00 2001
2 From: Eric Dumazet <edumazet@google.com>
3 Date: Fri, 21 Jun 2019 06:09:55 -0700
4 Subject: tcp: refine memory limit test in tcp_fragment()
5
6 From: Eric Dumazet <edumazet@google.com>
7
8 commit b6653b3629e5b88202be3c9abc44713973f5c4b4 upstream.
9
10 tcp_fragment() might be called for skbs in the write queue.
11
12 Memory limits might have been exceeded because tcp_sendmsg() only
13 checks limits at full skb (64KB) boundaries.
14
15 Therefore, we need to make sure tcp_fragment() wont punish applications
16 that might have setup very low SO_SNDBUF values.
17
18 Fixes: f070ef2ac667 ("tcp: tcp_fragment() should apply sane memory limits")
19 Signed-off-by: Eric Dumazet <edumazet@google.com>
20 Reported-by: Christoph Paasch <cpaasch@apple.com>
21 Tested-by: Christoph Paasch <cpaasch@apple.com>
22 Signed-off-by: David S. Miller <davem@davemloft.net>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24
25 ---
26 net/ipv4/tcp_output.c | 3 ++-
27 1 file changed, 2 insertions(+), 1 deletion(-)
28
29 --- a/net/ipv4/tcp_output.c
30 +++ b/net/ipv4/tcp_output.c
31 @@ -1185,7 +1185,8 @@ int tcp_fragment(struct sock *sk, struct
32 if (nsize < 0)
33 nsize = 0;
34
35 - if (unlikely((sk->sk_wmem_queued >> 1) > sk->sk_sndbuf)) {
36 + if (unlikely((sk->sk_wmem_queued >> 1) > sk->sk_sndbuf &&
37 + tcp_queue != TCP_FRAG_IN_WRITE_QUEUE)) {
38 NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPWQUEUETOOBIG);
39 return -ENOMEM;
40 }