[Devel] [PATCH RHEL7 COMMIT] rh/tcp: refine memory limit test in tcp_fragment()

Konstantin Khorenko khorenko at virtuozzo.com
Thu Aug 15 18:46:03 MSK 2019


The commit is pushed to "branch-rh7-3.10.0-957.27.2.vz7.107.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.27.2.vz7.107.3
------>
commit 4a01b61cdd98888ddf9d471429638b6d72d7760f
Author: Florian Westphal <fwestpha at redhat.com>
Date:   Tue Jul 2 12:14:28 2019 +0200

    rh/tcp: refine memory limit test in tcp_fragment()
    
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1723032
    
    Upstream Status: commit b6653b3629e5b88
    commit b6653b3629e5b88202be3c9abc44713973f5c4b4
    Author: Eric Dumazet <edumazet at google.com>
    Date:   Fri Jun 21 06:09:55 2019 -0700
        tcp: refine memory limit test in tcp_fragment()
        tcp_fragment() might be called for skbs in the write queue.
        Memory limits might have been exceeded because tcp_sendmsg() only
        checks limits at full skb (64KB) boundaries.
        Therefore, we need to make sure tcp_fragment() wont punish applications
        that might have setup very low SO_SNDBUF values.
        Fixes: f070ef2ac667 ("tcp: tcp_fragment() should apply sane memory limits")
        Signed-off-by: Eric Dumazet <edumazet at google.com>
        Reported-by: Christoph Paasch <cpaasch at apple.com>
        Tested-by: Christoph Paasch <cpaasch at apple.com>
        Signed-off-by: David S. Miller <davem at davemloft.net>
    Signed-off-by: Florian Westphal <fwestpha at redhat.com>
    Signed-off-by: Jiri Benc <jbenc at redhat.com>
    Signed-off-by: Denys Vlasenko <dvlasenk at redhat.com>
    ===========================================
    This patch is included into 3.10.0-957.27.4.el7 RHEL7.6 EUS kernel,
    so apply them.
    
    https://jira.sw.ru/browse/PSBM-95578
    
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 net/ipv4/tcp_output.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 48fa7fa40370..deb3e4826639 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1129,8 +1129,9 @@ int tcp_fragment(struct sock *sk, enum tcp_queue tcp_queue,
 	if (nsize < 0)
 		nsize = 0;
 
-	if (unlikely((sk->sk_wmem_queued >> 1) > sk->sk_sndbuf) ||
-	    skb_queue_len(&sk->sk_write_queue) > 2048) {
+	if (unlikely(((sk->sk_wmem_queued >> 1) > sk->sk_sndbuf &&
+	    tcp_queue != TCP_FRAG_IN_WRITE_QUEUE) ||
+	    skb_queue_len(&sk->sk_write_queue) > 2048)) {
 		NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPWQUEUETOOBIG);
 		return -ENOMEM;
 	}



More information about the Devel mailing list