Thread (17 messages) 17 messages, 3 authors, 16h ago

Re: [PATCH rdma-next 12/13] RDMA/rxe: Implement disassociate_ucontext callback

From: Zhu Yanjun <hidden>
Date: 2026-07-10 04:21:59
Also in: cgroups, linux-kselftest, linux-rdma, linux-s390

在 2026/7/9 2:55, Jiri Pirko 写道:
From: Jiri Pirko <redacted>

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.

rxe needs no teardown here: its user-mapped queues live in
reference-counted vmalloc memory (see rxe_mmap.c) that stays valid
while userspace holds the mappings.
The logic here is correct for enabling netns migration. Since RXE's 
user-mapped

queues rely on reference-counted vmalloc memory, this empty stub is safe 
enough

to prevent kernel panics or Use-After-Free (UAF) during device movement.


However, as a note for future improvement: keeping this callback 
entirely empty

means userspace won't be immediately notified (via SIGBUS or page table 
zapping)

when the underlying device is moved out of its netns. For now, this 
serves well as

a functional enabler, but we might want to introduce proper PTE 
tearing/zap_vma_ptes()

down the road if applications require strict, immediate disconnection 
semantics.


Thanks Jiri.

Reviewed-by: Yanjun Zhu <redacted>

Zhu Yanjun
quoted hunk ↗ jump to hunk
Signed-off-by: Jiri Pirko <redacted>
---
  drivers/infiniband/sw/rxe/rxe_verbs.c | 5 +++++
  1 file changed, 5 insertions(+)
diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
index 1ec130fee8ea..6eb10d2f0653 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)
+{
+}
+
  /* pd */
  static int rxe_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
  {
@@ -1478,6 +1482,7 @@ static const struct ib_device_ops rxe_dev_ops = {
  	.destroy_srq = rxe_destroy_srq,
  	.detach_mcast = rxe_detach_mcast,
  	.device_group = &rxe_attr_group,
+	.disassociate_ucontext = rxe_disassociate_ucontext,
  	.enable_driver = rxe_enable_driver,
  	.get_dma_mr = rxe_get_dma_mr,
  	.get_hw_stats = rxe_ib_get_hw_stats,
-- 
Best Regards,
Yanjun.Zhu
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help