From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.16 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796364992; b=QQMGQV33U/9AWCk5Q8XKVbaQARS2cuaCejC01X0Yx9KKIpQ8SOpdyiui3bRL4VVVV9/D yiNXV5BHNrQnJUZf+LllJtm/CvDq2+wj4andHMx43hcx7Vz6MJjlkHQW3tJuxvCFdLQiF QWWOFGct3fKzYgwNGUVDhVC9hVIJpy5LWPeRvTFlfJI7BSld5KB/EKAd9rUH4bdfyAhq3 sDuIrSGSJXxY+OOELikUijBj8JGh7A7O0uzyY5x+Cd2CQZRM+x9G03BxdtmdlT+5uwFtY 1+YBitaogUB4Jh+PWRo52w2zwzMHW2XHwPnDibDgclEy5+neg4LfxtvsXsA4fdN9VJQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796364992; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=WXKeOr6EDnE7Ge4dJAYMPSf4CGFVHYVoSeuLhbPl4yw=; b=zhJ/lE6/16Dc0kUPn/80VUQ3/542limUA5WY7fQ+7cafPKBgdOSQsK4LbpsT/z5rZcIO JrkeeYM1NMqL6i6pOBwyI8h9xPbACUms3vGn/iXtclMqDP0eBANbO+ru364XkMcNR9JMV OMHrs1YN4daskAURFzvJQGWMdZ4Gh2Js8HuSRkP+haB0OpiDAYQZTEjsVGSy7JKBrwsOT crtiOhv/0GsiOU9CpyP41ZiPCWX7fapZdhe1z+BTHyJYkvNELfNvT0zMtWmgX6YuBg7sR NOZTD2hxfGEjb7F3FUwjRj3gKW9GpCKKuLSlVWhdFFEa2tjMaDVhnC9mHoMNivlLAJQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=NMmg29XB; arc=none smtp.remote-ip=95.215.58.16 Received: from mta1.migadu.com (out-16.mta1.migadu.com [95.215.58.16]) (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 E044E606A689 for ; Fri, 4 Dec 2026 06:16:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E044E606A689 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=NMmg29XB X-Envelope-To: netdev@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=b3BF9c1koVCFzaMq58LMFSdYhEK3cYxpIXymoj/fxrY=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796364989; v=1; x=1796969789; b=NMmg29XBoGukmKzHczeb2HJDEElmjSawXYP4nM7m7UbhNOWHXaH7VuXXBYifWHh90gwuL5VU qq/yiSYThaTcvlqGrao8fgyfg0Y5DALJmLLuUeOI36T+WmUzAFIYJqMSnfyXDEvwdISOR6tG6yX CHLy8ihIZT0FG8+uR2TNi4UY= X-Envelope-To: netdev@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 7c05ca393a42d0b8; Fri, 04 Dec 2026 06:16:29 +0000 X-Mizu-Trace-ID: 7c05ca393a42d0b8 X-Migadu-Flow: FLOW_OUT Message-ID: <2018a6f6-ce72-480d-b820-b901014d7351@linux.dev> Date: Fri, 4 Dec 2026 14:16:23 +0800 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net] tcp: clamp the u64 delta in tcp_rcv_rtt_measure() To: Chris Mason , 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@bacik.io, netdev@vger.kernel.org References: <20261203202930.14580-1-mason@kernel.org> From: Jiayuan Chen In-Reply-To: <20261203202930.14580-1-mason@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/4/26 4:45 AM, Chris Mason wrote: > 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 The math is right, but in practice it needs a lot of conditions to actually hit this. > 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 Reviewed-by: Jiayuan Chen > --- > 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);