From: Zhu Yanjun <yanjun.zhu@linux.dev>
To: Serhat Kumral <serhatkumral1@gmail.com>,
"yanjun.zhu@linux.dev" <yanjun.zhu@linux.dev>
Cc: dsahern@kernel.org, jgg@ziepe.ca, leon@kernel.org,
linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org,
syzbot+8c9eede336e3a843750e@syzkaller.appspotmail.com,
zyjzyj2000@gmail.com
Subject: Re: [PATCH v3] RDMA/rxe: rework per-net tunnel socket lifetime to fix refcount underflow
Date: Wed, 8 Jul 2026 20:33:53 -0700 [thread overview]
Message-ID: <fdac9d3e-62ef-4009-aa55-19e4625a5ced@linux.dev> (raw)
In-Reply-To: <20260708181007.24280-1-serhatkumral1@gmail.com>
在 2026/7/8 11:10, Serhat Kumral 写道:
> Hi Yanjun,
>
>> However, after the network namespace teardown, the associated netdevice
>> is still unregistered, which
>> triggers the NETDEV_UNREGISTER notifier. In rxe_notify(), this event
>> eventually calls rxe_net_del() to
>> remove the RDMA link.
> Isn't the ordering the other way around? The netdevices of a dying
> netns are unregistered by default_device_exit_batch(), a pernet
> device op, while rxe_net_ops is a pernet subsys, and subsys exits
> run after all device exits. So NETDEV_UNREGISTER (and the notifier's
> rxe_net_del()) should have already completed before rxe_ns_exit()
> destroys the mutex.
>
> Am I missing a path where rxe_net_del() can run after rxe_ns_exit()?
Hi,
Thanks for the clarification. Your analysis is spot on.
The assumption that pernet device exit (default_device_exit_batch)
always guarantees a synchronous NETDEV_UNREGISTER notification for all
netdevices prior to pernet subsys exit (rxe_ns_exit) is indeed flawed.
There are two critical blind spots in this flow:
Netns Migration (The init_net fallback): During netns teardown, certain
stateful or persistent devices like loopback
(lo) or stacked virtual interfaces are moved back to init_net via
dev_change_net_namespace() rather than being fully unregistered. This
triggers NETDEV_DOWN or namespace change events instead of a standard
NETDEV_UNREGISTER. Consequently, rxe_net_del() is skipped, leaving
stale RXE resources bound to the dying netns.
Module Unload Race (Parallel Cleanup): When rmmod rdma_rxe invokes
unregister_pernet_subsys(), rxe_ns_exit()
runs concurrently across multiple netns. If a concurrent thread or a
deferred RCU/workqueue task (e.g., net_todo_list) is simultaneously
processing an asynchronous netdevice unregistration, rxe_net_del() and
rxe_ns_exit() will race on different CPUs.
In both corner cases, rxe_ns_exit() can proceed to tear down the pernet
infrastructure and destroy the mutex lock while a lingering
or concurrent rxe_net_del() invocation still attempts to acquire it.
This inevitably triggers a Use-After-Free (UAF) on the mutex.
To fix this properly, we must ensure that:
rxe_ns_exit() explicitly flushes and tears down any remaining RXE
devices under the lock before the mutex is destroyed.
We handle netns migration events properly in the netdev notifier to
trigger early cleanup.
Could you please a new patch to include this explicit ordering in
rxe_ns_exit()?
Thanks a lot.
Zhu Yanjun
>
> Thanks,
> Serhat
--
Best Regards,
Yanjun.Zhu
prev parent reply other threads:[~2026-07-09 3:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 16:00 [PATCH v3] RDMA/rxe: rework per-net tunnel socket lifetime to fix refcount underflow Serhat Kumral
2026-07-07 23:16 ` Yanjun.Zhu
2026-07-08 18:10 ` Serhat Kumral
2026-07-09 3:33 ` Zhu Yanjun [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=fdac9d3e-62ef-4009-aa55-19e4625a5ced@linux.dev \
--to=yanjun.zhu@linux.dev \
--cc=dsahern@kernel.org \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=serhatkumral1@gmail.com \
--cc=syzbot+8c9eede336e3a843750e@syzkaller.appspotmail.com \
--cc=zyjzyj2000@gmail.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