Received: by 10.192.165.148 with SMTP id m20csp808661imm; Fri, 27 Apr 2018 07:52:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZouN+4NeEqt0UitOSOCDqbNmEV9LOxmytA3ENGh0FWEOb8ot32rcVOQr1PMc9YKI9wvbaVY X-Received: by 2002:a63:6783:: with SMTP id b125-v6mr2335529pgc.177.1524840722972; Fri, 27 Apr 2018 07:52:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524840722; cv=none; d=google.com; s=arc-20160816; b=F4p2RApz73jWVQ1t7MTLxqxqBBJzOeMWZJCno/IjF892loDAnNREX4MBxxHZxvBIe1 uTD9fr8jQ3OIVzMlx0swY8i5Dl5A9OZhkOYmtDADof7uMlqW0JDtpCKHIAXegOIBU/hq 3xw0MarwYwmNUb3J+iR8FvKQxAOPzrSf7v2rttH1eVmEPz/gQFzEcyKwf9F+j/q9UyV0 bvkQNlRSEWQzXbodktZGHCn879/KiBUhZgmTQlmMGMqBoFHzouVBA5rFvM7LCUc1WtFa EsdrhDp46tpVQk0N1yQiwC4SGckI2JLo9AN9RaCAyG3zSQMA8vg0n7R17KX7vRS0iEN7 zEqA== 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:dmarc-filter :arc-authentication-results; bh=A/SVSk+QznjKDN8saOqztItpIqs/wLJe7MFcWU7wt60=; b=fWhN98Ff03x+f+AizCUG2zBIGw+n7rMkyJ10bz9dyZyFAhwIYylpela1VjdDayDWzG PfM+Gd+hC+A3uSLkQBMiSmn8BnLZpHgbO8+27ZBSXQ1D2jAm+tkd2EL0NDPxFvGo08eb tePH+Fw+BsJmUOs0U8GhcaP2C7fiKK66LBdPjIoe/4PRTq7EodZM6oKqbnDlzOpIFnkh 70gj1Gv0orRdRSz4ujziboF75nrwCYw7PX16Ts9BdyGpMLklwSqF3+Tf2F86RWhQ0hNg SN8BOB+9FdXTLWGljanx46Vu+kROazgtu6TgOwG5+QLWZykyaTp6oZ0k1+Wio+xNgz/g KN5A== 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 z23-v6si1421781plo.597.2018.04.27.07.51.49; Fri, 27 Apr 2018 07:52:02 -0700 (PDT) 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 S934431AbeD0Oue (ORCPT + 99 others); Fri, 27 Apr 2018 10:50:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:53046 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934254AbeD0OHL (ORCPT ); Fri, 27 Apr 2018 10:07:11 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 DD2A621864; Fri, 27 Apr 2018 14:07:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD2A621864 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Subash Abhinov Kasiviswanathan , Sami Farin , Eric Dumazet , Soheil Hassas Yeganeh , Yuchung Cheng , Neal Cardwell Subject: [PATCH 4.14 33/80] tcp: clear tp->packets_out when purging write queue Date: Fri, 27 Apr 2018 15:58:26 +0200 Message-Id: <20180427135734.655295347@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135732.928644313@linuxfoundation.org> References: <20180427135732.928644313@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 Clear tp->packets_out when purging the write queue, otherwise tcp_rearm_rto() mistakenly assumes TCP write queue is not empty. This results in NULL pointer dereference. Also, remove the redundant `tp->packets_out = 0` from tcp_disconnect(), since tcp_disconnect() calls tcp_write_queue_purge(). Fixes: a27fd7a8ed38 (tcp: purge write queue upon RST) Reported-by: Subash Abhinov Kasiviswanathan Reported-by: Sami Farin Tested-by: Sami Farin Signed-off-by: Eric Dumazet Signed-off-by: Soheil Hassas Yeganeh Acked-by: Yuchung Cheng Acked-by: Neal Cardwell Signed-off-by: Greg Kroah-Hartman --- include/net/tcp.h | 1 + net/ipv4/tcp.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1616,6 +1616,7 @@ static inline void tcp_write_queue_purge sk_mem_reclaim(sk); tcp_clear_all_retrans_hints(tcp_sk(sk)); tcp_init_send_head(sk); + tcp_sk(sk)->packets_out = 0; } static inline struct sk_buff *tcp_write_queue_head(const struct sock *sk) --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2354,7 +2354,6 @@ int tcp_disconnect(struct sock *sk, int icsk->icsk_backoff = 0; tp->snd_cwnd = 2; icsk->icsk_probes_out = 0; - tp->packets_out = 0; tp->snd_ssthresh = TCP_INFINITE_SSTHRESH; tp->snd_cwnd_cnt = 0; tp->window_clamp = 0;