From: Ido Schimmel <idosch@nvidia.com>
To: David Ahern <dsahern@kernel.org>
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
ralf@mandelbit.com, ja@ssi.bg, David Ahern <dahern@nvidia.com>
Subject: Re: [PATCH net-next v3 02/13] ipv6: keep a superseded pcpu dst working until its holders notice
Date: Wed, 2 Dec 2026 18:19:42 +0200 [thread overview]
Message-ID: <20261202161942.GA2800642@shredder> (raw)
In-Reply-To: <20261201174021.7211-3-dsahern@kernel.org>
On Tue, Dec 01, 2026 at 10:40:03AM -0700, David Ahern wrote:
> From: David Ahern <dahern@nvidia.com>
>
> When rt6_get_pcpu_route() finds that a pcpu dst of a route using a
> nexthop object has been invalidated, it takes the dst out of its slot
> and calls dst_dev_put() on it. That points the dst at the blackhole
> device and makes its output a discard, although the dst may still be
> held: by a socket, a tunnel dst_cache, an xfrm bundle, or an skb that
> has not reached dst_output() yet (a queued or NFQUEUE reinjected
> packet, async crypto). Those packets are dropped, where the holder
> would have noticed that the dst is stale at its next check and looked
> the route up again.
>
> The dst does have to be detached from its device when the device is
> unregistered: it is no longer reachable from the FIB, and a holder
> such as an idle socket can keep it indefinitely, which would hold the
> device. Put it on the uncached list instead. It keeps working until its
> holders let go, and rt6_uncached_list_flush_dev() detaches it on
> unregister like any other uncached dst.
>
> Fixes: 8f34e53b60b3 ("ipv6: Use global sernum for dst validation with nexthop objects")
Looks like another day 1 bug. I suggest dropping the tag.
> Reported-by: Ralf Lici <ralf@mandelbit.com>
> Signed-off-by: David Ahern <dahern@nvidia.com>
> ---
> net/ipv6/route.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index c41c5ca23fe1..31ebcf665216 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -1483,7 +1483,13 @@ static struct rt6_info *rt6_get_pcpu_route(const struct fib6_result *res)
> /* Paired with READ_ONCE() in __fib6_drop_pcpu_from() */
> prev = xchg(p, NULL);
> if (prev) {
> - dst_dev_put(&prev->dst);
> + /* Holders may still be using it until they notice it
> + * is stale, so keep it working rather than dst_dev_put()
> + * it, which would turn the packets of anyone who has
> + * not rechecked yet into drops. Device unregister
> + * detaches it like any other uncached dst.
> + */
Redundant, IMO.
> + rt6_uncached_list_add(prev);
I don't think it's safe. ip6_route_output_flags() treats uncached dst
entries as entries that are already reference counted and doesn't take a
reference on them:
if (!rt6->dst.rt_uncached_list && !dst_hold_safe(dst)) {
If a lookup in process context is interleaved with a lookup in softirq,
the former can treat the entry as reference counted when it's not
(diagram from Claude):
CPU 0 CPU 1
----- -----
ip6_route_output_flags()
rcu_read_lock()
ip6_pol_route(NOREF)
local_bh_disable()
P = rt6_get_pcpu_route()
P becomes stale because of
route insertion
local_bh_enable()
softirq: a packet routed via
the same nexthop
ip6_pol_route()
rt6_get_pcpu_route()
/* P stale */
xchg(slot, NULL)
rt6_uncached_list_add(P)
/* P->dst.rt_uncached_list
* is now set */
dst_release(&P->dst)
/* the slot's reference
* is gone */
return P
if (!P->dst.rt_uncached_list &&
/* false */
!dst_hold_safe(&P->dst))
/* skipped: no hold */
rcu_read_unlock()
return P
/* caller thinks it owns a
* reference; nobody holds one */
It's problematic that callers check if a reference was taken based on
dst.rt_uncached_list, which can now change after the entry is already
visible.
IMO, callers should only determine it based on the NOREF flag and
ip6_pol_route() should honor it by queueing an RCU callback to release
the reference from uncached dst entries when this flag is specified.
next prev parent reply other threads:[~2026-12-02 16:19 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 17:40 [PATCH net-next v3 00/13] ipv6: validate cached dsts against the netns route generation David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 01/13] ipv6: allocate the exception entry before removing the one it replaces David Ahern
2026-12-02 16:02 ` Ido Schimmel
2026-12-01 17:40 ` [PATCH net-next v3 02/13] ipv6: keep a superseded pcpu dst working until its holders notice David Ahern
2026-12-02 16:19 ` Ido Schimmel [this message]
2026-12-01 17:40 ` [PATCH net-next v3 03/13] ipv6: don't insert a PMTU exception whose MTU could not be stored David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 04/13] ipv6: invalidate the failing dst in ip6_link_failure() David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 05/13] ipv6: tell route dumps about exception inserts with a table sequence David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 06/13] ipv6: validate dsts against the netns route generation David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 07/13] ipv6: make rt_genid_bump_ipv6() a plain counter increment David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 08/13] nexthop: factor out nh_has_f6i() David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 09/13] nexthop: bump the IPv6 route generation on group changes David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 10/13] ipv6: stamp dsts with the generation sampled before the FIB lookup David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 11/13] selftests: net: pmtu: check that a deleted cached exception stays deleted David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 12/13] selftests: net: fib_tests: Add stale pcpu test David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 13/13] selftests: net: ipvs: check a PMTU learned after the DR route was cached David Ahern
2026-12-01 17:43 ` [PATCH net-next v3 00/13] ipv6: validate cached dsts against the netns route generation netdev-bot+sinfo
2026-12-02 9:45 ` Ralf Lici
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=20261202161942.GA2800642@shredder \
--to=idosch@nvidia.com \
--cc=dahern@nvidia.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=ja@ssi.bg \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=ralf@mandelbit.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