Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp14022574ybl; Mon, 30 Dec 2019 02:33:15 -0800 (PST) X-Google-Smtp-Source: APXvYqwKh3NkZ79vnyi3TtvzSkS9mR637sp5C5liaQRRUUQUvp0wzvcQfD1xgfDSbTWOC9/3Gwzb X-Received: by 2002:a9d:6f0a:: with SMTP id n10mr75893182otq.54.1577701995193; Mon, 30 Dec 2019 02:33:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577701995; cv=none; d=google.com; s=arc-20160816; b=cEfvorL3TWBwPt5Dl5/3VRo06UG41A6gBCMHc54X5+pURB51L7nekbBUbGy7YydJX0 yvwsd3sTFiHfM1YkUMLXtyEUFNVDuitTxe88LLZCzJ6sUZNqxKS/uNgo1gEOCf4Kph9L Aab0JoAuNwfy6plZEQRn4+oSNW9c21c5sDnLcqVLQtWqMhM1CTLow0ZCNnSEIwLhgtZN htdgdhHHn0NtB5B3yvQpCXhw6qIAKswj9PUVFySHKP2OoXc/8LIbwAajTHFCdFrHPanK D5f1S5JZIWfsiDWutS052JLQbgq8AJyi9f9qobCgxO1rPl6wmyoi58flZsym66qJD0Pf kRBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=Ljvel8MOOaqhyxfRrt4QkAGDQgHLWHj7evK7siBvygY=; b=bTa9dfj55wAxPvX2oBBUgo1gmvYCuThbMqOUXGIvw89hYMy7RnwxerDou1Zhs0eiQu 6E3kAy2+jxpKX3aaGNjdKeMOSPwCildXXtmowMlrU6/kOEr+OH/vWdcL103nOWO3qXX1 RXq1vGBg8ZJPVdRoObd/ulKDcjq9meJMln6+HY6Q+2aNeHQ6R7XcYKFJEBmxDcLuhi1R KUSLjZ1nHXXmXBCLT556c7jNxUlzOZH2ut67VFgpR/UL6jnQb3hBTUY8qGxnb26GsG9/ c8h4cWrgPeWQLw8UC95hPAcVeoWZVt1m45G/vM/Iw7gGzK+TswHn3v7ZYi5TBy6w7ist 51YA== 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 j24si19975533otk.76.2019.12.30.02.33.04; Mon, 30 Dec 2019 02:33:15 -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 S1727448AbfL3Kc1 (ORCPT + 99 others); Mon, 30 Dec 2019 05:32:27 -0500 Received: from mail.wangsu.com ([123.103.51.227]:41779 "EHLO wangsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726196AbfL3Kc1 (ORCPT ); Mon, 30 Dec 2019 05:32:27 -0500 X-Greylist: delayed 2179 seconds by postgrey-1.27 at vger.kernel.org; Mon, 30 Dec 2019 05:32:23 EST Received: from 137.localdomain (unknown [59.61.78.232]) by app2 (Coremail) with SMTP id 4zNnewBnR8yiyQledHAHAA--.7S2; Mon, 30 Dec 2019 17:55:47 +0800 (CST) From: Pengcheng Yang To: edumazet@google.com Cc: davem@davemloft.net, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, ast@kernel.org, daniel@iogearbox.net, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, andriin@fb.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Pengcheng Yang Subject: [PATCH] tcp: fix "old stuff" D-SACK causing SACK to be treated as D-SACK Date: Mon, 30 Dec 2019 17:54:41 +0800 Message-Id: <1577699681-14748-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6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJb IYCTnIWIevJa73UjIFyTuYvjfU4gAwDUUUU X-CM-SenderInfo: p1dqw1nf6zt0xjvxhudrp/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When we receive a D-SACK, where the sequence number satisfies: undo_marker <= start_seq < end_seq <= prior_snd_una we consider this is a valid D-SACK and tcp_is_sackblock_valid() returns true, then this D-SACK is discarded as "old stuff", but the variable first_sack_index is not marked as negative in tcp_sacktag_write_queue(). If this D-SACK also carries a SACK that needs to be processed (for example, the previous SACK segment was lost), this SACK will be treated as a D-SACK in the following processing of tcp_sacktag_write_queue(), which will eventually lead to incorrect updates of undo_retrans and reordering. Fixes: fd6dad616d4f ("[TCP]: Earlier SACK block verification & simplify access to them") Signed-off-by: Pengcheng Yang --- net/ipv4/tcp_input.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 88b987c..0238b55 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -1727,8 +1727,11 @@ static int tcp_sack_cache_ok(const struct tcp_sock *tp, const struct tcp_sack_bl } /* Ignore very old stuff early */ - if (!after(sp[used_sacks].end_seq, prior_snd_una)) + if (!after(sp[used_sacks].end_seq, prior_snd_una)) { + if (i == 0) + first_sack_index = -1; continue; + } used_sacks++; } -- 1.8.0