Received: by 10.192.165.148 with SMTP id m20csp765628imm; Fri, 27 Apr 2018 07:11:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr0Sn9R4t1c9AXB5G+OBnuSSO0rSQ7MJo8JNHerz5CRYfX4OW3JObTfb8vp5Y9IMoQ4Wlgm X-Received: by 2002:a65:428b:: with SMTP id j11-v6mr2281635pgp.370.1524838309326; Fri, 27 Apr 2018 07:11:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524838309; cv=none; d=google.com; s=arc-20160816; b=GSkSIG5paAUO0HigJdn/0R0np/ndH93PHiDuSjM7ThWlhVIsqBMheeo10DtbC1eYa+ HWxnGV/fJFz67IWwqkuTz1KfMKtrX6JxVHgLa2KfEwU4kMXeAiR20QGfPylF1CTnTaE8 c6TFRlkPNYtilUomuDanb2925JTbcQo5Kwm9By6XNH1ZCnHCIZV/B16BuPBV50VgIP/k GCkxSH0X7BJxJ8sFGnTmJN6tulM5FqXxHepwly+W6k33OgMmJlgg6KamhOAERXdbcafk kn6xpbPk2IBGbnr0bNhRm9LyVUr/Iw0tRFVUkHyzktZ9gTdxpDEzd8rGe5CrpVmEd/VC jAzg== 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=4r0ULE0gHzScBRotC8nnCc+Zub5ut6B1bY2eMMC26bk=; b=Thi4HsiCmW43I+bXSwyhslo+tann4ABoHWW7SJ608YgUgQPCY5ehDxfG3LX/FBNxIX 6KAHcNe79mzW3TZHasSQwzUpR8DDDMWdOyj1Ov9vXq29UjyyuK+a/ImJ17YOEH142pTy OAXPW5h/TgM0+0C98OaO+CbafO+IduZ/IXCJQG6eBJwaUvoVlhxhV6vHGajbHcXdG5ms NotlYplJqxYg8MhV+csmO2Hok7fFurkx1rv+cAbAwkqC6y5NoHpB9kd+6GrnBW4600xk 3JjiPx4E86Fv3xqg9GtJ68aud8bKCWwzOzQOPvd7CXjNkWPQ/p4S6v9g/QhRIkv5ZLyH fxTw== 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 o186-v6si1275505pga.350.2018.04.27.07.11.35; Fri, 27 Apr 2018 07:11:49 -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 S934857AbeD0OKc (ORCPT + 99 others); Fri, 27 Apr 2018 10:10:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:55542 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934799AbeD0OK0 (ORCPT ); Fri, 27 Apr 2018 10:10:26 -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 37B7B21864; Fri, 27 Apr 2018 14:10:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37B7B21864 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 , "David S. Miller" Subject: [PATCH 4.16 27/81] tcp: clear tp->packets_out when purging write queue Date: Fri, 27 Apr 2018 15:58:29 +0200 Message-Id: <20180427135744.708942422@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135743.216853156@linuxfoundation.org> References: <20180427135743.216853156@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.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Soheil Hassas Yeganeh [ Upstream commit bffd168c3fc5cc7d2bad4c668fa90e7a9010db4b ] 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: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2385,6 +2385,7 @@ void tcp_write_queue_purge(struct sock * INIT_LIST_HEAD(&tcp_sk(sk)->tsorted_sent_queue); sk_mem_reclaim(sk); tcp_clear_all_retrans_hints(tcp_sk(sk)); + tcp_sk(sk)->packets_out = 0; } int tcp_disconnect(struct sock *sk, int flags) @@ -2434,7 +2435,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;