Skip to contentSkip to conversation

netfilter: nft_fib_ipv6: handle routes via external nexthop

PATCH Superseded Jiayuan Chen 3 participants 8 messages May 19 – May 20

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 netfilter: nft_fib_ipv6: handle routes via external nexthop

fib6_info has a union:

    union {
        struct list_head fib6_siblings;
        struct list_head nh_list;
    };

Old-style multipath (ip -6 route add ... nexthop ... nexthop ...) uses fib6_siblings. External nexthop (ip -6 route add ... nhid N) uses nh_list, linked into &nh->f6i_list.

nft_fib6_info_nh_uses_dev() blindly walks &rt->fib6_siblings, causing an OOB read past the struct nexthop slab when rt->nh is set:

==================================================================

  BUG: KASAN: slab-out-of-bounds in nft_fib6_eval+0x1362/0x16c0
  Read of size 8 at addr ffff888103a099d0 by task ping/386

  CPU: 2 UID: 0 PID: 386 Comm: ping Not tainted 7.1.0-rc3+ #251 PREEMPT
  Call Trace:
   <IRQ>
   dump_stack_lvl+0x76/0xa0
   print_report+0xd1/0x5f0
   kasan_report+0xe7/0x130
   __asan_report_load8_noabort+0x14/0x30
   nft_fib6_eval+0x1362/0x16c0
   nft_do_chain+0x279/0x18c0
   nft_do_chain_ipv6+0x1a8/0x230
   nf_hook_slow+0xad/0x200
   ipv6_rcv+0x152/0x380
   __netif_receive_skb_one_core+0x118/0x1c0
  ==================================================================

Branch by route shape: when rt->nh is set, walk via nexthop_for_each_fib6_nh() (also covers nh groups, which the original code missed); otherwise walk fib6_siblings, guarded by fib6_nsiblings.

Fixes 1c32b24c234b ("netfilter: nft_fib_ipv6: switch to fib6_lookup")
---
 net/ipv6/netfilter/nft_fib_ipv6.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
net/ipv6/netfilter/nft_fib_ipv6.c +16 -0
index 8b2dba88ee96..a44919f46de9 100644
@@ -160,16 +160,32 @@ static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev,
 	       l3mdev_master_ifindex_rcu(nh_dev) == dev->ifindex;
 }
 
+static int nft_fib6_nh_match_dev_cb(struct fib6_nh *nh, void *arg)
+{
+	const struct net_device *dev = arg;
+
+	return nft_fib6_info_nh_dev_match(nh->fib_nh_dev, dev) ? 1 : 0;
+}
+
 static bool nft_fib6_info_nh_uses_dev(struct fib6_info *rt,
 				      const struct net_device *dev)
 {
 	const struct net_device *nh_dev;
 	struct fib6_info *iter;
 
+	/* External nexthop: fib6_siblings slot aliases nh_list, walk via nh. */
+	if (rt->nh)
+		return nexthop_for_each_fib6_nh(rt->nh,
+						nft_fib6_nh_match_dev_cb,
+						(void *)dev) != 0;
+
 	nh_dev = fib6_info_nh_dev(rt);
 	if (nft_fib6_info_nh_dev_match(nh_dev, dev))
 		return true;
 
+	if (!rt->fib6_nsiblings)
+		return false;
+
 	list_for_each_entry(iter, &rt->fib6_siblings, fib6_siblings) {
 		nh_dev = fib6_info_nh_dev(iter);
 
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/2 selftests: netfilter: add nft_fib_nexthop test

Cover nft_fib6_eval() over three route shapes and reproduce the OOB caused by the blind &rt->fib6_siblings walk:

1) single external nexthop (nhid)
2) external nexthop group (nhid -> group)
3) old-style multipath (nexthop ... nexthop ...)

After the fix:

./nft_fib_nexthop.sh
Nothing to flush
PASS: single external nexthop (nhid)
Flushed 1 nexthops
PASS: nexthop group (nhid group 1/2)
Flushed 2 nexthops
PASS: old-style multipath (fib6_siblings)

---
 .../testing/selftests/net/netfilter/Makefile  |   1 +
 .../net/netfilter/nft_fib_nexthop.sh          | 104 ++++++++++++++++++
 2 files changed, 105 insertions(+)
 create mode 100755 tools/testing/selftests/net/netfilter/nft_fib_nexthop.sh
tools/testing/selftests/net/netfilter/Makefile +1 -0
index ee2d1a5254f8..d953ee218c0f 100644
@@ -26,6 +26,7 @@ TEST_PROGS := \
 	nft_concat_range.sh \
 	nft_conntrack_helper.sh \
 	nft_fib.sh \
+	nft_fib_nexthop.sh \
 	nft_flowtable.sh \
 	nft_interface_stress.sh \
 	nft_meta.sh \
tools/testing/selftests/net/netfilter/nft_fib_nexthop.sh new file +104 -0

104 lines not on this page · raw message

Signature · 1 line
2.43.0
maintainer
#2 lore raw

Re: [PATCH nf 2/2] selftests: netfilter: add nft_fib_nexthop test

Quoted 6 lines · Jiayuan Chen

Cover nft_fib6_eval() over three route shapes and reproduce the OOB caused by the blind &rt->fib6_siblings walk:

1) single external nexthop (nhid)
2) external nexthop group (nhid -> group)
3) old-style multipath (nexthop ... nexthop ...)

https://sashiko.dev/#/patchset/20260519041431.396218-1-jiayuan.chen%40linux.dev

Specifially: 'Does the test need to verify the datapath actually evaluated correctly?' and
'It looks like the test also sets up an nftables counter rule but doesn't verify if the rule actually matched any packets.'

I prefer functionality test over 'bug trap' tests.

#3 lore raw

Re: [PATCH nf 2/2] selftests: netfilter: add nft_fib_nexthop test

Quoted 6 lines · Florian Westphal

Specifially: 'Does the test need to verify the datapath actually evaluated correctly?' and
'It looks like the test also sets up an nftables counter rule but doesn't verify if the rule actually matched any packets.'

I prefer functionality test over 'bug trap' tests.

Agreed -- functional verification is the right approach here.

reviewer
#4 lore raw
In reply to Jiayuan Chen

Hi,

Quoted 48 lines · Jiayuan Chen

fib6_info has a union:

    union {
        struct list_head fib6_siblings;
        struct list_head nh_list;
    };

Old-style multipath (ip -6 route add ... nexthop ... nexthop ...) uses fib6_siblings. External nexthop (ip -6 route add ... nhid N) uses nh_list, linked into &nh->f6i_list.

nft_fib6_info_nh_uses_dev() blindly walks &rt->fib6_siblings, causing an OOB read past the struct nexthop slab when rt->nh is set:

==================================================================

  BUG: KASAN: slab-out-of-bounds in nft_fib6_eval+0x1362/0x16c0
  Read of size 8 at addr ffff888103a099d0 by task ping/386

  CPU: 2 UID: 0 PID: 386 Comm: ping Not tainted 7.1.0-rc3+ #251 PREEMPT
  Call Trace:
   <IRQ>
   dump_stack_lvl+0x76/0xa0
   print_report+0xd1/0x5f0
   kasan_report+0xe7/0x130
   __asan_report_load8_noabort+0x14/0x30
   nft_fib6_eval+0x1362/0x16c0
   nft_do_chain+0x279/0x18c0
   nft_do_chain_ipv6+0x1a8/0x230
   nf_hook_slow+0xad/0x200
   ipv6_rcv+0x152/0x380
   __netif_receive_skb_one_core+0x118/0x1c0
  ==================================================================

Branch by route shape: when rt->nh is set, walk via nexthop_for_each_fib6_nh() (also covers nh groups, which the original code missed); otherwise walk fib6_siblings, guarded by fib6_nsiblings.

Fixes 1c32b24c234b ("netfilter: nft_fib_ipv6: switch to fib6_lookup")
---
 net/ipv6/netfilter/nft_fib_ipv6.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
net/ipv6/netfilter/nft_fib_ipv6.c +0 -0
index 8b2dba88ee96..a44919f46de9 100644

net/ipv6/netfilter/nft_fib_ipv6.c static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev, · line 167

Quoted 8 lines
net/ipv6/netfilter/nft_fib_ipv6.c +5 -0
@@ -160,16 +160,32 @@ static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev,
 	       l3mdev_master_ifindex_rcu(nh_dev) == dev->ifindex;
 }
 
