Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2920244pxb; Tue, 24 Aug 2021 10:37:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbByuMbYRPO+oS0Dw+drm2dsSLacAwwjiqom0swS4umxWsWJ7SqMTrcXKl4Kwyrzq294eF X-Received: by 2002:a5d:898f:: with SMTP id m15mr32376731iol.188.1629826635967; Tue, 24 Aug 2021 10:37:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629826635; cv=none; d=google.com; s=arc-20160816; b=G6t3+bEudiRTg3VRgrI3RYboxwW6HocEk9deBsjwelDLQC/CjapNQhRAR6KrYYjoPm eJU2Do5B0FgE0G5qjl5cUS+w3P49JwgcbjDOtlaA9ePs1I3P/RQ2o2k2cwS9kWg+DMzi eK8hM4rrbRzGNJ9HFZDcSmrgbw9H2ni2vsv+MxlSlnBqnrFmWZDosLogbzhPwWWvjz4e mgLe0zxEHqNnXAHGPtQlJoc97jNxQCIriBpwhsHAHinEktpQhJjpzDl9oBPkw5JpPN+u oQdGWIkE8VuCeBlTLoTdqxJVFqY37Q6s4LXa+QZGyrtPF/tV/T2Xl7DvoYQdA/P4fFN8 RFhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wrtF7ZhC7074DLEj1YOmfPo173Czqd8RP7LTYxqvvvc=; b=F+DgqxjimVtM9nqv5rVjsoZ+KgmBubxoxJ4cVToW1uDgnIJ+u69D0Xcdf5dBMmr7Yk Uxmth16Sl6FblkALlXLLWBvwyYBLomhzdMxNNOivnECktDFdS+XRE8nwmeOd6n1+nW+C nc7goFDBUR3YCcHAwKLXVHJ0+RomHuw/4hz9ai9SuXbY4hcRbRj4qW0tA2l0jeg2rdkd Wg4w85XchKFtzxXNuL9WW7U8nfS4qlHKqRSXiY78nrIWZelSSZU7JDoKrdWtTQ5n2ZmG /AR1MVFvoSMR7CO4bjJFyOMIHs+xdWeMSQODDOjlIaaB5pTUuJcDHw4xc/HFxs3Hhj4Z rFdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YKUerqAd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si18339324ilg.98.2021.08.24.10.37.04; Tue, 24 Aug 2021 10:37:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YKUerqAd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242073AbhHXRhG (ORCPT + 99 others); Tue, 24 Aug 2021 13:37:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:39356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241716AbhHXRdW (ORCPT ); Tue, 24 Aug 2021 13:33:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3BF5361929; Tue, 24 Aug 2021 17:06:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824785; bh=xQYOYtWnvg5VIRgtwEIALnkaOWqwNtABEPKbzxj3BZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YKUerqAdy9wNchrkmCvdRFU+hEadId3DXlmlFVGZPy84Am88Qh7jhCy1U89j7mom5 Q+xQleMlGDr5fKJDBDU0Kel2h8z6NAIfzfSAuS/b4ywKdOrZtdycogzX7gVJgED4Ir 3890WSE4FE3Rp8dcu5hplWtUqWnfg5EbkrNzy5S3bJx53RzKMfZStLlj+m+5mUvOeb oT6IpMCbvXoDpLRsF2xp+TnZtDiyrm0zLUKUx+VQuy0DRMpiJ7L6UePgkVNigZ8yyi Y8tRNMGFKqdMK0K6ogmhXPWRdRjj6kHgxTvYXxMR3XyS8vkZUly8aCvJ/DtLguUy7x HNaBk4FvEke3g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Neal Cardwell , Yuchung Cheng , Kevin Yang , Eric Dumazet , Jakub Kicinski , Sasha Levin Subject: [PATCH 4.9 08/43] tcp_bbr: fix u32 wrap bug in round logic if bbr_init() called after 2B packets Date: Tue, 24 Aug 2021 13:05:39 -0400 Message-Id: <20210824170614.710813-9-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824170614.710813-1-sashal@kernel.org> References: <20210824170614.710813-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.281-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.9.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.9.281-rc1 X-KernelTest-Deadline: 2021-08-26T17:06+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Neal Cardwell [ Upstream commit 6de035fec045f8ae5ee5f3a02373a18b939e91fb ] Currently if BBR congestion control is initialized after more than 2B packets have been delivered, depending on the phase of the tp->delivered counter the tracking of BBR round trips can get stuck. The bug arises because if tp->delivered is between 2^31 and 2^32 at the time the BBR congestion control module is initialized, then the initialization of bbr->next_rtt_delivered to 0 will cause the logic to believe that the end of the round trip is still billions of packets in the future. More specifically, the following check will fail repeatedly: !before(rs->prior_delivered, bbr->next_rtt_delivered) and thus the connection will take up to 2B packets delivered before that check will pass and the connection will set: bbr->round_start = 1; This could cause many mechanisms in BBR to fail to trigger, for example bbr_check_full_bw_reached() would likely never exit STARTUP. This bug is 5 years old and has not been observed, and as a practical matter this would likely rarely trigger, since it would require transferring at least 2B packets, or likely more than 3 terabytes of data, before switching congestion control algorithms to BBR. This patch is a stable candidate for kernels as far back as v4.9, when tcp_bbr.c was added. Fixes: 0f8782ea1497 ("tcp_bbr: add BBR congestion control") Signed-off-by: Neal Cardwell Reviewed-by: Yuchung Cheng Reviewed-by: Kevin Yang Reviewed-by: Eric Dumazet Link: https://lore.kernel.org/r/20210811024056.235161-1-ncardwell@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv4/tcp_bbr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c index c22da42376fe..47f40e105044 100644 --- a/net/ipv4/tcp_bbr.c +++ b/net/ipv4/tcp_bbr.c @@ -811,7 +811,7 @@ static void bbr_init(struct sock *sk) bbr->prior_cwnd = 0; bbr->tso_segs_goal = 0; /* default segs per skb until first ACK */ bbr->rtt_cnt = 0; - bbr->next_rtt_delivered = 0; + bbr->next_rtt_delivered = tp->delivered; bbr->prev_ca_state = TCP_CA_Open; bbr->packet_conservation = 0; -- 2.30.2