Article View: linux.kernel.netdev
Article #26576[PATCH net] tcp: clamp the u64 delta in tcp_rcv_rtt_measure()
From: "Chris Mason"
Date: Thu, 03 Dec 2026 20:45
Date: Thu, 03 Dec 2026 20:45
41 lines
10875 bytes
10875 bytes
TCP autotuning can leave the receive buffer too small if the sender
takes more than 71 minutes to fill a receive window.
tcp_rcv_rtt_measure() uses that time as an RTT sample, but truncates it
to u32 before tcp_rcv_rtt_update() clamps it:
tcp_mstamp - rcv_rtt_est.time = 4295000000 us
(u32)4295000000 = 32704 us
min(32704, TCP_RTT_MAX_US) = 32704 us
Without TCP timestamps, autotuning keeps the smallest sample as its RTT
estimate for the rest of the connection.
The fix used here is to clamp the sample while it is still a u64.
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: 645f4c6f2ebd ("tcp: switch rcv_rtt_est and rcvq_space to high resolution timestamps")
Signed-off-by: Chris Mason <mason@kernel.org>
---
net/ipv4/tcp_input.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 50c0da17923e4..0bbb0ed71469b 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -895,7 +895,7 @@ static inline void tcp_rcv_rtt_measure(struct tcp_sock *tp)
goto new_measure;
if (before(tp->rcv_nxt, tp->rcv_rtt_est.seq))
return;
- delta_us = tcp_stamp_us_delta(tp->tcp_mstamp, tp->rcv_rtt_est.time);
+ delta_us = min(tp->tcp_mstamp - tp->rcv_rtt_est.time, TCP_RTT_MAX_US);
if (!delta_us)
delta_us = 1;
tcp_rcv_rtt_update(tp, delta_us, 1);
--
2.56.0
Technical Details
Message-ID:
<20261203202930.14580-1-mason@kernel.org>Path:
mbox-mo1.pugleaf.net!news-ams.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376851-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-ams.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376851-linux-kernel-netdev=dewy.ru
From: mason@kernel.org ("Chris Mason")
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] tcp: clamp the u64 delta in tcp_rcv_rtt_measure()
Date: Thu, 03 Dec 2026 15:45:36 -0500
Organization: Usenet Network
Message-ID: <20261203202930.14580-1-mason@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
logging-data="2591811"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:f8k+RM3fXR/iPVSueG4Fze/21tA= sha256:3ZbGokmCefWhR4i/ERIZFHyCl/ZV4KUFxt5We6YbDe0=
sha1:U0fL4QK5CelVrKlQ+o615QJzGoU= sha256:NpbRMnSGGZqGXLh63CG1QX1htMw4R7ZVfDZ7eCMyTXA=
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 485E5117A2F; Thu, 3 Dec 2026 23:46:14 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.64
X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1,
DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
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=kernel.org
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 CeXhfx6Uj367;
Thu, 3 Dec 2026 23:46:12 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376851-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 9B687117A29; Thu, 3 Dec 2026 23:46:02 +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 40C9827864; Thu, 3 Dec 2026 20:45:59 +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=1796330759;
b=sD7iv43z5dv6yY8IvfjmOtfppz6gtQFq/somVpW27p7elWN/QE5BlxM/3zI3gmYJ6Ge0
0emLLI68VnOcek+euCOsd9tgQSILtDXdIxJtP+DzksDkoH3U1YsJkD5T1gAj3PyGzTc4t
PcAOr0BvMmt7IrGhjE3kJ5q1tnx3pzRHIk2h3Rimdt4WW1t244CrJRYeNSuP7QTBme4sQ
KknWxvegYOOOgStX3pEWhVfQ6PJWuabwY7wnD9oL6YQc6RcoUMQ521gMsA/8sYkqrK1AI
UANuHoYtNWvaEa8MqxPIsvQjrLgW2T6xaWVBiSHrHHIupohdz09R63ODfSq2CnAt5+w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796330759;
h=X-Original-To:Received:Received:DKIM-Signature:Received:Received:
X-ME-Sender:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:Received:X-Mailer:
X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:X-ThreadId:Date:
From:To:Message-Id:Subject:Content-Type:Content-Transfer-Encoding;
bh=FyH31y5ZmkdbUBySI/CPEhIq2Go5W50/GMg29glNJO8=;
b=KZ4EgwOUKBEv9Oa2VpOUo7PlTvmJ+C/vI86lzrzk605s3PI6qqLVCxYTz0BHyGhkdYxL
l/j7Zw3hAy2YmTSlV5vzNrwlr+GT4BYh5RBy3z08uZ6nBBPAzZuRzpuWkAScIQgm6q0Im
BFeZtiOPiEFVwLLKDw7wAlml1776sIKTpV7u3UM4+hBTxghqJFN0jn4tUEIwmAGxrqT/2
B2nVT+5spmzpfyQ2uT4+OZtLCf03lidn3O6tPkPiYFC+eg9m4OkSklXBPO97ZJx0+dt3S
RsQJFEMYEpT6CAjxzBZipKcKIV3NXS9FtaCcKUw1URLryctMa4iiwoCPXqgMg6VXlQQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="D2/sJA/9";
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 137C1606A333;
Thu, 3 Dec 2026 20:45:59 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=D2/sJA/9
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796330758;
b=Cfp6+Q6IQXH1nz59RUw0/iGWUgWmeQ9BY2klL0Q3+8JVwJRmWiOxej4JbH7sbx5BBrpi
PKqd46iURjBPMqewmUIqYa3Ujt0YcNjCCVxlDC+Si0zzjgpLW72ROXxHewjygMq+ED5H2
jm0SCHZEsdgzwpb9Ixb0yUuA2e+m/o51JaLdum/eUfvyZii2fk4wm49WV3ELnqSW/okzO
6MYAUnDHkm82j3US/6MEfwMnWMCHnGzVRaXtpElf/mF+KrPfzEbfj964RzLm7BP5W+6Xn
AuTQSh5sN+spZdnTTcaTZg7z/Hl1UeWM/ZRWy9IF/VmPvertpPre9RNmlq+tpqWR4kg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796330758;
h=Received:DKIM-Signature:Received:Received:X-ME-Sender:
X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:Received:X-Mailer:
MIME-Version:X-ThreadId:Date:From:To:Message-Id:Subject:Content-Type:
Content-Transfer-Encoding;
bh=FyH31y5ZmkdbUBySI/CPEhIq2Go5W50/GMg29glNJO8=;
b=bkJfvZeYLmsSWokK1Ru2nV1kmrs07atlBSKdwMNdq7n590HDCgWumGlAXE2TaoUoaqY8
dS4qqzCW81KORulebqlqZu54vAlVr9xKL++aTRxXKXRjBt4yipNvFQU6L2toY1KFE2YFm
/qIr4e22r4uTeG3UvgEo2HShpJMg4DtqVnBeS/uVxLT9xftkwX8+iHbWJQZOMjvXuBlWV
BNSQvZwrrDoXPTKmdrXx9jFDgHnKwojS4epBYad9TmMgJxBxi6VfT3MPuJEuRvu4S9R1j
OFOGtCGotjvGtjRS25C1VViqL9QbQTBPEK05Nl0pA/K9MsR1SIY3SM/CAG5vhIpL/JQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="D2/sJA/9";
arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature ECDSA (prime256v1))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EA7D606A322
for <netdev@vger.kernel.org>; Thu, 3 Dec 2026 20:45:57 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 584EF1F0092B;
Thu, 3 Dec 2026 20:45:57 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
s=k20260515; t=1796330757;
bh=FyH31y5ZmkdbUBySI/CPEhIq2Go5W50/GMg29glNJO8=;
h=Date:From:To:Subject;
b=D2/sJA/94Pc5k/g1Preor++dtNfhjrHEF8liTBMo1dMT1efK3S2BApGpRG2Sng7rw
F1nS1A61zdBS1sXHwMV5y0zFatNdOlKfgyWdGbutbko7EgTan26OxaIbwacByu8T+Z
6lrtVRiSo7xFH37D38K2EhkdVh21BVEkIX+X44VL6H9iodEg/yIrS3NnohoqFG7m7p
MDVr+rhNGM10CC+I9dA0buXssZVsrN+AaZPF7ACFHxtuq0kONuqUQG/VECb8Uxpnjz
O/gEBNzkrQfleqVAznRzEO8WTTsVohwO0axuCnqPmUuv4AxhTeJ+LloIeFp2o9gqiE
u7LcwrVdQUGLw==
X-Received: from stl-compute-04.internal (stl-compute-04.internal [10.204.2.64])
by mailfauth.stl.internal (Postfix) with ESMTP id 94113780043;
Thu, 3 Dec 2026 15:45:56 -0500 (EST)
X-Received: from stl-imap-13 ([10.204.2.104])
by stl-compute-04.internal (MEProxy); Thu, 03 Dec 2026 15:45:56 -0500
X-ME-Sender: <xms:BNURa8xUeYVpmAYzDwQQfY9pCdLK1VRJXE2x9msyNsbbNs9L6rsW-Q>
<xme:BNURa7E2d8bb7y8wmfosqIjG9Tw2zuVvu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:BNURazYPRT_tJGWlTJTKbZQUU-piKlA-a2FGwijcovNRWc8TmBNawEaK>
X-Feedback-ID: iccae4b50:Fastmail
X-Received: by mailuser.stl.internal (Postfix, from userid 501)
id 538A0F60088; Thu, 3 Dec 2026 15:45:56 -0500 (EST)
X-Mailer: MessagingEngine.com Webmail Interface
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
X-ThreadId: A6QYJzXTjw8k