+static int nft_fib6_nh_match_dev_cb(struct fib6_nh *nh, void *arg)
+{
+	const struct net_device *dev = arg;
+
+	return nft_fib6_info_nh_dev_match(nh->fib_nh_dev, dev) ? 1 : 0;

Why the ternary here? The function returns bool, but the iterator merely checks the value for 0 and caller returns the value as bool as well.

net/ipv6/netfilter/nft_fib_ipv6.c static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev, · line 180

Quoted 13 lines
net/ipv6/netfilter/nft_fib_ipv6.c +7 -0
+}
+
 static bool nft_fib6_info_nh_uses_dev(struct fib6_info *rt,
 				      const struct net_device *dev)
 {
 	const struct net_device *nh_dev;
 	struct fib6_info *iter;
 
+	/* External nexthop: fib6_siblings slot aliases nh_list, walk via nh. */
+	if (rt->nh)
+		return nexthop_for_each_fib6_nh(rt->nh,
+						nft_fib6_nh_match_dev_cb,
+						(void *)dev) != 0;

As above, the '!= 0' is not needed, is it?

net/ipv6/netfilter/nft_fib_ipv6.c static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev, · line 186

Quoted 6 lines
net/ipv6/netfilter/nft_fib_ipv6.c +2 -0
+
 	nh_dev = fib6_info_nh_dev(rt);
 	if (nft_fib6_info_nh_dev_match(nh_dev, dev))
 		return true;
 
+	if (!rt->fib6_nsiblings)

Should this access using READ_ONCE() as per commit 31d7d67ba127 ("ipv6:
annotate data-races around rt->fib6_nsiblings")?

net/ipv6/netfilter/nft_fib_ipv6.c static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev, · line 190

Quoted 4 lines
net/ipv6/netfilter/nft_fib_ipv6.c +2 -0
+		return false;
+
 	list_for_each_entry(iter, &rt->fib6_siblings, fib6_siblings) {
 		nh_dev = fib6_info_nh_dev(iter);

I thought about open-coding this to void the need for the callback wrapper, but it's not worth it.

Cheers, Phil

#5 lore raw

Hi Phil,

Thanks for your review.

Quoted 70 lines · Phil Sutter

Hi,

Quoted 48 lines · Jiayuan Chen

fib6_info has a union:

     union {
         struct list_head fib6_siblings;
         struct list_head nh_list;
     };

Old-style multipath (ip -6 route add ... nexthop ... nexthop ...) uses fib6_siblings. External nexthop (ip -6 route add ... nhid N) uses nh_list, linked into &nh->f6i_list.

nft_fib6_info_nh_uses_dev() blindly walks &rt->fib6_siblings, causing an OOB read past the struct nexthop slab when rt->nh is set:

   ==================================================================
   BUG: KASAN: slab-out-of-bounds in nft_fib6_eval+0x1362/0x16c0
   Read of size 8 at addr ffff888103a099d0 by task ping/386

   CPU: 2 UID: 0 PID: 386 Comm: ping Not tainted 7.1.0-rc3+ #251 PREEMPT
   Call Trace:
    <IRQ>
    dump_stack_lvl+0x76/0xa0
    print_report+0xd1/0x5f0
    kasan_report+0xe7/0x130
    __asan_report_load8_noabort+0x14/0x30
    nft_fib6_eval+0x1362/0x16c0
    nft_do_chain+0x279/0x18c0
    nft_do_chain_ipv6+0x1a8/0x230
    nf_hook_slow+0xad/0x200
    ipv6_rcv+0x152/0x380
    __netif_receive_skb_one_core+0x118/0x1c0
   ==================================================================

Branch by route shape: when rt->nh is set, walk via nexthop_for_each_fib6_nh() (also covers nh groups, which the original code missed); otherwise walk fib6_siblings, guarded by fib6_nsiblings.

Fixes 1c32b24c234b ("netfilter: nft_fib_ipv6: switch to fib6_lookup")
---
  net/ipv6/netfilter/nft_fib_ipv6.c | 16 ++++++++++++++++
  1 file changed, 16 insertions(+)
net/ipv6/netfilter/nft_fib_ipv6.c +0 -0
index 8b2dba88ee96..a44919f46de9 100644

net/ipv6/netfilter/nft_fib_ipv6.c static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev, · line 167

Quoted 8 lines
net/ipv6/netfilter/nft_fib_ipv6.c +5 -0
@@ -160,16 +160,32 @@ static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev,
  	       l3mdev_master_ifindex_rcu(nh_dev) == dev->ifindex;
  }
 
+static int nft_fib6_nh_match_dev_cb(struct fib6_nh *nh, void *arg)
+{
+	const struct net_device *dev = arg;
+
+	return nft_fib6_info_nh_dev_match(nh->fib_nh_dev, dev) ? 1 : 0;

Why the ternary here? The function returns bool, but the iterator merely checks the value for 0 and caller returns the value as bool as well.

Quoted 8 lines
net/ipv6/netfilter/nft_fib_ipv6.c +2 -0
+}
+
  static bool nft_fib6_info_nh_uses_dev(struct fib6_info *rt,
  				      const struct net_device *dev)
  {
  	const struct net_device *nh_dev;
  	struct fib6_info *iter;
 
Quoted 5 lines

net/ipv6/netfilter/nft_fib_ipv6.c static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev, · line 180

Quoted 5 lines
net/ipv6/netfilter/nft_fib_ipv6.c +5 -0
+	/* External nexthop: fib6_siblings slot aliases nh_list, walk via nh. */
+	if (rt->nh)
+		return nexthop_for_each_fib6_nh(rt->nh,
+						nft_fib6_nh_match_dev_cb,
+						(void *)dev) != 0;

All make sense !

Quoted 8 lines

net/ipv6/netfilter/nft_fib_ipv6.c static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev, · line 186

Quoted 6 lines
net/ipv6/netfilter/nft_fib_ipv6.c +2 -0
+
  	nh_dev = fib6_info_nh_dev(rt);
  	if (nft_fib6_info_nh_dev_match(nh_dev, dev))
  		return true;
 
+	if (!rt->fib6_nsiblings)

Should this access using READ_ONCE() as per commit 31d7d67ba127 ("ipv6:
annotate data-races around rt->fib6_nsiblings")?

You are right, we need READ_ONCE since fib6_add_rt2node will modify @fib6_nsiblings .

Quoted 3 lines

net/ipv6/netfilter/nft_fib_ipv6.c static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev, · line 189

Quoted 3 lines
net/ipv6/netfilter/nft_fib_ipv6.c +2 -0
+		return false;
+
  	list_for_each_entry(iter, &rt->fib6_siblings, fib6_siblings) {

Now I think we should also change list_for_each_entry  into list_for_each_entry_rcu for the same reason.

But I'm not sure whether it is appropriate or not since this patch target to commit in Fiexes tag.

May be a followup patch is necessary.

Quoted 5 lines

net/ipv6/netfilter/nft_fib_ipv6.c static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev, · line 190

Quoted 1 line
net/ipv6/netfilter/nft_fib_ipv6.c +0 -0
  		nh_dev = fib6_info_nh_dev(iter);

I thought about open-coding this to void the need for the callback wrapper, but it's not worth it.

Cheers, Phil

reviewer
#6 lore raw

On Tue, May 19, 2026 at 06:50:55PM +0800, Jiayuan Chen wrote:
[...]

Quoted 95 lines · Phil Sutter
Quoted 70 lines

Hi,

Quoted 48 lines · Jiayuan Chen

fib6_info has a union:

     union {
         struct list_head fib6_siblings;
         struct list_head nh_list;
     };

Old-style multipath (ip -6 route add ... nexthop ... nexthop ...) uses fib6_siblings. External nexthop (ip -6 route add ... nhid N) uses nh_list, linked into &nh->f6i_list.

nft_fib6_info_nh_uses_dev() blindly walks &rt->fib6_siblings, causing an OOB read past the struct nexthop slab when rt->nh is set:

   ==================================================================
   BUG: KASAN: slab-out-of-bounds in nft_fib6_eval+0x1362/0x16c0
   Read of size 8 at addr ffff888103a099d0 by task ping/386

   CPU: 2 UID: 0 PID: 386 Comm: ping Not tainted 7.1.0-rc3+ #251 PREEMPT
   Call Trace:
    <IRQ>
    dump_stack_lvl+0x76/0xa0
    print_report+0xd1/0x5f0
    kasan_report+0xe7/0x130
    __asan_report_load8_noabort+0x14/0x30
    nft_fib6_eval+0x1362/0x16c0
    nft_do_chain+0x279/0x18c0
    nft_do_chain_ipv6+0x1a8/0x230
    nf_hook_slow+0xad/0x200
    ipv6_rcv+0x152/0x380
    __netif_receive_skb_one_core+0x118/0x1c0
   ==================================================================

Branch by route shape: when rt->nh is set, walk via nexthop_for_each_fib6_nh() (also covers nh groups, which the original code missed); otherwise walk fib6_siblings, guarded by fib6_nsiblings.

Fixes 1c32b24c234b ("netfilter: nft_fib_ipv6: switch to fib6_lookup")
---
  net/ipv6/netfilter/nft_fib_ipv6.c | 16 ++++++++++++++++
  1 file changed, 16 insertions(+)
net/ipv6/netfilter/nft_fib_ipv6.c +0 -0
index 8b2dba88ee96..a44919f46de9 100644

net/ipv6/netfilter/nft_fib_ipv6.c static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev, · line 167

Quoted 8 lines
net/ipv6/netfilter/nft_fib_ipv6.c +5 -0
@@ -160,16 +160,32 @@ static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev,
  	       l3mdev_master_ifindex_rcu(nh_dev) == dev->ifindex;
  }
 
+static int nft_fib6_nh_match_dev_cb(struct fib6_nh *nh, void *arg)
+{
+	const struct net_device *dev = arg;
+
+	return nft_fib6_info_nh_dev_match(nh->fib_nh_dev, dev) ? 1 : 0;

Why the ternary here? The function returns bool, but the iterator merely checks the value for 0 and caller returns the value as bool as well.

Quoted 8 lines
net/ipv6/netfilter/nft_fib_ipv6.c +2 -0
+}
+
  static bool nft_fib6_info_nh_uses_dev(struct fib6_info *rt,
  				      const struct net_device *dev)
  {
  	const struct net_device *nh_dev;
  	struct fib6_info *iter;
 
Quoted 5 lines

net/ipv6/netfilter/nft_fib_ipv6.c static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev, · line 180

Quoted 5 lines
net/ipv6/netfilter/nft_fib_ipv6.c +5 -0
+	/* External nexthop: fib6_siblings slot aliases nh_list, walk via nh. */
+	if (rt->nh)
+		return nexthop_for_each_fib6_nh(rt->nh,
+						nft_fib6_nh_match_dev_cb,
+						(void *)dev) != 0;

All make sense !

Quoted 8 lines

net/ipv6/netfilter/nft_fib_ipv6.c static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev, · line 186

Quoted 6 lines
net/ipv6/netfilter/nft_fib_ipv6.c +2 -0
+
  	nh_dev = fib6_info_nh_dev(rt);
  	if (nft_fib6_info_nh_dev_match(nh_dev, dev))
  		return true;
 
+	if (!rt->fib6_nsiblings)

Should this access using READ_ONCE() as per commit 31d7d67ba127 ("ipv6:
annotate data-races around rt->fib6_nsiblings")?

You are right, we need READ_ONCE since fib6_add_rt2node will modify @fib6_nsiblings .

Quoted 7 lines
Quoted 3 lines

net/ipv6/netfilter/nft_fib_ipv6.c static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev, · line 189

Quoted 3 lines
net/ipv6/netfilter/nft_fib_ipv6.c +2 -0
+		return false;
+
  	list_for_each_entry(iter, &rt->fib6_siblings, fib6_siblings) {

Now I think we should also change list_for_each_entry  into list_for_each_entry_rcu for the same reason.

Seems legit! I missed that one because most examples in net/ipv6/route.c use a non-RCU variant, I guess because exclusive access is ensured via other means.

Quoted 4 lines

But I'm not sure whether it is appropriate or not since this patch target to commit in Fiexes tag.

May be a followup patch is necessary.

I'd submit the _rcu fix in an initial patch of the series, so the one introducing the fib6_nsiblings check extends correct code (using _rcu) with a correct pattern (READ_ONCE).

Thanks, Phil

#7 lore raw
Quoted 108 lines · Phil Sutter

On Tue, May 19, 2026 at 06:50:55PM +0800, Jiayuan Chen wrote:
[...]

Quoted 93 lines · Phil Sutter
Quoted 70 lines

Hi,

Quoted 48 lines · Jiayuan Chen

fib6_info has a union:

      union {
          struct list_head fib6_siblings;
          struct list_head nh_list;
      };

Old-style multipath (ip -6 route add ... nexthop ... nexthop ...) uses fib6_siblings. External nexthop (ip -6 route add ... nhid N) uses nh_list, linked into &nh->f6i_list.

nft_fib6_info_nh_uses_dev() blindly walks &rt->fib6_siblings, causing an OOB read past the struct nexthop slab when rt->nh is set:

    ==================================================================
    BUG: KASAN: slab-out-of-bounds in nft_fib6_eval+0x1362/0x16c0
    Read of size 8 at addr ffff888103a099d0 by task ping/386

    CPU: 2 UID: 0 PID: 386 Comm: ping Not tainted 7.1.0-rc3+ #251 PREEMPT
    Call Trace:
     <IRQ>
     dump_stack_lvl+0x76/0xa0
     print_report+0xd1/0x5f0
     kasan_report+0xe7/0x130
     __asan_report_load8_noabort+0x14/0x30
     nft_fib6_eval+0x1362/0x16c0
     nft_do_chain+0x279/0x18c0
     nft_do_chain_ipv6+0x1a8/0x230
     nf_hook_slow+0xad/0x200
     ipv6_rcv+0x152/0x380
     __netif_receive_skb_one_core+0x118/0x1c0
    ==================================================================

Branch by route shape: when rt->nh is set, walk via nexthop_for_each_fib6_nh() (also covers nh groups, which the original code missed); otherwise walk fib6_siblings, guarded by fib6_nsiblings.

Fixes 1c32b24c234b ("netfilter: nft_fib_ipv6: switch to fib6_lookup")
---
   net/ipv6/netfilter/nft_fib_ipv6.c | 16 ++++++++++++++++
   1 file changed, 16 insertions(+)
net/ipv6/netfilter/nft_fib_ipv6.c +0 -0
index 8b2dba88ee96..a44919f46de9 100644

net/ipv6/netfilter/nft_fib_ipv6.c static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev, · line 167

Quoted 8 lines
net/ipv6/netfilter/nft_fib_ipv6.c +5 -0
@@ -160,16 +160,32 @@ static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev,
   	       l3mdev_master_ifindex_rcu(nh_dev) == dev->ifindex;
   }
 
+static int nft_fib6_nh_match_dev_cb(struct fib6_nh *nh, void *arg)
+{
+	const struct net_device *dev = arg;
+
+	return nft_fib6_info_nh_dev_match(nh->fib_nh_dev, dev) ? 1 : 0;

Why the ternary here? The function returns bool, but the iterator merely checks the value for 0 and caller returns the value as bool as well.

Quoted 8 lines
net/ipv6/netfilter/nft_fib_ipv6.c +2 -0
+}
+
   static bool nft_fib6_info_nh_uses_dev(struct fib6_info *rt,
   				      const struct net_device *dev)
   {
   	const struct net_device *nh_dev;
   	struct fib6_info *iter;
 
Quoted 5 lines

net/ipv6/netfilter/nft_fib_ipv6.c static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev, · line 180

Quoted 5 lines
net/ipv6/netfilter/nft_fib_ipv6.c +5 -0
+	/* External nexthop: fib6_siblings slot aliases nh_list, walk via nh. */
+	if (rt->nh)
+		return nexthop_for_each_fib6_nh(rt->nh,
+						nft_fib6_nh_match_dev_cb,
+						(void *)dev) != 0;

All make sense !

Quoted 8 lines

net/ipv6/netfilter/nft_fib_ipv6.c static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev, · line 186

Quoted 6 lines
net/ipv6/netfilter/nft_fib_ipv6.c +2 -0
+
   	nh_dev = fib6_info_nh_dev(rt);
   	if (nft_fib6_info_nh_dev_match(nh_dev, dev))
   		return true;
 
+	if (!rt->fib6_nsiblings)

Should this access using READ_ONCE() as per commit 31d7d67ba127 ("ipv6:
annotate data-races around rt->fib6_nsiblings")?

You are right, we need READ_ONCE since fib6_add_rt2node will modify @fib6_nsiblings .

Quoted 6 lines
Quoted 3 lines

net/ipv6/netfilter/nft_fib_ipv6.c static bool nft_fib6_info_nh_dev_match(const struct net_device *nh_dev, · line 189

Quoted 3 lines
net/ipv6/netfilter/nft_fib_ipv6.c +2 -0
+		return false;
+
   	list_for_each_entry(iter, &rt->fib6_siblings, fib6_siblings) {

Now I think we should also change list_for_each_entry  into list_for_each_entry_rcu for the same reason.

Seems legit! I missed that one because most examples in net/ipv6/route.c use a non-RCU variant, I guess because exclusive access is ensured via other means.

Quoted 3 lines

But I'm not sure whether it is appropriate or not since this patch target to commit in Fiexes tag.

Quoted 6 lines
Quoted 1 line

May be a followup patch is necessary.

I'd submit the _rcu fix in an initial patch of the series, so the one introducing the fib6_nsiblings check extends correct code (using _rcu) with a correct pattern (READ_ONCE).

Thanks, Phil

Got it - will respin as v2.
Sending after a short cool-down.

Respect