From: Serhat Kumral <serhatkumral1@gmail.com>
To: yanjun.zhu@linux.dev
Cc: dsahern@kernel.org, jgg@ziepe.ca, leon@kernel.org,
linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org,
serhatkumral1@gmail.com,
syzbot+8c9eede336e3a843750e@syzkaller.appspotmail.com,
zyjzyj2000@gmail.com
Subject: Re: [PATCH] RDMA/rxe: rework per-net tunnel socket lifetime to fix refcount underflow
Date: Mon, 6 Jul 2026 21:14:04 +0300 [thread overview]
Message-ID: <20260706181404.6687-1-serhatkumral1@gmail.com> (raw)
In-Reply-To: <1a4f521b-796e-46a4-8992-dc5955e463b4@linux.dev>
Hi Yanjun,
Thanks for the review.
> core problem is to serialize the dellink operation.
>
> This commit replaces sk->sk_refcnt with the per-network-namespace
> variables nr_sk4 and nr_sk6. However, this change does not actually
> resolve the underlying issue, because it does not serialize dellink. As
> a result, the race condition can still occur.
You are right that v1 does not serialize dellink itself: if
RDMA_NLDEV_CMD_DELLINK and the NETDEV_UNREGISTER notifier run
concurrently for the same device, rxe_net_del() can be entered twice,
and that device would then drop two references instead of one.
What the per-net mutex does guarantee is that the socket pointer is
cleared under the lock and udp_tunnel_sock_release() is called at most
once per socket, so the refcount underflow / use-after-free from the
syzbot report can no longer occur. The remaining effect of the
unserialized dellink is that the shared socket could be released early
while another device in the namespace still uses it.
> One possible solution is to use rtnl_lock(). However, this is not an
> ideal approach, since there is ongoing work in the kernel community to
> reduce and eventually eliminate unnecessary uses of rtnl_lock().
>
> Another option is to introduce a static mutex specifically for dellink
> serialization. While this would likely solve the race, it is not an
> elegant solution and adds another global lock solely to work around this
> issue.
For that remaining window, instead of rtnl_lock() or a global mutex,
v2 makes rxe_net_del() idempotent per device with a test_and_set_bit()
in struct rxe_dev, so only the first invocation drops the pernet
socket references. This keeps the serialization at device granularity
without adding any global locking. If you would rather serialize
dellink itself, I am happy to respin that way.
I will send v2 shortly.
Thanks,
Serhat
next prev parent reply other threads:[~2026-07-06 18:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-04 10:25 [PATCH] RDMA/rxe: rework per-net tunnel socket lifetime to fix refcount underflow Serhat Kumral
2026-07-04 17:11 ` Zhu Yanjun
2026-07-06 18:14 ` Serhat Kumral [this message]
2026-07-09 15:48 ` Jason Gunthorpe
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=20260706181404.6687-1-serhatkumral1@gmail.com \
--to=serhatkumral1@gmail.com \
--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=syzbot+8c9eede336e3a843750e@syzkaller.appspotmail.com \
--cc=yanjun.zhu@linux.dev \
--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