๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #7331

Re: [PATCH net 2/2] tcp: fix shift-out-of-bounds in inet_csk_rto_backoff()

#7331
From: netdev-bot+sashiko
Date: Mon, 26 Oct 2026 06:50
99 lines
11302 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

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

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] The code change is correct.

--

tcp: fix shift-out-of-bounds in inet_csk_rto_backoff()

This commit caps the shift amount in inet_csk_rto_backoff() at 32, so a
large icsk_backoff no longer causes an out-of-range shift of icsk_rto.
The clamp covers both callers, tcp_ld_RTO_revert() and the orphan check
in tcp_probe_timer().

> icsk_backoff is bumped on every RTO and zero window probe, and the only
> thing bounding it is tcp_retries2 (a u8 sysctl, 0..255).

[ ... ]

> Set tcp_retries2 to 64 or more and keep the peer silent, icsk_backoff
> climbs past 63 and the shift is UB.

[Severity: Medium]
The code change looks correct to me. Is this description of how the bug
is reached accurate, though?

tcp_retries2 caps icsk_backoff only in the zero window probe path:

net/ipv4/tcp_output.c:tcp_send_probe0() {
    ...
	if (err <= 0) {
		if (icsk->icsk_backoff < READ_ONCE(net->ipv4.sysctl_tcp_retries2))
			icsk->icsk_backoff++;
    ...
}

In the RTO path there is no limit on the count:

net/ipv4/tcp_timer.c:tcp_retransmit_timer() {
    ...
		icsk->icsk_backoff++;
		icsk->icsk_rto = min(icsk->icsk_rto << 1, tcp_rto_max(sk));
    ...
}

The connection is killed only by tcp_write_timeout(), which calls
retransmits_timed_out(sk, retry_until, icsk_user_timeout). When
TCP_USER_TIMEOUT is non-zero, the tcp_retries2 based model is skipped,
and only elapsed time is compared against the user timeout:

net/ipv4/tcp_timer.c:retransmits_timed_out() {
    ...
	if (likely(timeout == 0)) {
		...
		timeout = tcp_model_timeout(sk, boundary, rto_base);
	}
    ...
}

Even when the user timeout is 0, the model bounds elapsed time and not
the icsk_backoff count.

No privilege is needed for either socket option. tcp_sock_set_user_timeout()
accepts any value >= 0, and TCP_RTO_MAX_MS accepts values down to 1000 ms
in do_tcp_setsockopt().

So an unprivileged process can trigger this with default sysctls:

  setsockopt(TCP_RTO_MAX_MS, 1000)
  setsockopt(TCP_USER_TIMEOUT, a few minutes)
  peer goes silent
    tcp_retransmit_timer() fires about once a second
    icsk_backoff passes 63 in about a minute
  ICMP unreachable arrives
    tcp_v4_err()->tcp_ld_RTO_revert()->inet_csk_rto_backoff()

Without TCP_RTO_MAX_MS, a TCP_USER_TIMEOUT of a few hours is enough. An
orphaned socket reaches the same shift through tcp_probe_timer().

Is the impact also larger than a UBSAN warning? On x86-64 the hardware
masks the shift count. tcp_ld_RTO_revert() could then compute an
icsk_rto that is far too small, and the orphan alive check in
tcp_probe_timer() could give the wrong answer.

Could the commit message say that unprivileged socket options and a
network ICMP are enough to trigger this, and describe the RTO impact,
instead of saying it needs tcp_retries2 >= 64?

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261023064915.401112-1-jiayuan.chen%40linux.dev
Technical Details
Message-ID: <179299743134.3134.13204213247651180532@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351704-linux-kernel-netdev=dewy.ru
References: <20261023064915.401112-2-jiayuan.chen@linux.dev>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351704-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 2/2] tcp: fix shift-out-of-bounds in inet_csk_rto_backoff()
Date: Mon, 26 Oct 2026 06:50:31 +0000
Organization: Usenet Network
Message-ID: <179299743134.3134.13204213247651180532@kernel.org>
References: <20261023064915.401112-2-jiayuan.chen@linux.dev>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1243463"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:p4iLcbdOe+ExPMkORBoawL3k8oU= sha256:AYh4XUjG+KyZGBNke5EBqvArI6Q/to0O2+fkMd4NkGw=
	sha1:v6m+VFzdxEq0q6QZMl72BNwxZis= sha256:LOWI4MjPaAqF5spfIkzyOQIlVecKScl7+Yx2LrDXOA0=
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 3F74E125B7B; Mon, 26 Oct 2026 09:51:03 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.738
X-Spam-Status: No, score=-3.738 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.339, 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, URIBL_BLOCKED=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 xT0Vu_TxbH6d;
	Mon, 26 Oct 2026 09:50:55 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-351704-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id F1E29125B8A; Mon, 26 Oct 2026 09:50:45 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id A619D2593C; Mon, 26 Oct 2026 06:50:44 +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=1792997444;
	b=GRmORoi38qQtal6u8U/6NSEHaaA3RZB8vO90u9GLugLL6+QA0zffkpNYvWlUJo/EVWFT
	 tO6vsmmlqoQ3k7Wl6kCPgT4GByPesGAtSoyiJZp/E8HZqGGBpbtm3BzWIr3wHcl3v3OAf
	 uz6TNLkNtEw/OTHeII/4vwTryyxMxaAhuvK+FAYFYMkkni6a3dHjmFEYhYPnUBsnSUWyy
	 om6EWusGcDCgU2zpTz3E3ddiPEsDNtK1W8BQCeWGNfYUx82yYnCf8USpWdoQooX5qWeL5
	 pXYu5MuI0t9nrvivbv4hAhYv2pDGto5v0C9iPVU4Tj4MhwhSpAvqtcuvfjQXrTEqRDg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792997444;
	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=mGGTzTbDVNWYnQmVpbZgCh4dhNFuupx1F6U7YbVqkjw=;
	b=kLCBEXlcYp+1FNZUEvrV8suhMjerpHfjj0V45EF6oJUzXvRJzfXketFl1zPfOy7fKLJ4
	 4Z42G/F4UuCjZjCN14wfbtYE9mIC6ZFdtWY1H3g77gd4j/kMErDQ4+hWXCBdUeEPpAIuk
	 KS7isBqM2wl+z4vMCdFJDYlLmcxtDDNmnzeaDWG2m2cH4/ctitiLOOrDsJvvVIAfmlIL5
	 afgTmODVTx1a7s+z1aHOqxIBcc9o054rE6KfaI4YWvZSZg20TFjNxJGI9Ql2MQzsiP/Uh
	 /NnqSLELyCfXt+eQMCBT9jGbr+LGWxMMeZfwPotDh3t9wgtRoxscRmjJy3rAKYG9y2g==
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=EUF0qaOc;
	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 12F4D606A32A;
	Mon, 26 Oct 2026 06:50:44 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=EUF0qaOc
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=1792997438;
	b=i8jtNAvAAk/5O2+qqdpX285f2utHNjcVSxEb21fNoExjvsAedm+BZAj93UnWqvFfMkl0
	 1OdN4Y2o1tXXxDVnZIMj+MQMd2r7s5v/v+7nd1Q/VUdh1iMB2CStnRhZE6MeO3SATGI6Y
	 GuemrWX3zZKZcgInZLHr7gGbaBb1akbezgDlREAFkGarKHZwbWBouZiqE2ckC4vbgJ16k
	 G+DV79a6LWH2yJwkJAl5eHy6PGvhHvy06plqoD6J7TIuDWgpYZ/2ofds7zVQC5Mw6naNR
	 PcQ3ttqpiyx28p7kLFU+lL6dKordj4fYpsAdPefZ9Ra05FiawoMr7mje1IB5CDdZZeA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792997438;
	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=mGGTzTbDVNWYnQmVpbZgCh4dhNFuupx1F6U7YbVqkjw=;
	b=KDyw5WDIsZTJSsyS4/eHI3ti14hheub03B418PHFdGYCXMTxuml8r0MACB0FNn76Lmty
	 mO0//ZYAsJHqXSW9qi1/J4MCa+cP2gGKsqO1rbuLsqmND88iJh7FXyVtO+hNFyw5QA14W
	 g4I3bnZ9W8/xlRvBzokryomUtirNFyZprfOPItTkpcqkEJNs4LtDS/97c6QuWoTdvLWBS
	 8lEM/y6jbs4S6Fo19Z5bfY8lUVSj4/reIqjoBnjDptjA5wVITPni1PwvjqCfeBz4S71Yx
	 EaZeD10kfaUsWsjCwM203rC+fUk96jDKx7EQwIFMpDdH5Ne7alUigGIOVtvewz3wXNQ==
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=EUF0qaOc;
	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 DD46A606A320;
	Mon, 26 Oct 2026 06:50:32 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC20A1F01828;
	Mon, 26 Oct 2026 06:50:31 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1792997432;
	bh=mGGTzTbDVNWYnQmVpbZgCh4dhNFuupx1F6U7YbVqkjw=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=EUF0qaOcqXijAYxN/SEzQ6twa4I5WqUb0a/9TjIoalYIbhIo12caB9egezz5tDZh1
	 ZaY69jnouSphGUfRckZwX/YFmSK+rtAIU9mBW7939sKiwpJ3OE5shSfKp4+lLPQupM
	 SGjw/ug6YOzvdRFymXnFbABt0lpH5Rxt88XuwbFev4oX8TEW+bM+EK+VbQAp/+FDGt
	 7OKJaS/kbwlNPqTpfofy5sc+ZHUPnJ/Hv/DfYygru7MoMOSWQos6pcWWF6qWDhqno0
	 HiWAZP7Vb7EYWPxLmUSi+KQcz/9i/+zy5tlvuQEJxubUTrqN/yllli5xSFaXlSSarP
	 vRjyGJPrxjx0w==
X-Cc: netdev@vger.kernel.org, stable@vger.kernel.org, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
 corbet@lwn.net, skhan@linuxfoundation.org, rdunlap@infradead.org,
 ncardwell@google.com, kuniyu@google.com, linux-doc@vger.kernel.org,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <20261023064915.401112-2-jiayuan.chen@linux.dev>
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