๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #18754

Re: [PATCH v1 net 3/8] tcp: Don't bypass GTSM check for reqsk.

#18754
From: netdev-bot+sashiko
Date: Wed, 18 Nov 2026 20:36
124 lines
11888 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 1 ยท Medium: 0 ยท 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).

- [High] Incomplete fix: GTSM (IP_MINTTL / IPV6_MINHOPCOUNT) is still
  skipped for request sockets on the TCP receive path.

--

tcp: Don't bypass GTSM check for reqsk.

This patch moves the IP_MINTTL and IPV6_MINHOPCOUNT checks in
tcp_v4_err() and tcp_v6_err() ahead of the TCP_NEW_SYN_RECV handling.
ICMP errors with a low TTL or hop limit can then no longer abort request
sockets. For a reqsk, the value is read from the listener through
sk_to_full_sk().

> diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
> index bf8542368032f..fd9588bba9672 100644
> --- a/net/ipv4/tcp_ipv4.c
> +++ b/net/ipv4/tcp_ipv4.c
> @@ -516,6 +516,17 @@ int tcp_v4_err(struct sk_buff *skb, u32 info)
>  		inet_twsk_put(inet_twsk(sk));
>  		return 0;
>  	}
> +
> +	if (static_branch_unlikely(&ip4_min_ttl)) {
> +		/* min_ttl can be changed concurrently from do_ip_setsockopt() */
> +		if (unlikely(ip_hdr(skb)->ttl <
> +			     READ_ONCE(inet_sk(sk_to_full_sk(sk))->min_ttl))) {
> +			__NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP);
> +			sock_gen_put(sk);
> +			return 0;
> +		}
> +	}
> +

[Severity: High]

This covers the ICMP path. Do ordinary segments that match a request
socket still skip GTSM, though?

The subject says "Don't bypass GTSM check for reqsk", and the changelog
says "Let's restore IP_MINTTL/IPV6_MINHOPCOUNT for reqsk".

In tcp_v4_rcv(), a segment that matches a TCP_NEW_SYN_RECV socket is
handled entirely inside the reqsk block:

net/ipv4/tcp_ipv4.c:tcp_v4_rcv() {
    ...
	if (sk->sk_state == TCP_NEW_SYN_RECV) {
		...
		sk = req->rsk_listener;
		...
			nsk = tcp_check_req(sk, skb, req, false, &req_stolen,
					    &drop_reason);
		}
		if (!nsk) {
			...
			goto discard_and_relse;
		}
		...
		} else {
			drop_reason = tcp_child_process(sk, nsk, skb);
			...
			return 0;
		}
	}

	isn = 0;
