Received: by 10.223.185.116 with SMTP id b49csp5472495wrg; Wed, 7 Mar 2018 12:21:13 -0800 (PST) X-Google-Smtp-Source: AG47ELv/tmn3hytsyV7MHl4LlTzqWjA7yySUKuw8U4sPsonomTdZCW1rxEFqypnOCVIA6DjYZLy7 X-Received: by 10.101.82.70 with SMTP id q6mr18819301pgp.67.1520454073600; Wed, 07 Mar 2018 12:21:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520454073; cv=none; d=google.com; s=arc-20160816; b=C5mCX75tn6VsPRWNEKuY/HGIR64DSpUxR6zm+rMwSls+qPz9yC7WIKlbSOZlFO1R1T cDKcs5hN0MGDcbQtJx6BuciHn/jMtxOHUC90fI69/X45iHe4hXHxyqFHZKmKn6X9e7qm v3oZqe5YQj0Ieh5mocWlIkxycUMg4tg3IBIL6liyCBlIja2xBoW8ccar1e5WXOzPR4r2 wTxmgCozRwBY7ImLuSHq8G/gFLa6Z0sTsrFd/RJVeVhSK9yKLJGwENSkujQd6d+/umAG rqkTaLUcnJk3HqCZfMW7NQgTnLPQYN4r8ss1LD/AWcct+Hs123jk7qNc7/rpmHNAHENW MdVw== 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=FmaiPhXf+XRn8T2HJb+v+fLRFqPI8gl3Nu/8QNf4cZQ=; b=p81UuwchR7YYqLCJW9Elrrnjx2Au99uqrZXr4ozAn5yZKItv/uYUts762s11ZOf13Q UDvaB/2oH/abXOLMZ+DR5BWOjsMxfANuBjMrWeaNYHwJFbbJJJLZ/K+PaNpiflA81N1c gJwa3hJ2RMZJfSJv17G3RT+SYM4hmxv06ilNyFYreG3S0BCxpzpAdPfjZkwkDfctch+4 L3EXfsfuR7pql1Q4MaTPnCbc9A1UD+rvXgN6lTSsCBKAKFrKPN68lUzW3t8oQE5+CWUf YPEYxADIzrMhypanIiPXel2O03uKKrFOjVRuvHIsKDfZ4Wvxx9hQSW8FOIzkL7yudECp j4Yg== 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 w9-v6si13264002plp.425.2018.03.07.12.20.59; Wed, 07 Mar 2018 12:21:13 -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 S934973AbeCGTnq (ORCPT + 99 others); Wed, 7 Mar 2018 14:43:46 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:43430 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964983AbeCGTnn (ORCPT ); Wed, 7 Mar 2018 14:43:43 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 75C3FC8D; Wed, 7 Mar 2018 19:43:42 +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.15 075/122] tcp: purge write queue upon RST Date: Wed, 7 Mar 2018 11:38:07 -0800 Message-Id: <20180307191740.121639703@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180307191729.190879024@linuxfoundation.org> References: <20180307191729.190879024@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.15-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 @@ -3988,6 +3988,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))