Skip to contentSkip to conversation

tcp: Don't flag tcp_sk(sk)->rx_opt.saw_unknown for TCP AO.

PATCH Applied Kuniyuki Iwashima 5 participants 6 messages Jul 3, 2024 – Jul 4, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcp: Don't flag tcp_sk(sk)->rx_opt.saw_unknown for TCP AO.

When we process segments with TCP AO, we don't check it in tcp_parse_options(). Thus, opt_rx->saw_unknown is set to 1, which unconditionally triggers the BPF TCP option parser.

Let's avoid the unnecessary BPF invocation.

Fixes 0a3a809089eb ("net/tcp: Verify inbound TCP-AO signed segments")
---
 net/ipv4/tcp_input.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/ipv4/tcp_input.c +7 -0
index e67cbeeeb95b..77294fd5fd3e 100644
@@ -4223,6 +4223,13 @@ void tcp_parse_options(const struct net *net,
 				 * checked (see tcp_v{4,6}_rcv()).
 				 */
 				break;
+#endif
+#ifdef CONFIG_TCP_AO
+			case TCPOPT_AO:
+				/* TCP AO has already been checked
+				 * (see tcp_inbound_ao_hash()).
+				 */
+				break;
 #endif
 			case TCPOPT_FASTOPEN:
 				tcp_parse_fastopen_option(
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Kuniyuki Iwashima

When we process segments with TCP AO, we don't check it in tcp_parse_options(). Thus, opt_rx->saw_unknown is set to 1, which unconditionally triggers the BPF TCP option parser.

Let's avoid the unnecessary BPF invocation.

Fixes 0a3a809089eb ("net/tcp: Verify inbound TCP-AO signed segments")
Acked-by on v1 1/1
#2 lore raw
In reply to Kuniyuki Iwashima
Quoted 9 lines · Kuniyuki Iwashima

When we process segments with TCP AO, we don't check it in tcp_parse_options(). Thus, opt_rx->saw_unknown is set to 1, which unconditionally triggers the BPF TCP option parser.

Let's avoid the unnecessary BPF invocation.

Fixes 0a3a809089eb ("net/tcp: Verify inbound TCP-AO signed segments")

LGTM, thanks!

Signature · 1 line
             Dmitry
maintainer
#3 lore raw
In reply to Kuniyuki Iwashima
Quoted 20 lines · Kuniyuki Iwashima

When we process segments with TCP AO, we don't check it in tcp_parse_options(). Thus, opt_rx->saw_unknown is set to 1, which unconditionally triggers the BPF TCP option parser.

Let's avoid the unnecessary BPF invocation.

Fixes 0a3a809089eb ("net/tcp: Verify inbound TCP-AO signed segments")
---
 net/ipv4/tcp_input.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/ipv4/tcp_input.c +0 -0
index e67cbeeeb95b..77294fd5fd3e 100644
@@ -4223,6 +4223,13 @@ void tcp_parse_options(const struct net *net,
 				 * checked (see tcp_v{4,6}_rcv()).
 				 */
 				break;

net/ipv4/tcp_input.c void tcp_parse_options(const struct net *net, · line 4235

Quoted 10 lines
net/ipv4/tcp_input.c +7 -0
+#endif
+#ifdef CONFIG_TCP_AO
+			case TCPOPT_AO:
+				/* TCP AO has already been checked
+				 * (see tcp_inbound_ao_hash()).
+				 */
+				break;
 #endif
 			case TCPOPT_FASTOPEN:
 				tcp_parse_fastopen_option(

[not strictly related to this patch] possibly even MPTCP could benefit from a similar change, but I'm unsure if we want to add even more cases to this statement.

Cheers,

Paolo

#4 lore raw

From: Paolo Abeni <[email protected]>
Date: Thu, 04 Jul 2024 12:05:42 +0200

Quoted 27 lines · Kuniyuki Iwashima
Quoted 26 lines

When we process segments with TCP AO, we don't check it in tcp_parse_options(). Thus, opt_rx->saw_unknown is set to 1, which unconditionally triggers the BPF TCP option parser.

Let's avoid the unnecessary BPF invocation.

Fixes 0a3a809089eb ("net/tcp: Verify inbound TCP-AO signed segments")
---
 net/ipv4/tcp_input.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/ipv4/tcp_input.c +6 -0
index e67cbeeeb95b..77294fd5fd3e 100644
@@ -4223,6 +4223,13 @@ void tcp_parse_options(const struct net *net,
 				 * checked (see tcp_v{4,6}_rcv()).
 				 */
 				break;
+#endif
+#ifdef CONFIG_TCP_AO
+			case TCPOPT_AO:
+				/* TCP AO has already been checked
+				 * (see tcp_inbound_ao_hash()).
+				 */
Quoted 8 lines

net/ipv4/tcp_input.c void tcp_parse_options(const struct net *net, · line 4235

Quoted 4 lines
net/ipv4/tcp_input.c +1 -0
+				break;
 #endif
 			case TCPOPT_FASTOPEN:
 				tcp_parse_fastopen_option(

[not strictly related to this patch] possibly even MPTCP could benefit from a similar change, but I'm unsure if we want to add even more cases to this statement.

Exactly, it seem no one has tried to inject/parse a new option with MPTCP.

#5 lore raw
In reply to Kuniyuki Iwashima
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

Quoted 10 lines · On Tue, 2 Jul 2024 20:35:08 -0700 you wrote:

When we process segments with TCP AO, we don't check it in tcp_parse_options(). Thus, opt_rx->saw_unknown is set to 1, which unconditionally triggers the BPF TCP option parser.

Let's avoid the unnecessary BPF invocation.

Fixes 0a3a809089eb ("net/tcp: Verify inbound TCP-AO signed segments")

[...]

Here is the summary with links:
- [v1,net] tcp: Don't flag tcp_sk(sk)->rx_opt.saw_unknown for TCP AO.

    https://git.kernel.org/netdev/net/c/4b74726c01b7

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html