Article View: linux.kernel.netdev
Article #18526Re: [PATCH net 1/3] tcp: don't let __tcp_set_rto() return 0
From: David Laight
Date: Wed, 18 Nov 2026 13:33
Date: Wed, 18 Nov 2026 13:33
68 lines
13556 bytes
13556 bytes
On Tue, 17 Nov 2026 19:50:49 -0500
Chris Mason <mason@kernel.org> wrote:
> __tcp_set_rto() computes the RTO as (srtt_us >> 3) + rttvar_us, in u32
> arithmetic and with no lower bound. A comment in tcp_set_rto() says that
> the algorithm guarantees an RTO above TCP_RTO_MIN. But tcp_rto_min() is
> only applied to rttvar_us, so that guarantee is lost if the sum wraps.
>
> tcp_retransmit_timer() backs off by doubling icsk_rto, so the backoff
> only works if icsk_rto is nonzero.
>
> Of the three callers, only the thin-stream branch of
> tcp_retransmit_timer() clamps the result. tcp_set_rto() and
> tcp_ld_RTO_revert() store it in icsk_rto with an upper bound only.
>
> The fix used here is to keep the result of __tcp_set_rto() from 0, for
> all of its callers, so that the backoff recovers from any state of the
> RTT estimator.
>
> Found by LLM code inspection, and confirmed with LLM generated
> reproducers on an unmodified kernel. Fixed by LLM, and tested with
> the reproducers and existing kernel selftests.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Chris Mason <mason@kernel.org>
> ---
> include/net/tcp.h | 4 +++-
> net/ipv4/tcp_input.c | 5 +++--
> 2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/include/net/tcp.h b/include/net/tcp.h
> index 5c9203aae834..6a714189bcc7 100644
> --- a/include/net/tcp.h
> +++ b/include/net/tcp.h
> @@ -910,7 +910,9 @@ static inline void tcp_bound_rto(struct sock *sk)
>
> static inline u32 __tcp_set_rto(const struct tcp_sock *tp)
> {
> - return usecs_to_jiffies((tp->srtt_us >> 3) + tp->rttvar_us);
> + u32 rto = usecs_to_jiffies((tp->srtt_us >> 3) + tp->rttvar_us);
> +
> + return max(rto, 1U);
return rto ?: 1;
is possibly more readable?
David
> }
>
> static inline unsigned long tcp_reqsk_timeout(struct request_sock *req)
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index a2074a1af422..f65697bc96c9 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -1221,8 +1221,9 @@ void tcp_set_rto(struct sock *sk)
> * with correct one. It is exactly, which we pretend to do.
> */
>
> - /* NOTE: clamping at TCP_RTO_MIN is not required, current algo
> - * guarantees that rto is higher.
> + /* NOTE: clamping at tcp_rto_min() is not required, tcp_rtt_estimator()
> + * applies it to rttvar_us. But rto must never be 0, which exponential
> + * backoff could not leave: __tcp_set_rto() takes care of that.
> */
> tcp_bound_rto(sk);
> }
Technical Details
Message-ID:
<20261118133310.6a2c48da@pumpkin>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366140-linux-kernel-netdev=dewy.ruReferences:
<20261118005048.53393-1-mason@kernel.org> <20261118005048.53393-2-mason@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366140-linux-kernel-netdev=dewy.ru
From: david.laight.linux@gmail.com (David Laight)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 1/3] tcp: don't let __tcp_set_rto() return 0
Date: Wed, 18 Nov 2026 13:33:10 +0000
Organization: Usenet Network
Message-ID: <20261118133310.6a2c48da@pumpkin>
References: <20261118005048.53393-1-mason@kernel.org>
<20261118005048.53393-2-mason@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
logging-data="2605030"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:cYigmPdANBlqUvszS4oYj8LabUc= sha256:0D4sgtSQqBkJFppKEkbrVP4VXDECGvvxrcpNatR2MRA=
sha1:1M5LF4S4urBdSPTWuVekxjVGHbs= sha256:N6Q3NSgRYoV6fwLMdYzviFwlfj1BB1EUzZ4vKY7yZjs=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 8EE951152AC; Wed, 18 Nov 2026 16:33:32 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id TgM1zwOYEUX5;
Wed, 18 Nov 2026 16:33:29 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-366140-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 3A08A115224; Wed, 18 Nov 2026 16:33:19 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id BC7982E513; Wed, 18 Nov 2026 13:33:14 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1795008794;
b=feHVgTr+CNvE07Cst7JdU3gSLJAA1h58F1ABThS4sVbDOyv101u1geSOgBDTMD4dy8xq
iEZnko2AD4fB6XKhTPHEbxJEgmBWAG1S/4/QvIXfgrsm69F7dAxwvu8U/TTgddW8fwEgR
YzxfsYRZmqOvFehQHbDtrAJPshd0LvaLMo5ud7IyAwT3JFBTM1ZJXpGKXt3odcL7GqDW1
ZMgGiSkVPniu7E0H1WJBSAQJPqhMYswW2TMp2hSm8jlhBe8+8xXfKAH+zyJqfqWgbBjkT
cvKzSg9Dj5UF3bFwbac3QK7KZUO3KY3YJpeBNhCtIENNURQKYbLOkWcW8skNMC/i2jA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795008794;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:Date:From:To:Cc:Subject:Message-ID:
In-Reply-To:References:X-Mailer:X-Mailing-List:List-Id:List-Post:
List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
MIME-Version:Content-Type:Content-Transfer-Encoding;
bh=CytpeUZs4e21yI0gXA+XVzgHbacfvLr71yrchjS5I0k=;
b=lAk+juJPYHChHe1/FwA4GvfXzYc8D3IRgxxhXySczo0ZwGbpuo+nzifm+xGtknMPbNCD
zaZE4BkyeuhglSx3pKg/UFHJap/C1twDf63VWGhS0NnrwTwDL+bMJo2IjoYI5CDdtg0ew
LqIr1UHFzhUNGaStC1aFiLX47bCNtj8H175aa5duQw9kX+6Cmwdrv4VFUJLg77nFu7lfo
QM3GnGPcl6fxEdbK9o9QK4L8jc3BA20EHiGb/OKyS+yRdBH7u9Sym7kW1srR4aTYnB2gL
IYFzJTLyqDVuHqzsQgQ0/1eHFIexQuj3X2G9mNbnObII5S0jJ+Xr2CRr1VHn2+DgCsQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=yFXCR9oN;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C836606A331;
Wed, 18 Nov 2026 13:33:14 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=yFXCR9oN
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.54
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795008793;
b=FtkDdPcpC5smCMf8sPHAD4/Pn1O01eE1t57AorId0xF9wkQpLWk9PlBL2IpVIB70cMbQ
UyLrX/SC6ZM6dHfsOXZXJvXRTqhTEF7n0vP3m0dsdd3SExCbWBq/sE1v7w+8gkO99DbIc
vB8cr8oPVgNQ2LTNebFFSTsR34bCJCqzwGERe7lkT/Am8f4d0sFgkEEJe+/894ENtecqr
+eynixhDdooaSzdFjrW80ow9oJenKwbtE64tkclXybeds0Y2Ah94+ZUqJ//LBr4+nRRoZ
p6KIDfi7i4DC9O65/efGf8PQND9rAzt8ibrTGXX6cKXne2WU93d3/v3Qe/0UqudvKJQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795008793;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References:X-Mailer:
MIME-Version:Content-Type:Content-Transfer-Encoding;
bh=CytpeUZs4e21yI0gXA+XVzgHbacfvLr71yrchjS5I0k=;
b=nV6ZYmYYIJct0aV0jbslR7VxBshLjnQrb1WV9oDwKq0nn6dmkoJe5iRTtEBrZWD2qHTx
dy18AV5X0yk5ndAe4psop5O26kl5JVyIVyrDvsGiQydI11kAwbO2oag/Un57XDQWgVwHW
DOlQCW8NfYUnBfWBJtgAi/ZjrE74/+2A6fRqm5u7XLDJlmGfajuamIcWnPagtagRj0GJx
B6JKHSTMFSYW+pftZAIacOUQza0+gfRMg38DDnxIjOmFmSTFqA6SN9p+8ESRPhbGwijbj
NOhC78Jeqx3qmWhuF/h7NXbW+YlZHHjXh3ZObh2qP7lvBdZeFkBIaWuIgzlE1TMF3mw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=yFXCR9oN;
arc=none smtp.remote-ip=209.85.221.54
X-Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 332A2606A320
for <netdev@vger.kernel.org>; Wed, 18 Nov 2026 13:33:13 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 332A2606A320
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-490d59c3f0aso419009f8f.1
for <netdev@vger.kernel.org>; Wed, 18 Nov 2026 05:33:12 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1795008791; x=1795613591; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:mime-version:references
:in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject
:date:message-id:reply-to:content-type;
bh=CytpeUZs4e21yI0gXA+XVzgHbacfvLr71yrchjS5I0k=;
b=yFXCR9oNXVv+lnnkDUmClHvyECFFTuJFCcboh8u9kWHS+AC5OmehC8Yr4WcbTepXcm
/2pKvU1Mipv3NG6R4DMUcpkvQXBKYYktARVXDX0QDT5gg8L3X5VP8/1GBb+1Zy9ByI1d
lgdKjoGf+PVkwLNcl2axynHOTuxFuEU3tn//7d4ALqBHtupVZ0t/uvgara1iMNCf1YWt
3ED7jCnvXKPXxgQBDi1gZjuztSypdIBnACIgHzGdD3fmC4rX6I2zQnLvKY0JBmjV8HW9
MSHPKonJcWBTCEorDb0QpgQzSakYZKdSn9cI6xdo0lB5xQwvPpmISlr+DKXS42C5JV8T
bjDA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1795008791; x=1795613591;
h=content-transfer-encoding:content-type:mime-version:references
:in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=CytpeUZs4e21yI0gXA+XVzgHbacfvLr71yrchjS5I0k=;
b=H4jQu+mUZ9/It4EWd8v7LUyurJgGi/vHT1Uc9uHEsWqqkoQ4i00KJKXjGh736l5404
KpWv48fh2mzZ969HSOHajdepuTfpjwRczV9p4Fz//Zb/IxRsHjPOPb2jcMvpq2SKWsD1
nxp+IaZc3pRozrY32Wo+4KdDWO8WjLTPw9fWwbP+wfn6W6zTA78wihj1J3rB43RXV0XC
BOgAkoe9V4MA1/vaO/Crz304NLusu/nvegby4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-4a63ecb5478mr5254932f8f.57.1795008791326;
Wed, 18 Nov 2026 05:33:11 -0800 (PST)
X-Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36])
by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4a654997681sm3870877f8f.15.2026.11.18.05.33.10
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Wed, 18 Nov 2026 05:33:11 -0800 (PST)
X-Cc: edumazet@kernel.org, ncardwell@google.com, kuniyu@google.com,
davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
willemb@google.com, josef@toxicpanda.com, netdev@vger.kernel.org
X-In-Reply-To: <20261118005048.53393-2-mason@kernel.org>
X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf)
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list