From: netdev-bot+sashiko@kernel.org
To: kuniyu@google.com
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
Subject: Re: [PATCH v1 net 3/8] tcp: Don't bypass GTSM check for reqsk.
Date: Wed, 18 Nov 2026 20:36:26 +0000 [thread overview]
Message-ID: <179503418639.3136.8004890294182760159@kernel.org> (raw)
In-Reply-To: <20261117053543.84032-4-kuniyu@google.com>
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
next prev parent reply other threads:[~2026-11-18 20:36 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 5:35 [PATCH v1 net 0/8] tcp: Misc fixes for tcp_v[46]_err() Kuniyuki Iwashima
2026-11-17 5:35 ` [PATCH v1 net 1/8] tcp: Don't accept ICMP for SND.NXT in TCP_SYN_SENT Kuniyuki Iwashima
2026-11-17 8:35 ` Eric Dumazet
2026-11-17 23:30 ` Kuniyuki Iwashima
2026-11-17 5:35 ` [PATCH v1 net 2/8] tcp: Don't use inner IP TTL for IP_MINTTL in tcp_v4_err() Kuniyuki Iwashima
2026-11-17 8:42 ` Eric Dumazet
2026-11-17 23:35 ` Kuniyuki Iwashima
2026-11-18 20:36 ` netdev-bot+sashiko
2026-11-17 5:35 ` [PATCH v1 net 3/8] tcp: Don't bypass GTSM check for reqsk Kuniyuki Iwashima
2026-11-17 8:45 ` Eric Dumazet
2026-11-17 23:42 ` Kuniyuki Iwashima
2026-11-18 20:36 ` netdev-bot+sashiko [this message]
2026-11-17 5:35 ` [PATCH v1 net 4/8] tcp: Fix reqsk abort condition on ICMP errors Kuniyuki Iwashima
2026-11-17 8:49 ` Eric Dumazet
2026-11-17 23:44 ` Kuniyuki Iwashima
2026-11-18 20:36 ` netdev-bot+sashiko
2026-11-17 5:35 ` [PATCH v1 net 5/8] tcp: Check ip_sk_accept_pmtu() in tcp_v4_err() Kuniyuki Iwashima
2026-11-17 8:54 ` Eric Dumazet
2026-11-17 5:35 ` [PATCH v1 net 6/8] selftest: net: packetdrill: Add ICMP and ICMPv6 tests Kuniyuki Iwashima
2026-11-17 8:58 ` Eric Dumazet
2026-11-17 23:45 ` Kuniyuki Iwashima
2026-11-17 5:35 ` [PATCH v1 net 7/8] tcp: Pass inet_sdif() to __inet_lookup_established() in tcp_v4_err() Kuniyuki Iwashima
2026-11-17 9:01 ` Eric Dumazet
2026-11-18 20:36 ` netdev-bot+sashiko
2026-11-17 5:35 ` [PATCH v1 net 8/8] tcp: Pass inet6_iif() to __inet6_lookup_established() in tcp_v6_err() Kuniyuki Iwashima
2026-11-17 9:03 ` Eric Dumazet
2026-11-17 23:56 ` Kuniyuki Iwashima
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179503418639.3136.8004890294182760159@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=kuniyu@google.com \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox