IPv6 raw FIB lookups populate f6i and nh in fib6_result, but not rt6.
fib6_rule_suppress() only examines rt6, so fib6_lookup() ignores
suppress_prefixlength and suppress_ifgroup.
With a policy rule that suppresses the main-table default route before
looking in a VPN table, an ordinary route lookup selects the VPN while
an nftables FIB lookup returns the suppressed default. Strict reverse-path
filtering can then drop replies arriving over the VPN. Policy-aware BPF
FIB lookups use the same raw lookup path.
Select the suppression inputs according to the lookup callback. For raw
lookups, use the FIB entry's destination prefix length and the selected
nexthop's device. Keep the existing inputs and destination-reference
handling for dst-based lookups.
Preserve raw results marked RTF_REJECT. The rule engine only calls the
suppression callback when the rule action returns zero. Dst-based lookups
return an error for terminal reject routes and therefore skip suppression,
whereas raw lookups can return zero with a rejection encoded in the result.
Suppressing that result would allow a later rule to bypass the rejection.
Check the result flags so blackhole nexthop objects are covered too.
Investigated with AI assistance after VPN failures on a Samsung laptop.
The original bug was reproduced on unmodified v7.4-rc2 in QEMU without
kernel instrumentation. The final fib6_rules.c compiles without warnings
and its extracted suppression callback passes focused ASan/UBSan tests.
On the rebuilt v7.4-rc2-based laptop kernel, all ten added nft_fib.sh
checks pass. Separate probes also preserve all three terminal reject types
and blackhole nexthop results with and without either suppression option.
Fixes: 138118ec96cb ("net/ipv6: Add fib6_lookup")
Link: https://github.com/firewalld/firewalld/issues/1600
Assisted-by: LLM
Signed-off-by: Leonard Lausen <redacted>
---
net/ipv6/fib6_rules.c | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index 0ffd7b47a046..e8a44b540291 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -283,19 +283,29 @@ INDIRECT_CALLABLE_SCOPE bool fib6_rule_suppress(struct fib_rule *rule,
struct fib_lookup_arg *arg)
{
struct fib6_result *res = arg->result;
- struct rt6_info *rt = res->rt6;
+ struct rt6_info *rt = NULL;
struct net_device *dev = NULL;
-
- if (!rt)
- return false;
-
- if (rt->rt6i_idev)
- dev = rt->rt6i_idev->dev;
+ int plen;
+
+ if (arg->lookup_ptr == fib6_table_lookup) {
+ /* Raw lookups report reject routes without an error. */
+ if (res->fib6_flags & RTF_REJECT)
+ return false;
+ plen = res->f6i->fib6_dst.plen;
+ dev = res->nh->fib_nh_dev;
+ } else {
+ rt = res->rt6;
+ if (!rt)
+ return false;
+ plen = rt->rt6i_dst.plen;
+ if (rt->rt6i_idev)
+ dev = rt->rt6i_idev->dev;
+ }
/* 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;
/* do not accept result if the route uses a device@@ -307,8 +317,10 @@ INDIRECT_CALLABLE_SCOPE bool fib6_rule_suppress(struct fib_rule *rule,
return false;
suppress_route:
- ip6_rt_put_flags(rt, flags);
- res->rt6 = NULL;
+ if (rt) {
+ ip6_rt_put_flags(rt, flags);
+ res->rt6 = NULL;
+ }
return true;
}
--
2.55.0