🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #18692

Re: [PATCH net 3/3] tcp: reject RTT samples from TSecr above 120 s

#18692
From: David Laight
Date: Wed, 18 Nov 2026 18:51
108 lines
15396 bytes
On Wed, 18 Nov 2026 16:27:28 +0100
Eric Dumazet <edumazet@kernel.org> wrote:

> Le mer. 18 nov. 2026 à 14:36, David Laight
> <david.laight.linux@gmail.com> a écrit :
> >
> > On Wed, 18 Nov 2026 10:58:14 +0100
> > Eric Dumazet <edumazet@kernel.org> wrote:
> >  
> > > Le mer. 18 nov. 2026 à 01:50, Chris Mason <mason@kernel.org> a écrit :  
> > > >
> > > > tcp_rtt_tsopt_us() returns the timestamp clock minus TSecr as an RTT
> > > > sample, and accepts up to 2,147 s. If TSecr echoes an old timestamp,
> > > > the sample is the age of that timestamp, not an RTT.
> > > >
> > > > tcp_ack_update_rtt() takes this sample for an ACK of retransmitted data.
> > > > tcp_rtt_estimator() clamps it to 120 s. The congestion control gets the
> > > > sample unclamped, in rs->rtt_us.
> > > >
> > > > tcp_rcv_rtt_measure_ts() passes the sample to tcp_rcv_rtt_update(),
> > > > which computes sample << 3 in u32 arithmetic. That wraps from 536.9 s
> > > > on.
> > > >
> > > > The fix used here is to reject a sample from TSecr above 120 s, for both
> > > > callers of tcp_rtt_tsopt_us().  
> > >
> > > This only covers one of the two callers of tcp_rcv_rtt_update().
> > >
> > > tcp_rcv_rtt_measure() is called from tcp_event_data_recv() for every
> > > data segment, with or without timestamps:
> > >
> > > delta_us = tcp_stamp_us_delta(tp->tcp_mstamp, tp->rcv_rtt_est.time);
> > > if (!delta_us)
> > >         delta_us = 1;
> > > tcp_rcv_rtt_update(tp, delta_us, 1);
> > >
> > > delta_us is the time the peer took to send one receive window. Any low
> > > rate flow can take more than 536.9 s for that, no bogus TSecr needed.
> > >
> > > Then 'sample << 3' wraps, and since win_dep is 1, the wrapped value
> > > is kept whenever it is smaller than the current estimate:
> > >
> > > if (old_sample == 0 || m < old_sample) {
> > >         new_sample = m;
> > >
> > > For instance a 540 s sample ends up as rcv_rtt_est.rtt_us >> 3 == ~3.1 s.
> > >
> > > We should also clamp in tcp_rcv_rtt_update(), like patch 2
> > > does in tcp_rtt_estimator(), so that both sources are covered [1]
> > >
> > > With that, 'old_sample - (old_sample >> 3) + sample' converges to at
> > > most 8 * 120 s, which fits in u32 too.
> > >  
> > > >
> > > > An ACK of retransmitted data whose TSecr is more than 120 s old now
> > > > gives no RTT sample. So it no longer resets the backoff, as on a
> > > > connection without timestamps.
> > > >  
> > >
> > > This seems fine to me. We send a retransmit at least every
> > > TCP_RTO_MAX, and the retransmit filling the hole updates TS.Recent on
> > > the receiver, so a well behaved peer does not echo a TSval that is more
> > > than 120 s old in an ACK of new data.
> > >
> > > [1]
> > > Something like this on top of your patch (compile tested only):
> > >
> > > diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> > > index 2d739cfdae8c33d12cd34e00388a29f0f4229806..708a989e5a63bb6ad67cc777d57815ae197c451e
> > > 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_t(u32, sample, TCP_RTT_MAX_US);  
> >
> > You can't need min_t() here.
> >  
> 
> Sure, on current kernels min() is happy with an u32 against a non
> negative signed constant.
> 
> But this series carries Fixes: tags going back to 2.6.12, so it is
> going to be backported as far as stable maintainers can take it.
> 
> The relaxed min()/max() checks landed in v6.7. I do not have cycles
> to check if they were backported to stable versions.

It got backported to some of them a while ago.
I suspect it is in all the current ones.

David
Technical Details
Message-ID: <20261118185109.166c9c58@pumpkin>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!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-366367-linux-kernel-netdev=dewy.ru
References: <20261118005048.53393-1-mason@kernel.org> <20261118005048.53393-4-mason@kernel.org> <CAL4WiirGtN4e6HO-aEBU57507XxSdEz5b0oto45hbRA_0sivtw@mail.gmail.com> <20261118133629.1e9714b4@pumpkin> <CAL4WiiqBXkr5tQZ2oe04ZA2ZqeLQWCdc9tnJWe3NcDFZDcUc3A@mail.gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!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-366367-linux-kernel-netdev=dewy.ru
From: david.laight.linux@gmail.com (David Laight)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 3/3] tcp: reject RTT samples from TSecr above 120 s
Date: Wed, 18 Nov 2026 18:51:09 +0000
Organization: Usenet Network
Message-ID: <20261118185109.166c9c58@pumpkin>
References: <20261118005048.53393-1-mason@kernel.org>
	<20261118005048.53393-4-mason@kernel.org>
	<CAL4WiirGtN4e6HO-aEBU57507XxSdEz5b0oto45hbRA_0sivtw@mail.gmail.com>
	<20261118133629.1e9714b4@pumpkin>
	<CAL4WiiqBXkr5tQZ2oe04ZA2ZqeLQWCdc9tnJWe3NcDFZDcUc3A@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="2670628"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:DwPUf8WTmXnXckRl37BT1eB2vTc= sha256:TnlhiDg9HtOEde285SPh1Tl9d2cGm1onUsIxaB5XDnQ=
	sha1:CFJZ8sIpt+0/I/vPbj67GA28Td8= sha256:iT8XXVo4i8EAO62uXQsBX142/dSkDgg0qySoQJqdayg=
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 ECA5A115384; Wed, 18 Nov 2026 21:51:38 +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 lSBb5fU7cGYn;
	Wed, 18 Nov 2026 21:51:36 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-366367-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 63F50115380; Wed, 18 Nov 2026 21:51:26 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 87343E45A2; Wed, 18 Nov 2026 18:51:15 +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=1795027875;
	b=QoYiQsBLJd8Y8qISSWVi9Ak8OneozU96qsX6GZkUOgiVEMDJSSUQlkpEDJdnGp7x2mOv
	 v5X1hLOehOEIQ6xSRn1rGgYTTxaV/tG3q5zrG7JAsi3jqHAVqJ5o/VbWYWON3KzdskdGc
	 2sdcBryGPAmpEuW9Di5YU7xNbcYFOyUJUoxJVqYopbQ8Glh4zYhvda4igGTOhuaUoxW/i
	 JdjWFPsal5/inTjXgd+BtviVQYN30PqWf/TtBIBff10L703cQI5a/G6xmD2gKhDBAYTd0
	 6bKC76p9/iNWW+rSu0m6YOaD3PJiG/wn/fvZ/9Spaaxr5/jtpZ4fWsW22rz9lYqovLQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795027875;
	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=ooPu190hYrxFNAoK26yIiEdMi4rBDWGb04lJsrsyuUU=;
	b=4ex2CIyWCSargGb48RVRa6LjW+xgfmTR+8miT8Ec2Bw5javpMC2L8+0GOlBMJ2nEePaK
	 5mWV0gMlnLnE0NT+lPBpzleictUPbGZPQfEjY1C6F4UltCJ0czS3o4/dnCsm2K+nXu+FS
	 42HF0/gAhqc4uGbFKyPT33nv1Jm2kWMN2F1Pio6m8e8D10C977W+lPmkcnrtjBbz/Ww9G
	 jX2P2oJznrEXzwGBpwgYQlmYYVGkhSHCcFmvb96jkl0TBgKNqfFEfo91h2ZZZlB9GxKcY
	 Ie9f342Gg6Txu1RZ6m3RcqhA9ACdw/TSTZ2Xh2ukaQBb0GQMR+lU5Y1QxVcI02UaZSw==
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=h94tLiIC;
	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 254C6606A330;
	Wed, 18 Nov 2026 18:51:15 +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=h94tLiIC
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.41
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795027874;
	b=0i09aTgyvOGNhy9MpsszLhFwIbdDQFBxAZKo+TiFaxbt4SRkNj/NFsavK09tNZ4Sgk+h
	 UtqVS9wzPD83+k9nfkaxNshpND7xnPsj+wbwXGfrjciclsdhQIwc6nHX2pKuo5+lrheWu
	 sJ+ZKeL0E8dv+HHhVKOz0i4LCPFagpOdacTlkSqgZw3k/BW6RmrpTvwNvroxKgdS8Dl3o
	 pdJT3UV8sICWppX4SkBaQDGVXvy6cNGxAOS3DjeIBjFNCF4kQoZjDk6eQ1+a3aI5wgFeC
	 ZFLFamWVBq+PLPVDB94K7/reE9bzPWCQqMcjxXZn2NwjrzSsl1HeV6sNfaAFDvFb/WQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795027874;
	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=ooPu190hYrxFNAoK26yIiEdMi4rBDWGb04lJsrsyuUU=;
	b=miIfD6p4L1eKdGAiCf476OgiOv/IG0HAu7GnFrQ3Oxb9S6fWg+ujhBXKH1IMmjQFizi8
	 Tc+TmEpsC781gxuEnHZRM+uicg5m2M/Vl8XeDoMw8S+eItKzMgA8LjoGuKD0Izht39P2Y
	 /k0c2oc5c26kXHdy7YlFaReVRZX8qckefau19VjiFPi2XfQcS8yUVI+AUhqtSFrPuhbVY
	 zGF+SmnJM2j8AwJ4RI7VWnX49JdKn0/TXf5hanixIuWDfjbsj3FEoDbG3WepQ5QiiaGnq
	 e1x1c0IVY7g5/BX8rmEQRDUpmI4Q8HPNMNH+FfJZ/kOStysuFbPjLIFD4AEyVKBWkTg==
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=h94tLiIC;
	arc=none smtp.remote-ip=209.85.221.41
