From: Jiri Pirko <jiri@resnulli.us>
To: sashiko-reviews@lists.linux.dev
Cc: Heiko Carstens <hca@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
tj@kernel.org, linux-s390@vger.kernel.org, hannes@cmpxchg.org,
mkoutny@suse.com
Subject: Re: [PATCH rdma-next 12/13] RDMA/rxe: Implement disassociate_ucontext callback
Date: Mon, 13 Jul 2026 15:24:35 +0200 [thread overview]
Message-ID: <alTnCW2s8kA6Gc0Q@FV6GYCPJ69> (raw)
In-Reply-To: <20260710095630.C5F851F00A3D@smtp.kernel.org>
Fri, Jul 10, 2026 at 11:56:30AM +0200, sashiko-bot@kernel.org wrote:
>Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>- [Critical] Implementing an empty `disassociate_ucontext` callback bypasses the core's VMA zapping because RXE uses legacy, untracked VMAs. This leads to a Use-After-Free of `ib_ucontext` and `rxe_dev` when the VMA is eventually closed, and potential kernel panics upon module unload.
>--
>
>--- Patch [12]: [PATCH rdma-next 12/13] RDMA/rxe: Implement disassociate_ucontext callback ---
>commit 8946fc9f2a378bad6f910a408699c6a70e97a6f6
>Author: Jiri Pirko <jiri@resnulli.us>
>
>RDMA/rxe: Implement disassociate_ucontext callback
>
>Implement an empty disassociate_ucontext() callback so the RDMA core
>can move rxe devices between net namespaces. The core requires this
>callback to reset user contexts without waiting for userspace.
>
>> diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
>> index 1ec130fee8ea7..6eb10d2f0653b 100644
>> --- a/drivers/infiniband/sw/rxe/rxe_verbs.c
>> +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
>> @@ -240,6 +240,10 @@ static void rxe_dealloc_ucontext(struct ib_ucontext *ibuc)
>> rxe_err_uc(uc, "cleanup failed, err = %d\n", err);
>> }
>>
>> +static void rxe_disassociate_ucontext(struct ib_ucontext *ibuc)
>> +{
>> +}
>> +
>
>[Severity: Critical]
>By adding this callback, does this opt the driver into asynchronous teardown
>which can lead to a use-after-free and kernel panic?
>
>Because RXE uses legacy, untracked VMAs (bypassing the core's
>rdma_user_mmap_entry mechanism), these VMAs are invisible to the core and are
>not zapped during teardown.
>
>If a user process maps an RXE resource and the device is then removed or
>migrated to another network namespace, the asynchronous teardown will free
>the ib_ucontext and allow module unload while the process still holds the VMA.
>
>When the process later unmaps the memory or exits, the untracked VMA's close
>callback (rxe_vma_close) will trigger rxe_mmap_release(), accessing the
>already-freed ib_ucontext and rxe_dev:
>
>drivers/infiniband/sw/rxe/rxe_mmap.c:rxe_mmap_release() {
> struct rxe_mmap_info *ip = container_of(ref,
> struct rxe_mmap_info, ref);
> struct rxe_dev *rxe = to_rdev(ip->context->device);
>
> spin_lock_bh(&rxe->pending_lock);
> ...
>}
>
>If the module was unloaded in the interim, jumping to the VMA's close callback
>could also trigger an immediate kernel panic.
Fixed.
>
>[ ... ]
>
>--
>Sashiko AI review · https://sashiko.dev/#/patchset/20260709095532.855647-1-jiri@resnulli.us?part=12
next prev parent reply other threads:[~2026-07-13 13:24 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 9:55 [PATCH rdma-next 00/13] RDMA: Make device names unique per net namespace Jiri Pirko
2026-07-09 9:55 ` [PATCH rdma-next 01/13] RDMA/core: Pass the net namespace to the device name lookups Jiri Pirko
2026-07-09 9:55 ` [PATCH rdma-next 02/13] RDMA/core: Handle device name conflicts when changing net namespace Jiri Pirko
2026-07-10 9:56 ` sashiko-bot
2026-07-13 12:32 ` Jiri Pirko
2026-07-09 9:55 ` [PATCH rdma-next 03/13] RDMA/core: Support renaming a device when changing its " Jiri Pirko
2026-07-10 9:56 ` sashiko-bot
2026-07-13 12:17 ` Jiri Pirko
2026-07-09 9:55 ` [PATCH rdma-next 04/13] RDMA/nldev: Report net namespace move errors through extack Jiri Pirko
2026-07-09 9:55 ` [PATCH rdma-next 05/13] RDMA/nldev: Allow setting the device name while changing net namespace Jiri Pirko
2026-07-09 9:55 ` [PATCH rdma-next 06/13] net/smc: Look up the pnetid ib device within the " Jiri Pirko
2026-07-10 9:56 ` sashiko-bot
2026-07-09 9:55 ` [PATCH rdma-next 07/13] RDMA/srp: Make the SRP sysfs class net namespace aware Jiri Pirko
2026-07-09 9:55 ` [PATCH rdma-next 08/13] RDMA/cgroup: Scope rdma cgroup device visibility to the net namespace Jiri Pirko
2026-07-09 13:04 ` Michal Koutný
2026-07-13 9:34 ` Jiri Pirko
2026-07-14 2:28 ` Tao Cui
2026-07-14 7:39 ` Jiri Pirko
2026-07-10 9:56 ` sashiko-bot
2026-07-14 11:39 ` Jiri Pirko
2026-07-09 9:55 ` [PATCH rdma-next 09/13] RDMA/cma: Document that CM configfs cannot be net namespace scoped Jiri Pirko
2026-07-09 9:55 ` [PATCH rdma-next 10/13] RDMA/core: Document the SELinux ibendport net namespace limitation Jiri Pirko
2026-07-09 9:55 ` [PATCH rdma-next 11/13] RDMA/core: Make device names unique per net namespace Jiri Pirko
2026-07-09 9:55 ` [PATCH rdma-next 12/13] RDMA/rxe: Implement disassociate_ucontext callback Jiri Pirko
2026-07-10 4:21 ` Zhu Yanjun
2026-07-10 9:56 ` sashiko-bot
2026-07-13 13:24 ` Jiri Pirko [this message]
2026-07-09 9:55 ` [PATCH rdma-next 13/13] RDMA/selftests: Add rxe_netns_names test Jiri Pirko
2026-07-10 4:24 ` Zhu Yanjun
2026-07-13 8:58 ` Jiri Pirko
2026-07-10 9:56 ` sashiko-bot
2026-07-13 13:35 ` Jiri Pirko
2026-07-10 23:51 ` yanjun.zhu
2026-07-13 9:02 ` Jiri Pirko
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=alTnCW2s8kA6Gc0Q@FV6GYCPJ69 \
--to=jiri@resnulli.us \
--cc=agordeev@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hannes@cmpxchg.org \
--cc=hca@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=mkoutny@suse.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tj@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.