๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19695

Re: [PATCH net 2/3] net: bound receive window predictions before narrowing

#19695
From: netdev-bot+sashiko
Date: Fri, 20 Nov 2026 08:22
122 lines
12555 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] In tcp_rcvbuf_grow() (net/ipv4/tcp_input.c), the slow-start
  growth term multiplies by `(newval - oldval)`.
- [Low] The From:/Signed-off-by: names do not match.

--

net: bound receive window predictions before narrowing

This patch changes rcvwin in tcp_rcvbuf_grow() and mptcp_rcvbuf_grow()
from u32 to u64, so the predicted receive window no longer wraps before it
is converted to a memory budget. The prediction is then clamped at INT_MAX
before it is passed to tcp_space_from_win() or mptcp_space_from_win().

> Fixes: aa251c84636c ("tcp: fix too slow tcp_rcvbuf_grow() action")
> Signed-off-by: lllei <llleigoing@outlook.com>

[Severity: Low]
The Author line is "lei lei <llleigoing@outlook.com>", but the sign-off
is "lllei <llleigoing@outlook.com>". The email addresses match and the
names don't. Could the names be made consistent? checkpatch will flag
the mismatch. The other patches in the series have the same mismatch.

> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index a2074a1af4222..6d5950dbe6638 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c

[ ... ]

