From: netdev-bot+sashiko@kernel.org
To: qiliang.yuan@linux.dev
Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, dsahern@kernel.org,
idosch@nvidia.com, razor@blackwall.org, kuniyu@google.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v4 4/4] net: remove rcu_barrier() from __dev_change_net_namespace()
Date: Sun, 22 Nov 2026 03:14:14 +0000 [thread overview]
Message-ID: <179531725438.3135.9155413849195157249@kernel.org> (raw)
In-Reply-To: <20261117-bug-net-netns-move-rcu-barrier-v4-4-43e1ca0aac7f@linux.dev>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · 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).
- [Medium] net: race in __dev_change_net_namespace() leaves moved dev on
xfrm_dst
- [Medium] net: missing dst_dev_put() wait in
__dev_change_net_namespace()
--
> diff --git a/net/core/dev.c b/net/core/dev.c
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -13153,7 +13153,6 @@ int __dev_change_net_namespace(struct net_device *dev, struct net *net,
> * the device is just moving and can keep their slaves up.
> */
> call_netdevice_notifiers(NETDEV_UNREGISTER, dev);
> - rcu_barrier();
>
> new_nsid = peernet2id_alloc(dev_net(dev), net, GFP_KERNEL);
>
>
[Severity: Medium]
The changelog says routes cached through the moved device are
rejected once the netns changes. That only covers users that go
through dst_check(). Is that enough here?
For routes without a nexthop object, dst_dev_put() on the per-cpu
and exception dsts only happens in two places: free_fib_info_rcu() ->
fib_nh_release(), and fib6_info_destroy_rcu() ->
fib6_nh_release() -> fib6_nh_release_dsts(). On NETDEV_UNREGISTER,
fib6_drop_pcpu_from() only clears ->from.
Without rcu_barrier(), __dev_change_net_namespace() can therefore
return while those dsts still have dst->output set to ip_output() /
ip6_output() and dst->dev_rcu pointing at dev.
A few users don't call dst_check():
A corked UDP, UDPv6 or RAW socket in the old netns keeps the dst from
ip_setup_cork() / ip6_setup_cork(). On uncork,
udp_push_pending_frames() -> ip_send_skb() -> dst_output() uses it
as is. If dev has already been brought up in its new netns, the
corked packet goes out there.
The following read dst_dev_rcu(__sk_dst_get(sk)) directly:
get_netdev_for_sock() in net/tls/tls_device.c,
net_devmem_get_sock_binding(), smc_clc_prfx_set(),
smc_clc_prfx_match(), smc_vlan_by_tcpsk() and
smc_pnet_find_roce_resource(). They would get the moved device
rather than blackhole_netdev, and attach offload state to a device
in another netns.
The window is small. The synchronize_net() at the end means the
grace period has elapsed and only callback invocation is pending.
But rcu_barrier() closed it completely before.
Could the changelog cover these users? If the barrier has to go,
would it be better to release the cached dsts of routes on dev
synchronously in the NETDEV_UNREGISTER handlers? Or is there a
reason these paths don't matter?
[Severity: Medium]
Does dropping the barrier open a window where an xfrm bundle gets
built on the moved device after the uncached list flush has run?
NETDEV_UNREGISTER queues free_fib_info_rcu() and
fib6_info_destroy_rcu(), and those are what call dst_dev_put() on
the per-cpu and exception routes. Until they run, dst_dev_rcu() on
such a route still returns dev. netif_is_alive(dev) also stays true,
because reg_state remains NETREG_REGISTERED across the move.
ip_route_output_flow() and ip6_dst_lookup_flow() take a reference on
the base route and drop rcu_read_lock() before calling
xfrm_lookup_route(). So the synchronize_net() earlier in
__dev_change_net_namespace() does not wait for them.
xfrm_policy_queue_process() also passes xfrm_dst_path(skb_dst(skb))
from the hold queue to xfrm_lookup() without a dst_check().
Suppose xfrm_bundle_create() or xfrm_create_dummy_bundle() runs
after NETDEV_UNREGISTER has done rt_flush_dev() and
rt6_uncached_list_flush_dev(), but before the RCU callbacks.
xfrm4_fill_dst() / xfrm6_fill_dst() then take a reference on dev.
Once NETDEV_REGISTER has run in the target netns, they also take a
reference on the inet6_dev that ipv6_add_dev() just allocated there.
The xdst is then added to rt_uncached_list / rt6_uncached_list with
no flush left to catch it. It keeps the moved device and the new
inet6_dev referenced, and traffic can leave through dev in its new
netns.
With rcu_barrier() in place, dst_dev_put() had already switched these
routes to blackhole_netdev before dev_net_set().
The rt_genid / fib6_sernum argument in the changelog relies on
dst_check(), which these xfrm paths don't seem to do. Did you look
at them? Is there something else that closes this window, or does
the move still need to wait for these callbacks in some form?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117-bug-net-netns-move-rcu-barrier-v4-0-43e1ca0aac7f%40linux.dev
prev parent reply other threads:[~2026-11-22 3:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 2:28 [PATCH net-next v4 0/4] net: make moving a device to another netns cheaper Qiliang Yuan
2026-11-18 2:28 ` [PATCH net-next v4 1/4] ipv4: draw rt_genid from a sequence shared by all netns Qiliang Yuan
2026-11-22 3:14 ` netdev-bot+sashiko
2026-11-18 2:28 ` [PATCH net-next v4 2/4] ipv6: take fib6_sernum " Qiliang Yuan
2026-11-20 17:52 ` Ralf Lici
2026-11-20 23:13 ` Qiliang Yuan
2026-11-22 3:14 ` netdev-bot+sashiko
2026-11-18 2:28 ` [PATCH net-next v4 3/4] nexthop: release cached routes when a nexthop leaves a group Qiliang Yuan
2026-11-22 3:14 ` netdev-bot+sashiko
2026-11-18 2:28 ` [PATCH net-next v4 4/4] net: remove rcu_barrier() from __dev_change_net_namespace() Qiliang Yuan
2026-11-22 3:14 ` 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=179531725438.3135.9155413849195157249@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--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=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=qiliang.yuan@linux.dev \
--cc=razor@blackwall.org \
/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