Netdev List
 help / color / mirror / Atom feed
From: Chris Mason <mason@kernel.org>
To: mason@kernel.org, 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
Subject: [PATCH net v2 5/5] tcp: bound the rto_min of a route in tcp_rto_min()
Date: Wed, 18 Nov 2026 10:51:49 -0500	[thread overview]
Message-ID: <20261118155144.18393-6-mason@kernel.org> (raw)
In-Reply-To: <20261118155144.18393-1-mason@kernel.org>

For a route with a locked RTAX_RTO_MIN, tcp_rto_min() returns the metric
as it is, and that can be any 32-bit number of milliseconds. All other
ways to set the minimum RTO have a nonzero floor: the tcp_rto_min_us
sysctl, TCP_RTO_MIN_US and TCP_BPF_RTO_MIN.

Both ends of that range give us trouble.

With an rto_min of 0, tcp_init_metrics() can start a connection with an
RTO of 0, if the cached RTT is below one jiffy:

    icsk_rto = crtt + max(2 * crtt, tcp_rto_min(sk)) = 0

It sets icsk_rto itself, so the lower bound in __tcp_set_rto() does not
help here.

At the other end, tcp_rto_min_us() and the sum in __tcp_set_rto() are
u32 values in usec, so an rto_min of more than about 71 minutes does not
fit.

Clamp a locked rto_min to the range from one jiffy to TCP_RTO_MAX in
tcp_rto_min().

ip_metrics_convert() could reject these values instead, as it does for a
locked cwnd of 0. But a route with "rto_min lock 0" is accepted today
and mostly works, so that would break existing setups.

A route still shows the rto_min that it was given, while TCP uses one
jiffy or 120 s.

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: 05bb1fad1cde ("[TCP]: Allow minimum RTO to be configurable via routing metrics.")
Signed-off-by: Chris Mason <mason@kernel.org>
---

Notes:
    v1->v2: new patch

 include/net/tcp.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index a617a72ee2c6..27de546dc802 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -939,7 +939,8 @@ static inline u32 tcp_rto_min(const struct sock *sk)
 	u32 rto_min = READ_ONCE(inet_csk(sk)->icsk_rto_min);
 
 	if (dst && dst_metric_locked(dst, RTAX_RTO_MIN))
-		rto_min = dst_metric_rtt(dst, RTAX_RTO_MIN);
+		rto_min = clamp(dst_metric_rtt(dst, RTAX_RTO_MIN),
+				1, TCP_RTO_MAX);
 	return rto_min;
 }
 
-- 
2.55.0


  parent reply	other threads:[~2026-11-18 15:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 15:51 [PATCH net v2 0/5] tcp: avoid integer wraps in the RTT estimator and the RTO Chris Mason
2026-11-18 15:51 ` [PATCH net v2 1/5] tcp: don't let __tcp_set_rto() return 0 Chris Mason
2026-11-18 15:51 ` [PATCH net v2 2/5] tcp: clamp RTT samples in tcp_rtt_estimator() Chris Mason
2026-11-18 15:51 ` [PATCH net v2 3/5] tcp: reject RTT samples from TSecr above 120 s Chris Mason
2026-11-18 15:51 ` [PATCH net v2 4/5] tcp: clamp the samples in tcp_rcv_rtt_update() Chris Mason
2026-11-18 16:34   ` Eric Dumazet
2026-11-18 15:51 ` Chris Mason [this message]
2026-11-18 16:33   ` [PATCH net v2 5/5] tcp: bound the rto_min of a route in tcp_rto_min() Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261118155144.18393-6-mason@kernel.org \
    --to=mason@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=josef@toxicpanda.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox