All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alice Mikityanska <alice.kernel@fastmail.im>
To: Pablo Neira Ayuso <pablo@netfilter.org>, Florian Westphal <fw@strlen.de>
Cc: Phil Sutter <phil@nwl.cc>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>, Felix Fietkau <nbd@nbd.name>,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	netdev@vger.kernel.org, Alice Mikityanska <alice@isovalent.com>,
	Sashiko <sashiko-bot@kernel.org>
Subject: [PATCH net] netfilter: flowtable: Saturate 16-bit flow_tuple->mtu
Date: Thu, 10 Sep 2026 19:20:52 +0300	[thread overview]
Message-ID: <20260910162052.94648-1-alice.kernel@fastmail.im> (raw)

From: Alice Mikityanska <alice@isovalent.com>

ip6_dst_mtu_maybe_forward clamps its return value to IP6_MAX_MTU, which
is 40 bytes bigger than U16_MAX. While it can be a valid IPv6 MTU (IPv6
payload_len doesn't include the header), this value is assigned to the
16-bit flow_tuple->mtu in flow_offload_fill_route.

To avoid the overflow, use U16_MAX for all MTUs bigger than 65535. Since
flow_tuple->mtu is just a threshold for the software flowtable fast
path, packets exceeding it won't be dropped, but rather punted to the
normal forwarding path: nf_flow_offload_ipv6_forward returns 0, and
nf_flow_offload_ipv6_hook returns NF_ACCEPT.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260901195714.673548-1-alice.kernel%40fastmail.im
Fixes: 4f3780c004ef ("netfilter: nf_flow_table: cache mtu in struct flow_offload_tuple")
Assisted-by: Codex:gpt-5.6-sol
Signed-off-by: Alice Mikityanska <alice@isovalent.com>
---
 net/netfilter/nf_flow_table_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/nf_flow_table_core.c b/net/netfilter/nf_flow_table_core.c
index 03241d4bfd5e..8f15540ae206 100644
--- a/net/netfilter/nf_flow_table_core.c
+++ b/net/netfilter/nf_flow_table_core.c
@@ -107,7 +107,8 @@ static int flow_offload_fill_route(struct flow_offload *flow,
 		flow_tuple->mtu = ip_dst_mtu_maybe_forward(dst, true);
 		break;
 	case NFPROTO_IPV6:
-		flow_tuple->mtu = ip6_dst_mtu_maybe_forward(dst, true);
+		flow_tuple->mtu = min(ip6_dst_mtu_maybe_forward(dst, true),
+				      U16_MAX);
 		break;
 	}
 
-- 
2.55.0


             reply	other threads:[~2026-09-10 16:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10 16:20 Alice Mikityanska [this message]
2026-09-11 11:31 ` [PATCH net] netfilter: flowtable: Saturate 16-bit flow_tuple->mtu Pablo Neira Ayuso

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=20260910162052.94648-1-alice.kernel@fastmail.im \
    --to=alice.kernel@fastmail.im \
    --cc=alice@isovalent.com \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=phil@nwl.cc \
    --cc=sashiko-bot@kernel.org \
    /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 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.