X-Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41])
	(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 27FE2606A32A
	for <netdev@vger.kernel.org>; Wed, 18 Nov 2026 18:51:12 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 27FE2606A32A
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-f41.google.com with SMTP id ffacd0b85a97d-498f5fa5103so822096f8f.2
        for <netdev@vger.kernel.org>; Wed, 18 Nov 2026 10:51:12 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1795027871; x=1795632671; 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=ooPu190hYrxFNAoK26yIiEdMi4rBDWGb04lJsrsyuUU=;
        b=h94tLiICWG7t+0Vm3kWdtbOmQuIqyihf+G5+MCWtJ/ujCKEewTRT0+wUXBL5kkfNfD
         tBQE7hYCWyKBgSQaZlKnsjtOFuP9CXhD8NhCxXIPhC7us4/U4dJUoPMFxJLXpqeh+jL+
         C3mWma30bS1LYM/jfQfdqBLJJahMuUdv/br6fz3JeQ6upSj736eem3q97caF9W3mZF6H
         hxmP/sncUiAB9NsQXw3Gk1gMhHUA9pAxPLRpXvbBOaMt4t2eO/n1ML3M538bBc4pqyfA
         u0k29fnztyWNZQ0XlxYug1/mmD5d4gsfR7UGpffveGv39y/pebRpEHL91DoikgHsbiW4
         SrCA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1795027871; x=1795632671;
        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=ooPu190hYrxFNAoK26yIiEdMi4rBDWGb04lJsrsyuUU=;
        b=H5OxjNy4ShM0FNeX5EYxt1H6k4nYhuDirJuepvzQI5F9f1YZ88aLX3x5qMgAWjoeQm
         C/nFIgh8Gp/SjeXCgTCo/bOBBKCCz00JBHB0Az2SDw6RZLi+/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5ANScB/scy/4QGCx2vbpvu
	m8ecTR6ePgcmz1/uiAtj7XcXdKJSOFqtttvWg8E4tUeesK6ODuYwrBrQi0O1UaDCoA==
X-Received: by 2002:a05:6000:4553:b0:4a3:8b21:51bc with SMTP id ffacd0b85a97d-4a63c468b74mr5497707f8f.46.1795027870966;
        Wed, 18 Nov 2026 10:51:10 -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-4a654b807fesm5805865f8f.10.2026.11.18.10.51.10
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Wed, 18 Nov 2026 10:51:10 -0800 (PST)
X-Cc: Chris Mason <mason@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: <CAL4WiiqBXkr5tQZ2oe04ZA2ZqeLQWCdc9tnJWe3NcDFZDcUc3A@mail.gmail.com>
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