Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp335807pxb; Mon, 16 Aug 2021 06:35:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTJ1MXqfJrbeD+k4c4ZNWj6zlO2OQrMbcARaHHjpGEUBn4s4m3tmNJLhHH9VzBed31XaoV X-Received: by 2002:a02:698b:: with SMTP id e133mr15610368jac.125.1629120921481; Mon, 16 Aug 2021 06:35:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629120921; cv=none; d=google.com; s=arc-20160816; b=en+XfOCatE1neeTscmgmRNiqEfVdzXx4U2/liXcnkvu0TWY2J3JZCVhM+LF/dZQOOX CD657e+vReSiI9YMB1BWVo9BqbsB1hYrWM1e7chj+lkVU+v49yljClw7unqOnBmaB/DZ IJzFtJ9YHIvPZF46UuU+B6/H7MAez6JNj/BjYM9PIESrBQOqmxdqrRS61liVLdaT5Vrk Y5xP7OyUOEsqwoeBnzo6rPZc2NQE7jbzyU5i5Dddp3wCEQmLs+yqpBnrFxCzcn7b1I+3 3dC8QVI3uMxUUpmJES8jY9I3jCfYUTmhj7Uu4mACvPRBzKKvvLSO/r7iG4MbXYUUwsuW MzOw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2kjIx75AX1oXW0HGHVQZjuqVPOGmCNzYmGrmRhM1xqA=; b=0+/p6NeBYLRM5quwWQsVzAphq6TxLL2Qq1XQpPHAWwcaXQD1sMcYjyXXlpmoqTYXxD nv0MdCDXGt3ZiwgejbZZbjqILtaWepskM+QQZhxtzfl75F4yTab+lCkyyrYNa74CmgDZ N96bFNJ1pPHWAc7NVPenngPNtuGHYlcrpAIG3aEeDOgHOfv4NSVJQR2ksX7Cz0oMUqJq NS5rLUQPe0Jf/k++7d8fMrA/LYx5ecNwGAXs9usPtChEBeU3QS2L3O+4QXPIlJgpgNjs leAehfUlyrVjfP2uWqg19w2LpZWBnJJhdbn12gWTEbQcbab+462S/KVMIec0+E073Eba sTFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PxDKpUFt; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b4si11180013iln.32.2021.08.16.06.35.09; Mon, 16 Aug 2021 06:35:21 -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=@linuxfoundation.org header.s=korg header.b=PxDKpUFt; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240901AbhHPNbl (ORCPT + 99 others); Mon, 16 Aug 2021 09:31:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:43166 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236907AbhHPNSh (ORCPT ); Mon, 16 Aug 2021 09:18:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 32C086329F; Mon, 16 Aug 2021 13:14:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1629119647; bh=Rxqm1YAwNPqM3lUQa+7ZC894ANw1ofrWEJYCyh8AmFo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PxDKpUFtw2u6dU8/A/16Vpw7wSawcnOZw1W9Bcj9gRTHFkqWajwaF+cc4Y/UY3UMw ShSa3lnshBIYIQ9xmlq+6sZB9fpTlGLW1TLn0mxOanG3whEzTGdhtKpaGiVS3KyI5e 7fPSovLKAES26W7OQMnv3IR6rVUnQ8Dgh+zlTjtg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Neal Cardwell , Yuchung Cheng , Kevin Yang , Eric Dumazet , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.13 108/151] tcp_bbr: fix u32 wrap bug in round logic if bbr_init() called after 2B packets Date: Mon, 16 Aug 2021 15:02:18 +0200 Message-Id: <20210816125447.626180849@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210816125444.082226187@linuxfoundation.org> References: <20210816125444.082226187@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 6ea3dc2e4219..6274462b86b4 100644 --- a/net/ipv4/tcp_bbr.c +++ b/net/ipv4/tcp_bbr.c @@ -1041,7 +1041,7 @@ static void bbr_init(struct sock *sk) bbr->prior_cwnd = 0; tp->snd_ssthresh = TCP_INFINITE_SSTHRESH; 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