From: netdev-bot+sashiko@kernel.org
To: ralf@mandelbit.com
Cc: netdev@vger.kernel.org, dsahern@kernel.org, idosch@nvidia.com,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, willemb@google.com, horms@kernel.org,
linux-kernel@vger.kernel.org, dahern@nvidia.com,
andrea.mayer@uniroma2.it, antonio@mandelbit.com
Subject: Re: [PATCH net-next 2/2] ipv6: keep a superseded pcpu dst working until its holders notice
Date: Sat, 05 Dec 2026 12:31:02 +0000 [thread overview]
Message-ID: <179647386221.3146.9662783054271208111@kernel.org> (raw)
In-Reply-To: <f595ecd06c4bb9dedaedaa5205b05bd46702d837.1796382820.git.ralf@mandelbit.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · 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).
- [High] The fix is incomplete.
- [Medium] The patch puts a stale nexthop pcpu rt6_info (rt->sernum != 0)
on the uncached list.
--
ipv6: keep a superseded pcpu dst working until its holders notice
This changes rt6_get_pcpu_route() so that an invalidated pcpu dst of a
nexthop-object route is put on the uncached list instead of being
dst_dev_put() when it is taken out of its per-CPU slot. The slot's
reference is now dropped after an RCU grace period, so that
RT6_LOOKUP_F_DST_NOREF readers are not left with a freed dst.
Link: https://lore.kernel.org/netdev/20261201174021.7211-3-dsahern@kernel.org/
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 39bcfa1ce01b1..df4d670bcfa60 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -1499,8 +1499,8 @@ 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);
> - dst_release(&prev->dst);
> + rt6_uncached_list_add(prev);
> + rt6_dst_release_deferred(prev);
[Severity: High]
The commit message describes two problems with a superseded nexthop pcpu
dst:
1. dst_dev_put() turns a dst that is still held into a discard.
2. The slot reference is dropped without a grace period while
RT6_LOOKUP_F_DST_NOREF readers may still be using the dst.
Is the same pattern still there in fib6_nh_release_dsts()?
net/ipv6/route.c:fib6_nh_release_dsts() {
...
for_each_possible_cpu(cpu) {
...
pcpu_rt = xchg(ppcpu_rt, NULL);
if (pcpu_rt) {
dst_dev_put(&pcpu_rt->dst);
dst_release(&pcpu_rt->dst);
}
}
}
On a group replace, this runs synchronously under RTNL for every IPv6
member of the replaced group:
replace_nexthop()
nh_rt_cache_flush(net, old, new)
fib6_nh_release_dsts(&nhi->fib6_nh)
The member nexthops stay live, so readers on other CPUs can still get to
their pcpu slots. Suppose the dst's references are the slot plus the
child reference of an xfrm bundle B, and B's call_rcu() is already
pending. Can this sequence free the dst under a NOREF reader?
CPU1 CPU0
rcu_read_lock()
ip6_route_input() takes the
pcpu dst NOREF from its slot
fib6_nh_release_dsts()
xchg(ppcpu_rt, NULL)
dst_release() /* 2 -> 1 */
B's grace period ends; it does not
cover CPU1's read section
dst_destroy(B)
dst_release_immediate(child)
/* 1 -> 0, freed */
uses the dst
On a single nexthop replace, replace_nexthop_single() swaps nh_info. Then
nexthop_put(new) reaches this path from an RCU callback:
nexthop_free_single()
fib6_nh_release()
fib6_nh_release_dsts()
The grace period problem doesn't apply there. But wouldn't dsts still
held by sockets, a tunnel dst_cache, xfrm bundles or queued skbs be
blackholed, just as the commit message describes for
rt6_get_pcpu_route()?
A nexthop replace looks like the most direct way for a nexthop pcpu dst
to be superseded. Should fib6_nh_release_dsts() also use the uncached
list and the deferred release?
[Severity: Medium]
Before this change, dst_dev_put() set dst.obsolete to DST_OBSOLETE_DEAD.
Now a pcpu dst with rt->sernum set goes on the uncached list, and its
obsolete stays DST_OBSOLETE_FORCE_CHK.
When the device later goes down or is unregistered,
rt6_uncached_list_flush_dev() does this:
rcu_assign_pointer(rt->dst.dev_rcu, blackhole_netdev);
...
from = unrcu_pointer(xchg(&rt->from, NULL));
fib6_info_release(from);
It does not change obsolete or sernum. ip6_dst_check() then returns early
for dsts that have a sernum:
if (rt->sernum)
return rt6_is_valid(rt) ? dst : NULL;
So the rt->from check, which rejects other flushed uncached dsts, is
never reached.
rt6_is_valid() compares rt->sernum against
rt_genid_ipv6(dev_net(rt->dst.dev)). After the flush that is init_net,
because blackhole_netdev lives there. For a route in a non-init netns,
ip6_rt_pcpu_alloc() took rt->sernum from the original netns. Every netns
counter starts at 1 and goes up by one per FIB change.
Can the stale sernum equal init_net's current fib6_sernum? If so, would
ip6_dst_check() accept the blackholed dst? The socket, tunnel dst_cache
or xfrm bundle holding it would then keep sending into blackhole_netdev
until init_net's fib6_sernum changes.
The commit message says rt6_uncached_list_flush_dev() detaches the dst
"like any other uncached dst", but other uncached dsts have a zero
sernum. Does the flush path, or the move to the uncached list, need to
clear rt->sernum or mark the dst DST_OBSOLETE_DEAD?
> }
>
> pcpu_rt = NULL;
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1796382820.git.ralf%40mandelbit.com
prev parent reply other threads:[~2026-12-05 12:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 11:29 [PATCH net-next 0/2] ipv6: move superseded pcpu dsts to the uncached list Ralf Lici
2026-12-04 11:29 ` [PATCH net-next 1/2] ipv6: base dst ownership on RT6_LOOKUP_F_DST_NOREF only Ralf Lici
2026-12-05 12:31 ` netdev-bot+sashiko
2026-12-04 11:29 ` [PATCH net-next 2/2] ipv6: keep a superseded pcpu dst working until its holders notice Ralf Lici
2026-12-05 12:31 ` netdev-bot+sashiko [this message]
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=179647386221.3146.9662783054271208111@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrea.mayer@uniroma2.it \
--cc=antonio@mandelbit.com \
--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=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=ralf@mandelbit.com \
--cc=willemb@google.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