๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by netdev-bot+sashiko Wed, 18 Nov 2026 20:36
Re: [PATCH v1 net 3/8] tcp: Don't bypass GTSM check for reqsk.
#18754
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads