diff mbox series

[v1,net] tcp: Don't flag tcp_sk(sk)->rx_opt.saw_unknown for TCP AO.

Message ID 20240703033508.6321-1-kuniyu@amazon.com (mailing list archive)
State Accepted
Commit 4b74726c01b7a0b5e1029e1e9247fd81590da726
Delegated to: Netdev Maintainers
Headers show
Series [v1,net] tcp: Don't flag tcp_sk(sk)->rx_opt.saw_unknown for TCP AO. | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 856 this patch: 856
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers fail 2 blamed authors not CCed: fruggeri@arista.com noureddine@arista.com; 2 maintainers not CCed: fruggeri@arista.com noureddine@arista.com
netdev/build_clang success Errors and warnings before: 860 this patch: 860
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 861 this patch: 861
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 13 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 1 this patch: 1
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-07-03--12-00 (tests: 666)

Commit Message

Kuniyuki Iwashima July 3, 2024, 3:35 a.m. UTC
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")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
 net/ipv4/tcp_input.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Eric Dumazet July 3, 2024, 6:14 a.m. UTC | #1
On Wed, Jul 3, 2024 at 5:35 AM Kuniyuki Iwashima <kuniyu@amazon.com> 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")
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>

Reviewed-by: Eric Dumazet <edumazet@google.com>
Dmitry Safonov July 3, 2024, 5:16 p.m. UTC | #2
On Wed, 3 Jul 2024 at 04:35, Kuniyuki Iwashima <kuniyu@amazon.com> 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")
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>

LGTM, thanks!

Acked-by: Dmitry Safonov <0x7f454c46@gmail.com>
Paolo Abeni July 4, 2024, 10:05 a.m. UTC | #3
On Tue, 2024-07-02 at 20:35 -0700, Kuniyuki Iwashima 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")
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
> ---
>  net/ipv4/tcp_input.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index e67cbeeeb95b..77294fd5fd3e 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -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(

[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
patchwork-bot+netdevbpf@kernel.org July 4, 2024, 10:30 a.m. UTC | #4
Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

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")
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
> 
> [...]

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!
Kuniyuki Iwashima July 4, 2024, 6:11 p.m. UTC | #5
From: Paolo Abeni <pabeni@redhat.com>
Date: Thu, 04 Jul 2024 12:05:42 +0200
> On Tue, 2024-07-02 at 20:35 -0700, Kuniyuki Iwashima 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")
> > Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
> > ---
> >  net/ipv4/tcp_input.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> > index e67cbeeeb95b..77294fd5fd3e 100644
> > --- a/net/ipv4/tcp_input.c
> > +++ b/net/ipv4/tcp_input.c
> > @@ -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(
> 
> [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.
diff mbox series

Patch

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index e67cbeeeb95b..77294fd5fd3e 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -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(