process:
	if (static_branch_unlikely(&ip4_min_ttl)) {
		/* min_ttl can be changed concurrently from do_ip_setsockopt() */
		if (unlikely(iph->ttl < READ_ONCE(inet_sk(sk)->min_ttl))) {
    ...
}

The only min_ttl check on the receive path is at the process label, and
only the nsk == sk case reaches it. If a child is created, the function
returns 0. If tcp_check_req() returns NULL, it jumps to
discard_and_relse. tcp_check_req(), tcp_inbound_hash() and
tcp_child_process() never look at min_ttl.

So a low-TTL sender facing a listener with IP_MINTTL=255 could still do
either of the following:

  - Drop the embryonic connection. An in-window SYN, or an RST with
    seq == rcv_nxt, goes through
    tcp_check_req()->embryonic_reset->inet_csk_reqsk_queue_drop().

  - Complete the handshake and create a child socket by sending the third
    ACK with ack_seq == snt_isn + 1.

The in-window SYN only has to land inside the receive window. That is
easier than the exact snt_isn match tcp_req_err() requires on the ICMP
path.

In the changelog's repro the final ACK is sent with ttl 255. If it were
sent with ttl 1, would accept() still return a TCP_ESTABLISHED socket
after this patch?

tcp_v6_rcv() is laid out the same way, and its IPV6_MINHOPCOUNT check
also sits only at the process label.

The selftest added later in the series (Test 3 in tcp_icmp_ipv4.pkt and
tcp_icmp_ipv6.pkt) only exercises the ICMP path. No later patch in the
series changes tcp_v4_rcv() or tcp_v6_rcv().

Should the same check be added to the TCP_NEW_SYN_RECV block of
tcp_v4_rcv() and tcp_v6_rcv(), using req->rsk_listener? If not, should
the subject and changelog say the fix only covers the ICMP path?

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117053543.84032-1-kuniyu%40google.com
Technical Details
Message-ID: <179503418639.3136.8004890294182760159@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-366443-linux-kernel-netdev=dewy.ru
References: <20261117053543.84032-4-kuniyu@google.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-366443-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH v1 net 3/8] tcp: Don't bypass GTSM check for reqsk.
Date: Wed, 18 Nov 2026 20:36:26 +0000
Organization: Usenet Network
Message-ID: <179503418639.3136.8004890294182760159@kernel.org>
References: <20261117053543.84032-4-kuniyu@google.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2692990"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:lZDNQRdAHMsWPg6jaqvqnmTKqRc= sha256:49IDVBGW+jwsLj3bxr9Nd7EByOIL+PIYrDm+YYx6hfM=
	sha1:4gQ7kvimFSDhvgTpLX1xnEaNBrk= sha256:MBbbDGCwpMJcwZ/eazdtvs7EbLVh7ufKZLNMv1D+m7g=
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 C119A1153D3; Wed, 18 Nov 2026 23:37:02 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 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, 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 VRit5xZhHzDd;
	Wed, 18 Nov 2026 23:36:59 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-366443-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 B01731153D0; Wed, 18 Nov 2026 23:36:49 +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 7ED2F162FF5; Wed, 18 Nov 2026 20:36:40 +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=1795034188;
	b=NGBlyf0kfq+xauV9Sg9NKzdCOSHJaa7zjbb0qNcx4d5KawrVFXxtwsXpzCW5zZTSNEiU
	 oGT783cMJ6PczFrehw/wIxY/Cud5bMbsZ1NC1J34nX+0KRai1xbl2z0IIIdGWFD0ggHTd
	 5gP/pVFpAUwDGejyTVbWBNXuGONKlGrM9iGK63eUSiyV/ZT2y/po2TWxRswwG2Kh+p7zl
	 6XxaVvrrVVcxLsDLFXNkAlo2mF7hSJclWI0lHnXqcD9+AKXs8/Pqnqh95lBWOvjuNjEU2
	 pZSnCtHxwMN9dW9yOBn5upi9GYje+2mqhiUXZaeiZ7kHKxDkQzHPnYZoRZ7eBjOgXuA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795034188;
	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=VZKwbVIEwZ16tQwwnnbKKkdu/6LIA0NjvDmvocNIRks=;
	b=hJ0AtSCmR/XYvsO756GTOjeOQf0ZPn2lXmZtnf2mldP/D5R3zIydnjpEqCivulbng3Mk
	 0+F6NXslvXf3v/9BbmYkMFQzYQYKApqX9e73F38aEBzIRpGnORyfOY907DD6hPlOQIxsa
	 UaeDtgLcYb45pa4ItC6IHvU/gCn9hEZRytAtVMNEpKq6n4v4v3Ye3h17QfQ/3TeQ05Ors
	 uLqHQ/RJTJezUq9u8tymzMErKtxV51783feJZ9lVvWU2X124KGBHy36j4ANJOYH/a84RF
	 3lAb44U7bDurPaeyA7j1Y9SuDe0eBjI2azI9jfrwI14hhZ94llz3FPJSS25kIUYymmw==
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=E7LyQSEx;
	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 5C03260A262D;
	Wed, 18 Nov 2026 20:36:28 +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=E7LyQSEx
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=1795034187;
	b=xybqfOlZSBJM1siaWaQpS1Q+92M0KQ8VGtO8DpiseTkbqkXxMjEVbEwRkA0SpxtLKK6p
	 mYKC4ckobBM2EPpuEW+8evs/6/Sxh+Pwvb5N9JSjRICAFulxS4VS8xmAa6fWuz3XxZlR7
	 Ycz359A3kQpww4qAzOmTAt8MivtHwhR18I3JF9DCYPtH1YHiCHrQ4bdC5YxsjMXfyipnW
	 KPcpgFCVvHy/z4TQ2newas39aeUe+MIFB4rdDxkqH6Mqpr0tD3OWsjLmIUs+OVmRf5T8K
	 MQLRTzzejWnUDGN2x/EpmLiHKDhk9HYDIvcoLK4SsTdLpw5ttPhrNFi9HBjXkzn96mA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795034187;
	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=VZKwbVIEwZ16tQwwnnbKKkdu/6LIA0NjvDmvocNIRks=;
	b=M9x3T0nS2O8dOmSoJzcvy3EdPCNHnkeK8bE1ddRSI7ZONz6Q0g+w86eR0v9AmPGNNhUC
	 I9VdOl54F45boMw9y2Peiwmu6wp6hZ2XRwgbAOffe7uEtvKsCpWbc4ELvsAYzpDTprnl3
	 hf8MNlkXoSx3hbQ7gWq9Vt/nRRkB5rBnjugrInpl81fpuJ05qTBtF7Mp3WWPswX03TjUz
	 0QLqtBek4e9Ogk7nWqkYhPiCZnqgEkkk6B5M+mCf/NJkRhsoltzo8tT0S148QSVfzlJIh
	 J6QUJs3hXGh6RXqx1jhZbAeDQNU7HoQUHlC+5svZn7tD+AivKyLi2NvyeSmmQ9S5AHA==
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=E7LyQSEx;
	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 7C55760A2613
	for <netdev@vger.kernel.org>; Wed, 18 Nov 2026 20:36:27 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C65391F000C5;
	Wed, 18 Nov 2026 20:36:26 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795034187;
	bh=VZKwbVIEwZ16tQwwnnbKKkdu/6LIA0NjvDmvocNIRks=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=E7LyQSEx5t7DRajKkqUT2Qw2zEPBSpx7jgEqS9ipCmdAyK8Z5BEwxZji8WbuyI2cm
	 sXRYLsf2PbuPkCXB39zenxa0VqRL0KD6MOGfmTcSQn7FaS33AsPOqUMguEh/HQDD4Q
	 b/pxShKH5KUS09Sp1qKfBM/HLm2pu1vQ/q1yhx7gTlc2H8VQSlEFsxSfJVAKEJTnnd
	 EDvhABLqxh57C9VOktnUDZiWBo09pJWX7kBlI9uYohBnlnfG9q8c0J0dzKQAXy2+fn
	 JH3n3RXznOKmX/Vfy2Ka4rTWyatlEhWT3wsLwBHbwsv9zAtOv4Vh6vGjEy+hXVi3jR
	 lnn4cfTZ6VJ/w==
X-Cc: edumazet@kernel.org, ncardwell@google.com, davem@davemloft.net,
 kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, kuni1840@gmail.com,
 netdev@vger.kernel.org
X-In-Reply-To: <20261117053543.84032-4-kuniyu@google.com>
X-sashiko-severity: High
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