* [PATCH] 9p/rdma: create RDMA CM ID in caller's net namespace
@ 2026-05-29 7:08 Yizhou Zhao
2026-05-29 8:10 ` Dominique Martinet
0 siblings, 1 reply; 3+ messages in thread
From: Yizhou Zhao @ 2026-05-29 7:08 UTC (permalink / raw)
To: v9fs
Cc: Yizhou Zhao, Eric Van Hensbergen, Latchesar Ionkov,
Dominique Martinet, Christian Schoenebeck, linux-kernel,
Yuxiang Yang, Ao Wang, Xuewei Feng, Qi Li, Ke Xu
The 9p RDMA transport currently passes &init_net to rdma_create_id().
As a result, RDMA address resolution and connection setup are performed
in the initial network namespace, even when the mount is initiated from
a non-initial network namespace.
This differs from the socket-based 9p transports, which create sockets
in current->nsproxy->net_ns. Use the caller's network namespace for the
RDMA CM ID as well, so that RDMA transport setup follows the same
namespace context as the process performing the mount.
This avoids surprising behaviour where a 9p RDMA mount from a container
or other non-initial network namespace may use the host namespace for
RDMA CM operations.
Fixes: fa20105e09e9 ("IB/cma: Add support for network namespaces")
Reported-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn>
Reported-by: Yuxiang Yang <yangyx22@mails.tsinghua.edu.cn>
Reported-by: Ao Wang <wangao@seu.edu.cn>
Reported-by: Xuewei Feng <fengxw06@126.com>
Reported-by: Qi Li <qli01@tsinghua.edu.cn>
Reported-by: Ke Xu <xuke@tsinghua.edu.cn>
Assisted-by: GLM:GLM-5.1
Signed-off-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn>
---
net/9p/trans_rdma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
index aa5bd74..ea49b15 100644
--- a/net/9p/trans_rdma.c
+++ b/net/9p/trans_rdma.c
@@ -541,7 +541,7 @@ rdma_create_trans(struct p9_client *client, struct fs_context *fc)
return -ENOMEM;
/* Create the RDMA CM ID */
- rdma->cm_id = rdma_create_id(&init_net, p9_cm_event_handler, client,
+ rdma->cm_id = rdma_create_id(current->nsproxy->net_ns, p9_cm_event_handler, client,
RDMA_PS_TCP, IB_QPT_RC);
if (IS_ERR(rdma->cm_id))
goto error;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] 9p/rdma: create RDMA CM ID in caller's net namespace
2026-05-29 7:08 [PATCH] 9p/rdma: create RDMA CM ID in caller's net namespace Yizhou Zhao
@ 2026-05-29 8:10 ` Dominique Martinet
0 siblings, 0 replies; 3+ messages in thread
From: Dominique Martinet @ 2026-05-29 8:10 UTC (permalink / raw)
To: Yizhou Zhao
Cc: v9fs, Eric Van Hensbergen, Latchesar Ionkov,
Christian Schoenebeck, linux-kernel, Yuxiang Yang, Ao Wang,
Xuewei Feng, Qi Li, Ke Xu
Yizhou Zhao wrote on Fri, May 29, 2026 at 03:08:15PM +0800:
> The 9p RDMA transport currently passes &init_net to rdma_create_id().
> As a result, RDMA address resolution and connection setup are performed
> in the initial network namespace, even when the mount is initiated from
> a non-initial network namespace.
>
> This differs from the socket-based 9p transports, which create sockets
> in current->nsproxy->net_ns. Use the caller's network namespace for the
> RDMA CM ID as well, so that RDMA transport setup follows the same
> namespace context as the process performing the mount.
>
> This avoids surprising behaviour where a 9p RDMA mount from a container
> or other non-initial network namespace may use the host namespace for
> RDMA CM operations.
>
> Fixes: fa20105e09e9 ("IB/cma: Add support for network namespaces")
> Reported-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn>
> Reported-by: Yuxiang Yang <yangyx22@mails.tsinghua.edu.cn>
> Reported-by: Ao Wang <wangao@seu.edu.cn>
> Reported-by: Xuewei Feng <fengxw06@126.com>
> Reported-by: Qi Li <qli01@tsinghua.edu.cn>
> Reported-by: Ke Xu <xuke@tsinghua.edu.cn>
> Assisted-by: GLM:GLM-5.1
> Signed-off-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn>
> ---
> net/9p/trans_rdma.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
> index aa5bd74..ea49b15 100644
> --- a/net/9p/trans_rdma.c
> +++ b/net/9p/trans_rdma.c
> @@ -541,7 +541,7 @@ rdma_create_trans(struct p9_client *client, struct fs_context *fc)
> return -ENOMEM;
>
> /* Create the RDMA CM ID */
> - rdma->cm_id = rdma_create_id(&init_net, p9_cm_event_handler, client,
> + rdma->cm_id = rdma_create_id(current->nsproxy->net_ns, p9_cm_event_handler, client,
We apparently should use fc->net_ns[1] (likewise in other transports that
use current->nsproxy->net_ns)
[1] https://sashiko.dev/#/patchset/20260529070817.76798-1-zhaoyz24%40mails.tsinghua.edu.cn
If you have time please send a (separate) patch fixing trans_fd.c ?
--
Dominique Martinet | Asmadeus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] 9p/rdma: create RDMA CM ID in caller's net namespace
@ 2026-05-29 9:10 Yizhou Zhao
0 siblings, 0 replies; 3+ messages in thread
From: Yizhou Zhao @ 2026-05-29 9:10 UTC (permalink / raw)
To: Dominique Martinet
Cc: Yizhou Zhao, Eric Van Hensbergen, Latchesar Ionkov,
Christian Schoenebeck, v9fs, linux-kernel, Yuxiang Yang, Ao Wang,
Xuewei Feng, Qi Li, Ke Xu
On Fri, May 29, 2026 at 03:08:15PM +0800, Dominique Martinet wrote:
> We apparently should use fc->net_ns[1] (likewise in other transports that
> use current->nsproxy->net_ns)
>
> [1] https://sashiko.dev/#/patchset/20260529070817.76798-1-zhaoyz24%40mails.tsinghua.edu.cn
>
> If you have time please send a (separate) patch fixing trans_fd.c ?
Thank you for the review! You're right, fc->net_ns is the proper way.
Instead of sending a separate patch for trans_fd.c, We've folded the
trans_fd.c fix into the same patch and updated trans_rdma.c to use
fc->net_ns as well. Please find v2 here:
https://lore.kernel.org/v9fs/20260529090625.78761-1-zhaoyz24@mails.tsinghua.edu.cn/
Best regards,
Yizhou
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-29 9:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-29 7:08 [PATCH] 9p/rdma: create RDMA CM ID in caller's net namespace Yizhou Zhao
2026-05-29 8:10 ` Dominique Martinet
-- strict thread matches above, loose matches on Subject: below --
2026-05-29 9:10 Yizhou Zhao
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.