๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26523

Re: [PATCH net-next 1/2] ipv6: Use the FIB prefix length when suppressing cached routes

#26523
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 17:34
151 lines
13492 bytes
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
Technical Details
Message-ID: <179631924394.3146.336826619374005468@kernel.org>
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376785-linux-kernel-netdev=dewy.ru
References: <20261202173023.17220-2-leonard@lausen.nl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376785-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179631924394.3146.336826619374005468@kernel.org>
References: <20261202173023.17220-2-leonard@lausen.nl>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2554894"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:N6OpGq6zX9fUh7FaadK7a2Pv1oM= sha256:g9c4aOStcp+PO85+2bBEltRUqzcaRO1pi9lZvSW+G5k=
	sha1:YgDCcsUcodPDuQbbbL2oxKYUbTY= sha256:cU2GFVXLRKZXuYuWBzRz3+CYKHWV70DXlEHSsUFQ+mg=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id F31731179EA; Thu,  3 Dec 2026 20:34:32 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.74
X-Spam-Status: No, score=-3.74 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id N13QHRDRdZTQ;
	Thu,  3 Dec 2026 20:34:29 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376785-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id B65EC1179D4; Thu,  3 Dec 2026 20:34:17 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 4DE21281F6; Thu,  3 Dec 2026 17:34:10 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796319247;
	b=0cavuQT0zGCBAZ8eGC5lD2xVpd7bqdKlgCctkL+0DWvWmDBlAWYs9dRYa+CTnXdKpU9e
	 2geUT2227WfcYMO079DGj8cbBxAFZiN4WEVtGowByAgg/lNRjzlxxXI3kpi3t2TkreIfA
	 P5jH6dO7QDJfxzPowvV/2i0ArCqQq/yySuX5BzSYz5koASBCrPqXc69rI0CC5LqKsY7a6
	 kv6u5QHiWCYW7xS0JSKNukJfNjCNLuzeEd13lwytKahxTrsyYHgjyYWxS4WzQsnQWVO/0
	 9W8/l4H3pCa1gR/lB9G3Tr0kTTSnCgrcswSkk0o2lcQGOXswDIedY7GeGGhrlaZvSDA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796319247;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=XblXgIPBh/JTrvw0njHIhz1RADWLgtQDj9QvCcfZTjY=;
	b=xOeXYNoMDSW5rQNW/sPkND9l0tkHCAhwbLDU5sEx78Hhght++bkKszkhITkd4OLSrqNh
	 uUss4iuLKec+cTUQT0NEqpV2iD9P5T1TaOXV5x1JDBh75MHFnx1UE6WtNr9eZYTFH67En
	 TG94absSubjFcVznJ14ZscJIJC8iLRIDp3Tf685E9t23TOFu7CKJldsXQK78AQJjDfBLb
	 wuKHgxvfeKJQEq2RTi3MAPpqmMU2T/m/Yhj3VoFlV+VTeQLgzVXURubn2KtZhQEqARvGO
	 WKwxiFm2sOkbLCcf+XVEGMSGcHJvzX8SfG2zIa+D5efpE8Dzw/1dSDdy+1QA4lsOK1w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NsDY7vsL;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 22512606A339;
	Thu,  3 Dec 2026 17:34:07 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NsDY7vsL
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796319246;
	b=CP5VB4t84rJYVzb3bMLEMF9qmeupR8LfqxbjYs7rebOQRPE2aft4c9MBjhX6yCYLhVcs
	 7mwTJlU3SnHKW4YNE5AbQ2y0MdeWF7fcrYtkVjhVG1tHKm+VPSx5SaLTNaErhadn2sp3y
	 LHza4HRJwO4qSeVx1UqDnpy4kd4+zA3YioVlAcOFJ5eaoqMQF0IJnTHSbJfBmuBg1M4Fn
	 LpmJMTIWPm8HMLuXPXOf7T6/FTP2ENz7XGiNIa6C62sZCGkL62Rpa4AE8y7gfjJ8x7gat
	 uA/cR5cX9hLqlUlpmszhwNLt6WDXyvCkf4vgXAWVGidji7LQNjImaMP1gl2RQORUfeA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796319246;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=XblXgIPBh/JTrvw0njHIhz1RADWLgtQDj9QvCcfZTjY=;
	b=mVCBpwzMV4hlec0E08oXcy9bTkJAjaH9qqV4ayrKhi2ilX659IEMG7r2ynY5pfIdSIts
	 CNuh/R84hXTCoKfB/XBMhJvmRAkhydnOlUXVpiMw2NMf3z8JET5bnRudiZcow7cg3X2BN
	 4COm0OUliV6qYlehYRIf7wOBjHRn9z6UUIyQJ+L/pEwxnpW5vwsR20ND/W/k6n4f/Fu0J
	 WGQJxKPHBXYjIJGnQfOjdcaBxdaH1WsJDG47IU7QgVvwCFB/kwGc35r3HXWEKNDJKWJv6
	 h4MZHJxAazWUoO7zKJSmmvAosZlBEvnFlyrbntGKmIVaioxZgRdai8b8zBsX+5Nf+GA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NsDY7vsL;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4398E606A32C;
	Thu,  3 Dec 2026 17:34:06 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AC491F00893;
	Thu,  3 Dec 2026 17:34:04 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796319245;
	bh=XblXgIPBh/JTrvw0njHIhz1RADWLgtQDj9QvCcfZTjY=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=NsDY7vsLkD38A0+GCHhpGHGGsp62wxe/uXpJ2Pc3soU9Bl8R4ShVx36q0KSknJAt/
	 uYWSp4Sy+f9Ib1ME4Xz4H/gPiGXH7D5VTe4ixYchDKVbRMzxAAlNSqesAAWAEV99S2
	 LTyOqbVEZt64bYgYhNkWhn4NWF1RqNwlk9k3T1e1KT76/ScgChTm1wFNTqjkPTiUEe
	 Nra+BQxtY2rw7n/NO+1i2405uJsBqkFp3XElGnk4BbBk9JYxr1la5j7DTdSaixeECw
	 WWakai8AXtZKHVz8Cm2FG4HDUH+QwUZLQsQXVJA2NBz+lMhjh9QRYcIui91tURIzFE
	 PF82fhHf560BA==
X-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
X-In-Reply-To: <20261202173023.17220-2-leonard@lausen.nl>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list