dst_confirm_neigh() is reachable from paths that do not hold an RCU read lock, including rawv6_sendmsg() with MSG_CONFIRM and MSG_PROBE. ip6_confirm_neigh() loads the egress device with dst_dev(). Concurrent route teardown can replace dst->dev with blackhole_netdev and drop the route's reference to the old net_device. The old device can then be freed before ip6_confirm_neigh() finishes using the pointer. An AI-assisted source audit identified the unsafe load. A delay inserted after it to widen the race window reproduced the issue on v7.4-rc3 with KASAN: BUG: KASAN: slab-use-after-free in ip6_confirm_neigh+0x6a7/0xbd0 Read of size 4 ... by task confirm_race/130 Hold the RCU read lock across the callback and use dst_dev_rcu() to load the device. The grace period added to netdev_run_todo() ensures that the device remains alive until the read-side critical section finishes. Fixes: 9514528d92d4 ("ipv6: call dst_dev_put() properly") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/netdev/20261123133000.1.n0ps1edzz@gmail.com/ Signed-off-by: Zhou Qiuyue --- net/ipv6/route.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 1b2dcc066..6bdd4423c 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -257,16 +257,21 @@ static struct neighbour *ip6_dst_neigh_lookup(const struct dst_entry *dst, static void ip6_confirm_neigh(const struct dst_entry *dst, const void *daddr) { const struct rt6_info *rt = dst_rt6_info(dst); - struct net_device *dev = dst_dev(dst); + struct net_device *dev; + + rcu_read_lock(); + dev = dst_dev_rcu(dst); daddr = choose_neigh_daddr(rt6_nexthop(rt, &in6addr_any), NULL, daddr); if (!daddr) - return; + goto out; if (dev->flags & (IFF_NOARP | IFF_LOOPBACK)) - return; + goto out; if (ipv6_addr_is_multicast((const struct in6_addr *)daddr)) - return; + goto out; __ipv6_confirm_neigh(dev, daddr); +out: + rcu_read_unlock(); } static struct dst_ops ip6_dst_ops_template = { -- 2.56.1.windows.1