Re: [PATCH] 9p/rdma: create RDMA CM ID in caller's net namespace
From: Dominique Martinet
Date: Fri May 29 2026 - 04:15:56 EST
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@xxxxxxxxxxxxxxxxxxxxx>
> Reported-by: Yuxiang Yang <yangyx22@xxxxxxxxxxxxxxxxxxxxx>
> Reported-by: Ao Wang <wangao@xxxxxxxxxx>
> Reported-by: Xuewei Feng <fengxw06@xxxxxxx>
> Reported-by: Qi Li <qli01@xxxxxxxxxxxxxxx>
> Reported-by: Ke Xu <xuke@xxxxxxxxxxxxxxx>
> Assisted-by: GLM:GLM-5.1
> Signed-off-by: Yizhou Zhao <zhaoyz24@xxxxxxxxxxxxxxxxxxxxx>
> ---
> 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