Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: leonard@lausen.nl
Cc: netdev@vger.kernel.org, dsahern@kernel.org, idosch@nvidia.com,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, willemb@google.com, horms@kernel.org,
	pablo@netfilter.org, fw@strlen.de, phil@nwl.cc, shuah@kernel.org,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net-next 1/2] ipv6: Use the FIB prefix length when suppressing cached routes
Date: Thu, 03 Dec 2026 17:34:03 +0000	[thread overview]
Message-ID: <179631924394.3146.336826619374005468@kernel.org> (raw)
In-Reply-To: <20261202173023.17220-2-leonard@lausen.nl>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 1

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] The fix reads the prefix length from rt->from, the route that
  created the cached exception.
- [Low] Baseline decision: false positive.

--

ipv6: Use the FIB prefix length when suppressing cached routes

This patch changes fib6_rule_suppress() so that suppress_prefixlen is
compared against the prefix length of the parent FIB entry (rt->from)
instead of rt6i_dst.plen. PMTU and redirect exceptions are /128 even under
a default route, so they could slip past suppress_prefixlength 0. If the
parent is gone, the old rt6i_dst.plen check is still used.

Link: https://lore.kernel.org/netdev/20261117091340.GA581197@shredder/

> diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
> index 7efb0515b5c8b..2f43e4e48e0d0 100644
> --- a/net/ipv6/fib6_rules.c
> +++ b/net/ipv6/fib6_rules.c

[ ... ]

> @@ -298,10 +300,13 @@ INDIRECT_CALLABLE_SCOPE bool fib6_rule_suppress(struct fib_rule *rule,
>  	if (rt->rt6i_idev)
>  		dev = rt->rt6i_idev->dev;
>  
> +	from = rcu_dereference(rt->from);
> +	plen = from ? from->fib6_dst.plen : rt->rt6i_dst.plen;
> +

[Severity: High]
Is rt->from always the fib6_info that was matched in the table this rule
is evaluating?

When routes use nexthop objects, the exception bucket lives in the
nexthop's shared fib6_nh. Every fib6_info that references the same nhid
shares that bucket, across tables. fib6_check_nexthop() says as much:

net/ipv4/nexthop.c:fib6_check_nexthop() {
	/* fib6_src is unique to a fib6_info and limits the ability to cache
	 * routes in fib6_nh within a nexthop that is potentially shared
	 * across multiple fib entries.
	...
}

ip6_pol_route()->rt6_find_cached_rt() finds the bucket through res->nh.
It then matches only on daddr, plus saddr when subtrees are enabled:

net/ipv6/route.c:rt6_find_cached_rt() {
	...
	bucket = fib6_nh_get_excptn_bucket(res->nh, NULL);
	rt6_ex = __rt6_find_exception_rcu(&bucket, daddr, src_key);
	...
}

Nothing checks that rt6_ex->rt6i->from == res->f6i. One bucket can hold
exceptions with different parents, which is why
fib6_nh_flush_exceptions() filters on ->from:

net/ipv6/route.c:fib6_nh_flush_exceptions() {
	...
			if (!from ||
			    rcu_access_pointer(rt6_ex->rt6i->from) == from)
				rt6_remove_exception(bucket, rt6_ex);
	...
}

Can the bypass still happen with a setup like this?

  ip -6 rule add fwmark 1 lookup 200
  ip -6 rule add lookup main suppress_prefixlength 0
  ip -6 rule add lookup 100        (VPN table)

  table 200: 2001:db8::/32 via nhid 1
  main:      default via nhid 1

1. A remote ICMPv6 Packet Too Big arrives for a marked flow to D.
   __ip6_rt_update_pmtu() sets res.f6i to the /32 route and res.nh to the
   shared fib6_nh, then calls rt6_insert_exception().

2. An unmarked flow to D matches the default route in main.
   rt6_find_cached_rt() returns the exception from step 1.

3. fib6_rule_suppress() computes plen as 32. That is greater than 0, so
   the route is not suppressed.

The traffic then leaves via main instead of falling through to table 100.

The opposite direction looks like a new regression. Suppose the exception
was created through a default route (from->fib6_dst.plen == 0), and
another table matches a more specific route on the same nexthop:

- The old code saw plen 128 and accepted the route.
- With this patch, plen is 0, so the specific route is suppressed and the
  lookup falls through to later rules.

The fib6_table_lookup branch above already uses res->f6i->fib6_dst.plen,
which is the entry matched in this table. On the rt6_info path, the
matched res.f6i in ip6_pol_route() is dropped before fib6_rule_suppress()
runs.

Could the matched entry be passed through instead? Another option would
be for rt6_find_cached_rt() to skip exceptions whose ->from does not match
res->f6i.

The selftest added later in the series does not use nexthop objects, so it
would not catch this case.

>  	/* do not accept result if the route does
>  	 * not meet the required prefix length
>  	 */
> -	if (rt->rt6i_dst.plen <= rule->suppress_prefixlen)
> +	if (plen <= rule->suppress_prefixlen)
>  		goto suppress_route;

[Severity: Low]
This isn't a bug, but with only this patch applied, no in-tree test
reaches the rt6_info branch of fib6_rule_suppress() with a cached /128
exception under suppress_prefixlength 0.

The IPv6 suppression cases in nft_fib.sh go through fib6_lookup() with
lookup_ptr == fib6_table_lookup. fib_suppress_test() in fib_tests.sh only
checks that nothing crashes.

The next patch in the series closes this gap. It is "selftests:
netfilter: cover IPv6 prefix suppression with a PMTU exception" and adds a
"suppress cached default route" case to nft_fib.sh.

That case creates an MTU 1280 exception under the default route. It then
checks the device returned by:

  ip -6 route get dead:1::99 from dead:1::1

That lookup goes through ip6_pol_route() and reaches the new rt->from
logic.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202173023.17220-1-leonard%40lausen.nl

  parent reply	other threads:[~2026-12-03 17:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 17:30 [PATCH net-next 0/2] ipv6: Use the FIB prefix length to suppress cached routes Leonard Lausen
2026-12-02 17:30 ` [PATCH net-next 1/2] ipv6: Use the FIB prefix length when suppressing " Leonard Lausen
2026-12-03  9:02   ` Ido Schimmel
2026-12-03 17:34   ` netdev-bot+sashiko [this message]
2026-12-02 17:30 ` [PATCH net-next 2/2] selftests: netfilter: cover IPv6 prefix suppression with a PMTU exception Leonard Lausen
2026-12-03 17:34   ` netdev-bot+sashiko

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=179631924394.3146.336826619374005468@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=leonard@lausen.nl \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=phil@nwl.cc \
    --cc=shuah@kernel.org \
    --cc=willemb@google.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