All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 nf] netfilter: nft_exthdr: stop the TCP option walk at EOL
@ 2026-11-21  5:54 Ryosuke Iwahashi
  2026-11-21  6:01 ` Florian Westphal
  0 siblings, 1 reply; 2+ messages in thread
From: Ryosuke Iwahashi @ 2026-11-21  5:54 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Florian Westphal; +Cc: Phil Sutter, netfilter-devel

RFC 9293 section 3.1 requires zero padding after the TCP End of Option
List (EOL). The nftables expressions that read, set or strip TCP options
keep searching this padding for the target option.

Stop the search for other option kinds at the first EOL. Keep the
existing behavior for explicit EOL matches.

Fixes: 935b7f643018 ("netfilter: nft_exthdr: add TCP option matching")
Signed-off-by: Ryosuke Iwahashi <ryosuke@ikotaslabs.com>
---
v2: Resend without line wrapping.

 net/netfilter/nft_exthdr.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/net/netfilter/nft_exthdr.c b/net/netfilter/nft_exthdr.c
index 861bab93f435..ce5494cfd4e8 100644
--- a/net/netfilter/nft_exthdr.c
+++ b/net/netfilter/nft_exthdr.c
@@ -204,8 +204,11 @@ static void nft_exthdr_tcp_eval(const struct nft_expr *expr,
 	for (i = sizeof(*tcph); i < tcphdr_len - 1; i += optl) {
 		optl = optlen(opt, i);
 
-		if (priv->type != opt[i])
+		if (priv->type != opt[i]) {
+			if (opt[i] == TCPOPT_EOL)
+				break;
 			continue;
+		}
 
 		if (i + optl > tcphdr_len || priv->len + priv->offset > optl)
 			goto err;
@@ -264,8 +267,11 @@ static void nft_exthdr_tcp_set_eval(const struct nft_expr *expr,
 
 		optl = optlen(opt, i);
 
-		if (priv->type != opt[i])
+		if (priv->type != opt[i]) {
+			if (opt[i] == TCPOPT_EOL)
+				break;
 			continue;
+		}
 
 		if (i + optl > tcphdr_len || priv->len + priv->offset > optl)
 			goto err;
@@ -347,8 +353,11 @@ static void nft_exthdr_tcp_strip_eval(const struct nft_expr *expr,
 		unsigned int j;
 
 		optl = optlen(opt, i);
-		if (priv->type != opt[i])
+		if (priv->type != opt[i]) {
+			if (opt[i] == TCPOPT_EOL)
+				break;
 			continue;
+		}
 
 		if (i + optl > tcphdr_len)
 			goto drop;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 nf] netfilter: nft_exthdr: stop the TCP option walk at EOL
  2026-11-21  5:54 [PATCH v2 nf] netfilter: nft_exthdr: stop the TCP option walk at EOL Ryosuke Iwahashi
@ 2026-11-21  6:01 ` Florian Westphal
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Westphal @ 2026-11-21  6:01 UTC (permalink / raw)
  To: Ryosuke Iwahashi; +Cc: Pablo Neira Ayuso, Phil Sutter, netfilter-devel

Ryosuke Iwahashi <ryosuke@ikotaslabs.com> wrote:
> RFC 9293 section 3.1 requires zero padding after the TCP End of Option
> List (EOL). The nftables expressions that read, set or strip TCP options
> keep searching this padding for the target option.
> 
> Stop the search for other option kinds at the first EOL. Keep the
> existing behavior for explicit EOL matches.

Why should this be changed?

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-21  6:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-21  5:54 [PATCH v2 nf] netfilter: nft_exthdr: stop the TCP option walk at EOL Ryosuke Iwahashi
2026-11-21  6:01 ` Florian Westphal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.