From: netdev-bot+sashiko@kernel.org
To: dsahern@kernel.org
Cc: netdev@vger.kernel.org, idosch@nvidia.com, davem@davemloft.net,
edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
horms@kernel.org, ralf@mandelbit.com, ja@ssi.bg,
dahern@nvidia.com, noreply@anthropic.com
Subject: Re: [PATCH net-next v3 02/13] ipv6: keep a superseded pcpu dst working until its holders notice
Date: Sat, 05 Dec 2026 19:20:51 +0000 [thread overview]
Message-ID: <179649845131.3148.2011766218783980294@kernel.org> (raw)
In-Reply-To: <20261201174021.7211-3-dsahern@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 1 · High: 0 · Medium: 1 · Low: 0
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).
- [Critical] net/ipv6/route.c rt6_get_pcpu_route() now calls
rt6_uncached_list_add(prev) on a stale RTF_PCPU dst, which sets…
- [Medium] The patch fixes only one of the paths that dst_dev_put() a
pcpu dst that may still be held.
--
ipv6: keep a superseded pcpu dst working until its holders notice
Before this patch, rt6_get_pcpu_route() called dst_dev_put() on a stale
pcpu dst of a route using a nexthop object. The patch puts the dst on the
uncached list instead. Current holders can keep using it until they notice
it is stale, and rt6_uncached_list_flush_dev() still detaches it from the
device on unregister.
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index c41c5ca23fe12..31ebcf6652166 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.
> + */
> + rt6_uncached_list_add(prev);
[Severity: Critical]
Can this unbalance the refcount on the pcpu dst?
In IPv6, a non-NULL rt_uncached_list tells the caller that it already owns
a reference, even for RT6_LOOKUP_F_DST_NOREF lookups.
rt6_uncached_list_add() documents this:
/* Set once and never cleared: non-NULL marks an uncached route. */
rt->dst.rt_uncached_list = ul;
NOREF lookups hand out pcpu dsts without taking a reference. Before this
patch, pcpu dsts never had the marker set. Now the marker can flip on a
pcpu dst that a NOREF caller already holds.
This sequence on one CPU looks possible:
process context
ip6_route_output_flags()
rcu_read_lock()
ip6_route_output_flags_noref()
ip6_pol_route(..., RT6_LOOKUP_F_DST_NOREF)
local_bh_disable()
rt6_get_pcpu_route() <- returns P, no ref, marker NULL
local_bh_enable() <- pending softirqs can run here
softirq on the same CPU, after fib6_sernum was bumped elsewhere
ip6_route_input()
...
rt6_get_pcpu_route() <- finds P stale
prev = xchg(p, NULL)
rt6_uncached_list_add(P) <- marker now set
dst_release(&P->dst) <- drops the slot's reference
Then, back in ip6_route_output_flags():
/* For an uncached dst, refcnt is already taken. */
if (!rt6->dst.rt_uncached_list && !dst_hold_safe(dst)) {
The marker is now set, so dst_hold_safe() is skipped. P goes back to the
caller as if it owned a reference. When the socket or dst_cache later
releases P, there is one more put than get.
Wouldn't that free P while the socket, or some other holder, still points
to it?
The window runs from local_bh_enable() in ip6_pol_route() to the marker
test. Softirqs on irq exit or preemption under PREEMPT_RCU can land
anywhere in it.
The same marker flip looks like it affects ip6_rt_put_flags():
if (!(flags & RT6_LOOKUP_F_DST_NOREF) ||
rt->dst.rt_uncached_list)
ip6_rt_put(rt);
That would put a reference the NOREF lookup never took. Callers include
both versions of fib6_rule_lookup() (fib6_rules.c and ip6_fib.c),
fib6_rule_action_alt(), fib6_rule_suppress() and
seg6_lookup_any_nexthop().
seg6_lookup_any_nexthop() also uses the marker to choose skb_dst_set()
over skb_dst_set_noref():
if ((flags & RT6_LOOKUP_F_DST_NOREF) && !dst->rt_uncached_list)
skb_dst_set_noref(skb, dst);
else
skb_dst_set(skb, dst);
So the later skb_dst_drop() would release a reference that was never
taken.
Before this patch, the same race ended with dst_hold_safe() either
succeeding or falling back to ip6_null_entry.
This also seems to still be present at the end of the series.
rt6_dst_release_deferred() defers the slot's put through call_rcu, which
keeps P alive for one grace period but does not fix the imbalance. Also,
"ipv6: validate dsts against the netns route generation" applies the same
rt6_uncached_list_add(old) pattern to replaced exceptions, and NOREF
lookups return those without a reference too.
> dst_release(&prev->dst);
> }
>
[Severity: Medium]
Should fib6_nh_release_dsts() get the same treatment? It still does the
sequence this patch removes here:
net/ipv6/route.c:fib6_nh_release_dsts() {
...
pcpu_rt = xchg(ppcpu_rt, NULL);
if (pcpu_rt) {
dst_dev_put(&pcpu_rt->dst);
dst_release(&pcpu_rt->dst);
}
...
}
When a nexthop group is replaced, nh_rt_cache_flush() calls it for every
IPv6 member right after rt_genid_bump_ipv6(). The routes and member
nexthops stay live:
replace_nexthop_grp()
nh_rt_cache_flush()
fib6_nh_release_dsts()
dst_dev_put()
The commit message describes the holders involved: sockets, tunnel
dst_caches, xfrm bundles and in-flight skbs. After this dst_dev_put(),
their packets would still go to blackhole_netdev/dst_discard_out instead
of the holder re-looking up the route.
The commit message's reasoning about device unregister would seem to
apply here as well. At the end of the series, fib6_nh_release_dsts()
still calls dst_dev_put(); only its dst_release() was converted to
rt6_dst_release_deferred().
Is there a reason this path is left alone?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201174021.7211-1-dsahern%40kernel.org
next prev parent reply other threads:[~2026-12-05 19:20 UTC|newest]
Thread overview: 31+ 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
2026-12-05 19:20 ` netdev-bot+sashiko [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-05 19:20 ` netdev-bot+sashiko
2026-12-01 17:40 ` [PATCH net-next v3 04/13] ipv6: invalidate the failing dst in ip6_link_failure() David Ahern
2026-12-05 19:20 ` netdev-bot+sashiko
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-05 19:20 ` netdev-bot+sashiko
2026-12-01 17:40 ` [PATCH net-next v3 06/13] ipv6: validate dsts against the netns route generation David Ahern
2026-12-05 19:20 ` netdev-bot+sashiko
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-05 19:20 ` netdev-bot+sashiko
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-05 19:20 ` netdev-bot+sashiko
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-05 19:21 ` netdev-bot+sashiko
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-05 19:21 ` netdev-bot+sashiko
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-05 19:21 ` netdev-bot+sashiko
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
2026-12-03 15:34 ` Ido Schimmel
2026-12-03 16:55 ` Ralf Lici
2026-12-03 17:16 ` Ido Schimmel
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=179649845131.3148.2011766218783980294@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=dahern@nvidia.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=ja@ssi.bg \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=noreply@anthropic.com \
--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