Received: by 10.223.185.116 with SMTP id b49csp5455144wrg; Wed, 7 Mar 2018 12:03:31 -0800 (PST) X-Google-Smtp-Source: AG47ELvgSpt6AeERQt5Nozx8jenWScXNIXf6NWYUle1MWBrNbNAc2J6ioc4RQIQcoQ8few8PBR5h X-Received: by 10.98.135.76 with SMTP id i73mr23833849pfe.140.1520453011512; Wed, 07 Mar 2018 12:03:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520453011; cv=none; d=google.com; s=arc-20160816; b=rUuZ1TjqeyRCuMDn3NasKtGogjqkn5WbyLcZpYze81yet3D3ODT/3FI4pemUQ0kj0d XibWL54jDSeyN0R/VtnWInc1dmIM2GI9q0Hm2/J5T3kCODYew6zhhEXLyaJOhq0rm+nu PgY5WZ/MfoCWAirXwFz6k89a6Mza/AS+cHBesNpeRL9U3vEqM2zMle0fLqmrjRCKViTv v+REbhHg2KPoNCkmnrLf+hoJ0vZ5zn5Csn2WCMAJNOneqYQir1o+IfZogqtbPP1HIqSq Bf2az+TWumSt3ueor7vUzsGMWnS/EX1/pnWS67caKRNwCkqar4k5xMBvZljh80grpa1S +ubw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=wqJGbrehhhDK5QPi5CmszP87XuhxKTEQg3XhdjlTdhA=; b=IzyyQ8JTxZnO3jvLPXlnNWV0lXanWYcJz/nXrncUFCnoq/Kd+HuWWPLQbY0EYxGmhj S0oLdpsBZQTCu9k0nvOcbxSyvC5ASgrlyuZmH6UZfFlAH17qMfC8fuZDJLH7Ty1c5U7x dbnxsGbugY6+1oCV0J2Ct7zb2Zr2s9zRCA7I7ja/f318Q8qRXoA203h7cMnTt49toT7x d1VJy+ZPHhU/QPfOjF9rMBRSYL0opGb0kDCH0gw8ZuN1oiHkEhfux7l2Pa/besQr5iy9 uUMCOGjyuZ4UNtpik+0xZCMWdsV3CmzPJmeuW14teYmb4/590LAgVw+w8KfgzYMw5mT1 W24g== ARC-Authentication-Results: i=1; mx.google.com; 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 n128si4813455pgn.827.2018.03.07.12.03.16; Wed, 07 Mar 2018 12:03:31 -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; 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 S965672AbeCGUCA (ORCPT + 99 others); Wed, 7 Mar 2018 15:02:00 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:44776 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754753AbeCGTqu (ORCPT ); Wed, 7 Mar 2018 14:46:50 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id DF10E10A9; Wed, 7 Mar 2018 19:46:49 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Soheil Hassas Yeganeh , Eric Dumazet , Yuchung Cheng , Neal Cardwell , "David S. Miller" Subject: [PATCH 4.14 071/110] tcp: purge write queue upon RST Date: Wed, 7 Mar 2018 11:38:54 -0800 Message-Id: <20180307191048.728849569@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180307191039.748351103@linuxfoundation.org> References: <20180307191039.748351103@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Soheil Hassas Yeganeh [ Upstream commit a27fd7a8ed3856faaf5a2ff1c8c5f00c0667aaa0 ] When the connection is reset, there is no point in keeping the packets on the write queue until the connection is closed. RFC 793 (page 70) and RFC 793-bis (page 64) both suggest purging the write queue upon RST: https://tools.ietf.org/html/draft-ietf-tcpm-rfc793bis-07 Moreover, this is essential for a correct MSG_ZEROCOPY implementation, because userspace cannot call close(fd) before receiving zerocopy signals even when the connection is reset. Fixes: f214f915e7db ("tcp: enable MSG_ZEROCOPY") Signed-off-by: Soheil Hassas Yeganeh Reviewed-by: Eric Dumazet Signed-off-by: Yuchung Cheng Signed-off-by: Neal Cardwell Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp_input.c | 1 + 1 file changed, 1 insertion(+) --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4011,6 +4011,7 @@ void tcp_reset(struct sock *sk) /* This barrier is coupled with smp_rmb() in tcp_poll() */ smp_wmb(); + tcp_write_queue_purge(sk); tcp_done(sk); if (!sock_flag(sk, SOCK_DEAD))