tcp_rcv_rtt_update() starts with sample << 3 in u32 arithmetic, so a sample of 536.9 s or more wraps. tcp_rcv_rtt_measure() can hand it one. Its sample is the time the sender took to fill one receive window, and a low rate flow can take longer than that. This caller only looks for a minimum, so the wrapped value is kept whenever it is below the current estimate. A 540 s sample ends up as an estimate of about 3.1 s. Clamp the sample to TCP_RTT_MAX_US in tcp_rcv_rtt_update(), like tcp_rtt_estimator() does on the send side. That covers both callers, and the smoothed estimate now tops out at 8 * 120 s, which fits in a u32. Found by code inspection (Eric Dumazet), who also suggested the fix. Confirmed with an LLM generated reproducer on an unmodified kernel, and tested with the reproducer and existing kernel selftests. Fixes: 645f4c6f2ebd ("tcp: switch rcv_rtt_est and rcvq_space to high resolution timestamps") Suggested-by: Eric Dumazet Signed-off-by: Chris Mason --- Notes: v1->v2: new patch (Eric), with min() instead of min_t() (David) net/ipv4/tcp_input.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 69e038b9389a..d9a66a1342ef 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -857,7 +857,11 @@ void tcp_initialize_rcv_mss(struct sock *sk) static void tcp_rcv_rtt_update(struct tcp_sock *tp, u32 sample, int win_dep) { u32 new_sample, old_sample = tp->rcv_rtt_est.rtt_us; - long m = sample << 3; + long m; + + /* Keep sample << 3 and the smoothed estimate within u32. */ + sample = min(sample, TCP_RTT_MAX_US); + m = sample << 3; if (old_sample == 0 || m < old_sample) { new_sample = m; -- 2.55.0