Received: by 2002:a17:90a:9103:0:0:0:0 with SMTP id k3csp11810123pjo; Thu, 2 Jan 2020 14:40:19 -0800 (PST) X-Google-Smtp-Source: APXvYqwz4wghFuLDZUyiKC2LVn30Pagf+3QHMpR6VDl7Dn20u6ojDqbVjDyqhv3sduwp+1jc9AmH X-Received: by 2002:a9d:480b:: with SMTP id c11mr84000348otf.283.1578004819253; Thu, 02 Jan 2020 14:40:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578004819; cv=none; d=google.com; s=arc-20160816; b=0J/UcNUEMAVvA3J88GSfPqxTuDDQkLebABM0JKTZQAEvW0u6LKtkxDr1IiwsaowdEa 0Gnakbui3xE46nWwt0qkDkUIP3wnUXzvNzKDm32AHHBlzuE0W6Om+Ni7mtmpc3VW6pOw FU9gbHILxUgJsWf4L3snVeFz8AzTzdUpPb6k9UuWAjoD7egLdiCQ7fFPPfOmJIPcptfY 8KisNCSXOw93Ch8ZAlbskv70c8nmNBDGupSeQdbeEq8vYjgcFreMHMZ5RaMQ6NOIxsHi BkgDzKb7fmTsAsQXdjnoyhHf6dyyI7akh6no2CHAUXdjtodBGwlIz5XFHlUcg8T4XJnX sYHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jUl9bw5sA6898VWtrs92fnovZWug2flM8urjolMEY7c=; b=avNil8iUvrSIXuHkmSN5jJkkoGm11w4rfAkZNHYERhjEaORA50P7wS9tNDZ5CPDSfS mcifbN60k18ckiNpnfPRiSUaZ7+2nUZ4W+GNS1ZhZFPIKbV+CroYFNaFJ8n7PvZwJ9wo FUP+lHPELKVsXh03qnQpWJlyzHeWBHGWf1E90rLWVLXelg/azqUvzRh985bcIUe78XWC Fuw1t5WSU9Ayz9VubCq4BaSrVqa/CJoA4RUs58/Zrs6C3VesZOI6XIxqVK6BJE4wIg+R /vtMFvvMqnMcuUa7aDYjiuXAq4YNY2HPmaVNofUY+EEnO1XupV49IuofB/14r4Z2NwVG cg/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UayEiFil; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p21si20440924otk.162.2020.01.02.14.40.07; Thu, 02 Jan 2020 14:40:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UayEiFil; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731423AbgABWjM (ORCPT + 99 others); Thu, 2 Jan 2020 17:39:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:54620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731408AbgABWjL (ORCPT ); Thu, 2 Jan 2020 17:39:11 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 33D1E21835; Thu, 2 Jan 2020 22:39:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578004750; bh=DIyWtAQ7QSGL6ztK8yUbiunjL1bhrGVP3ckBM3rg+PU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UayEiFilIm2Zrh/FLvvF6oqsgqfRpkSr4g6ERvMMpR8x4l7DNSxwYGF8fwkau+iib U5deCQl8DFPyTA55MH6Kb7e3yAOXmGN51UcjxqFecvDkm8gZwQtf2df572wrpoy6xH uA/qCyMJLD5Hx4HLyBYy9iyyj0CGLyNWllqFocn4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Christoph Paasch , Neal Cardwell , Jason Baron , Soheil Hassas Yeganeh , Jakub Kicinski Subject: [PATCH 4.4 137/137] tcp: do not send empty skb from tcp_write_xmit() Date: Thu, 2 Jan 2020 23:08:30 +0100 Message-Id: <20200102220605.660213239@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220546.618583146@linuxfoundation.org> References: <20200102220546.618583146@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet [ Upstream commit 1f85e6267caca44b30c54711652b0726fadbb131 ] Backport of commit fdfc5c8594c2 ("tcp: remove empty skb from write queue in error cases") in linux-4.14 stable triggered various bugs. One of them has been fixed in commit ba2ddb43f270 ("tcp: Don't dequeue SYN/FIN-segments from write-queue"), but we still have crashes in some occasions. Root-cause is that when tcp_sendmsg() has allocated a fresh skb and could not append a fragment before being blocked in sk_stream_wait_memory(), tcp_write_xmit() might be called and decide to send this fresh and empty skb. Sending an empty packet is not only silly, it might have caused many issues we had in the past with tp->packets_out being out of sync. Fixes: c65f7f00c587 ("[TCP]: Simplify SKB data portion allocation with NETIF_F_SG.") Signed-off-by: Eric Dumazet Cc: Christoph Paasch Acked-by: Neal Cardwell Cc: Jason Baron Acked-by: Soheil Hassas Yeganeh Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp_output.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -2148,6 +2148,14 @@ static bool tcp_write_xmit(struct sock * break; } + /* Argh, we hit an empty skb(), presumably a thread + * is sleeping in sendmsg()/sk_stream_wait_memory(). + * We do not want to send a pure-ack packet and have + * a strange looking rtx queue with empty packet(s). + */ + if (TCP_SKB_CB(skb)->end_seq == TCP_SKB_CB(skb)->seq) + break; + if (unlikely(tcp_transmit_skb(sk, skb, 1, gfp))) break;