Re: [PATCH] 9p/rdma: create RDMA CM ID in caller's net namespace

Dominique Martinet <[email protected]> Fri, 29 May 2026 17:10:46 +0900
Newsgroups dev.linux.lists.v9fs,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
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 <[email protected]>
> Reported-by: Yuxiang Yang <[email protected]>
> Reported-by: Ao Wang <[email protected]>
> Reported-by: Xuewei Feng <[email protected]>
> Reported-by: Qi Li <[email protected]>
> Reported-by: Ke Xu <[email protected]>
> Assisted-by: GLM:GLM-5.1
> Signed-off-by: Yizhou Zhao <[email protected]>
> ---
>  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