> @@ -961,10 +961,10 @@ void tcp_rcvbuf_grow(struct sock *sk, u32 newval)
>  		 * It might take few additional ms to reach 'line rate',
>  		 * but will avoid sk_rcvbuf inflation and poor cache use.
>  		 */
> -		grow = div_u64((u64)rcvwin * rtt_us, rtt_threshold);
> +		grow = div_u64(rcvwin * rtt_us, rtt_threshold);
>  	} else {
>  		/* slow start: allow the sender to double its rate. */
> -		grow = div_u64(((u64)rcvwin << 1) * (newval - oldval), oldval);
> +		grow = div_u64((rcvwin << 1) * (newval - oldval), oldval);
>  	}
>  	rcvwin += grow;
>  
> @@ -973,6 +973,7 @@ void tcp_rcvbuf_grow(struct sock *sk, u32 newval)
>  
>  	cap = READ_ONCE(net->ipv4.sysctl_tcp_rmem[2]);
>  
> +	rcvwin = min_t(u64, rcvwin, INT_MAX);
>  	rcvbuf = min_t(u32, tcp_space_from_win(sk, rcvwin), cap);
>  	if (rcvbuf > sk->sk_rcvbuf) {
>  		WRITE_ONCE(sk->sk_rcvbuf, rcvbuf);

[Severity: Medium]
Can this clamp turn an underflowed prediction into a fully saturated
subflow receive buffer?

The slow-start branch above computes (newval - oldval) in u32, and
tcp_rcvbuf_grow() never checks that newval > oldval. For MPTCP subflows,
mptcp_rcv_space_adjust() only compares copied against the msk-level space.
It then calls tcp_rcvbuf_grow() on every subflow:

net/mptcp/protocol.c:mptcp_rcv_space_adjust() {
    ...
	if (copied <= msk->rcvq_space.space)
		goto new_measure;
    ...
	if (mptcp_rcvbuf_grow(sk, copied)) {
		...
		mptcp_for_each_subflow(msk, subflow) {
			...
			if (tcp_sk(ssk)->rcvq_space.space)
				tcp_rcvbuf_grow(ssk, copied);
    ...
}

The msk space comes from a single subflow. mptcp_rcv_space_init() sets it
to min(rcv_wnd, TCP_INIT_CWND * advmss) of msk->first or the accepted ssk.
A join subflow sets its own space in tcp_init_buffer_space(), from its own
advmss and window.

For example, a first subflow with advmss 1460 gives an msk space of 14600.
A join subflow on a 9000 MTU path starts at around 62720. Both values only
grow after that, so the gap stays.

Suppose copied lands between those two values, e.g. copied=30000. That
already gives an msk prediction of about 186 KB, above the default
128 KiB sk_rcvbuf, so mptcp_rcvbuf_grow() returns true. For the join
subflow, newval - oldval then wraps to about 2^32. If that subflow's
rtt_us >> 3 is at least tcp_rcvbuf_low_rtt, the slow-start grow term is
around 1e10.

Before this patch, the u32 truncation gave an arbitrary result. With
newval == oldval / 2 the sum was exactly 2^33, so nothing changed.

Now that rcvwin is u64 and clamped at INT_MAX, every such underflow sets
sk_rcvbuf to tcp_rmem[2] on that subflow. window_clamp then becomes
tcp_win_from_space(sk, tcp_rmem[2]).

The commit message says:

    Predictions above INT_MAX therefore already require a saturated
    receive budget.

That assumes the prediction is meaningful, which isn't true when
newval < oldval.

The subtraction was already there before this patch. Would it make sense
to skip the slow-start growth when newval <= oldval?

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117052200.1507847-1-llleigoing%40outlook.com
Technical Details
Message-ID: <179516297347.3136.13553293180683672285@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367778-linux-kernel-netdev=dewy.ru
References: <20261117052200.1507847-3-llleigoing@outlook.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367778-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 2/3] net: bound receive window predictions before narrowing
Date: Fri, 20 Nov 2026 08:22:53 +0000
Organization: Usenet Network
Message-ID: <179516297347.3136.13553293180683672285@kernel.org>
References: <20261117052200.1507847-3-llleigoing@outlook.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3105898"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ZuvfW5Tteat26PXUxuMnnFpPpyY= sha256:ZYPvNUjF30j/Pewb8gILDhsUZar0DZ9Ne1Bt07pQ2BQ=
	sha1:YDdYpsslj+KaMGZ5B61zIg6XKaw= sha256:YBudaf6xXxEkLgohWQhXbG6H32MC6l5oPqOqVHpa94U=
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 DF427115908; Fri, 20 Nov 2026 11:23:12 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, 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 h24eNo4YyWeb;
	Fri, 20 Nov 2026 11:23:09 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-367778-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 A3E7A1158D0; Fri, 20 Nov 2026 11:23:00 +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 B0F56223126; Fri, 20 Nov 2026 08:22:55 +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=1795162975;
	b=OtyiuQEddSxWBprzuUmg/8BhYFGhWMsuWqJqo88sqlOVTDW7dcvqBz062eCDP/hyIY73
	 UrJcQ4ApdOYk8wTLCImNSmUv4Xck73QsqlepxV8Kp85DGlRA+uuSph2AsIVgaAZ8jLM9V
	 yOW+GjVBxRDQQTY36y8YAciFoN+90sR7z3fbgAG+Pc/QkLxVl943PNfS5prIendDNFKYN
	 TF/dTk6jaIYCEDOUXD4JpXjNUtgFY2pLmQ1Uv0DnLHYZ+3ZaleJ6Eosdwd4n506FwhJWg
	 vMRbWNdFpOUPmw1/1vKLKCVXIlJV6SQoU4qUYeu1XUjmOqbDpeZWabCiXUm1TiUWSbg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795162975;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=itdZZyugtbVor8Nz/NNjMIX62HxSZgWL08Ie13eHCus=;
	b=d/ukBV6I3XvEt9qA8sq8k6VZ0nnfOhmM2roU90xXTjzm4kb3ok8b0wQYAkyoP9aS81sm
	 SIaEpW9wExyJQD2o3A/UPwPAuQ2/Ye5orY3FN7bmfg2eIsJ5r7YNmbdl9kcDwXO4AHq3j
	 dlXp9p5QHvLkGDDCT6GcJV/xd+wYUm0nL78fdUHaUa2ohyLKBtRjTTOTf689tF6wSS5cF
	 LxE9iyrQSd/+uau+mTFq8G0N2tfNrriF+9QRBwBPdYBGnkN88HGnw3b47NoqCYYvb3u6k
	 3I57EvbNv3XKXMY0MJ6qn2m4g64EVV+KOQ5yOqTH25FLuCaDtBJNaz4VTLfHRvdBiZQ==
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=TlMA85qa;
	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 89582606A332;
	Fri, 20 Nov 2026 08:22:55 +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=TlMA85qa
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=1795162974;
	b=Hq7dwwPQCeB17Lfl995ciwembS3KcqX/gRxAlz/ewfoHY5vSuOLovC4Lh2V2qr2voQZH
	 ZReKmvtubIrPyEljeXSD9hllQmIOwIBDBd4g3cOFgFyArccPqj+9OlAwyq04Ig5XJeccI
	 AwsFP5ExmwsvO0OME1HjMV4Azx83xeYhWS7u00KXbuQmbmlrgZwjoZfCRpj0yZ3SfdGkO
	 vE5CYfiKixKvHEjxqYaj8j51+JUUKgMZf5peP0iXCis06m/41e2sy9g6H878cNRtUSFdV
	 aTl6bIwW6jz+GdPf3TUgJGOZGJJpNSIjIOYK041DCMYIipjjhfzTH8GPsFUeMU9UfSA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795162974;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=itdZZyugtbVor8Nz/NNjMIX62HxSZgWL08Ie13eHCus=;
	b=ZZFZmmtJrzSbgE/KqZlO+uygdyYhC+pgpePazEnC5yFG7HLQR8sRKS3NrVNAd/CGwJC5
	 OtsLfDBiJrF2SPGEmTcu7S9UbrXjqobXK5IUly7TwdRd0QK7s1uW9aBqUeID6aUeaGuDn
	 GJHU5oPHViCO+iTcjiTreGmeaBREcod/VgPdWZtkNqX9ji5JSKu+g5L6SqBqxQio1Tcmm
	 qGTdqgUAlW+KSbzr+SSGlL9obcViKMGQ+AktsRj1v82XqYDtp/JwCiIQqbNLx4BslHZhH
	 KCXkBweFzRDMolnsewZskF/Qzo4DQyyhZPQKEE80TCsx2bICHk8+0QZvfed0ntrHMRQ==
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=TlMA85qa;
	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 ABCAF606A320;
	Fri, 20 Nov 2026 08:22:54 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAEAD1F000D0;
	Fri, 20 Nov 2026 08:22:53 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795162974;
	bh=itdZZyugtbVor8Nz/NNjMIX62HxSZgWL08Ie13eHCus=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=TlMA85qaAe4MKlEjA4cKr5y1JYj05gDsPx1RbWLjNxH0Yi+62GbkiE7Qius+r6vgt
	 bnBwERT3ORIRJjpRQth4ufKSimQJcCjSIoemtL5rP0PDzPW+M5RjwMO4udwoWWjcA+
	 utESPVAxl2QTQxUEIFedL+tki0Feo3X2imv/rC0smS3Ja+tjkUjIKRMBCaM+aBznMm
	 I5jFm1OqPgemZxT7wBCEFVLySo+s5xDHK30MAEMkBEHWBtboi6w9zN819hbypkqrRG
	 wpggX254ubRDrCb3OhzdRgaGYTAlFKKsWUZzaHwde0YqLo8GAdTwrTilNNhTh77qxy
	 2fGjYjR+9OnKw==
X-Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, edumazet@kernel.org,
 ncardwell@google.com, kuniyu@google.com, davem@davemloft.net, kuba@kernel.org,
 pabeni@redhat.com, horms@kernel.org, matttbe@kernel.org, martineau@kernel.org,
 geliang@kernel.org
X-In-Reply-To: <20261117052200.1507847-3-llleigoing@outlook.com>
X-sashiko-severity: Medium
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