From nobody Mon Jun 8 12:16:09 2026 Received: from zg8tmtyylji0my4xnjeumjiw.icoremail.net (zg8tmtyylji0my4xnjeumjiw.icoremail.net [162.243.161.220]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D6D92C15A5 for ; Fri, 29 May 2026 09:06:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.243.161.220 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780045608; cv=none; b=XZnQrBD1+iWfg4lXVrd8wQ5YVNWzdbvuspVAe3s63TooLELjuWy51OuI7Qf3m+cI85bnKMv9uV3VNEMi2klxMRk1KY+9Ny9kkFPTfkNBvTLD7hNwPDYCgodAGaVC6p1kNPhqlhEeZPpnUWELVvAPN9AfrJ3HEUuVuyU6V6NWQKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780045608; c=relaxed/simple; bh=cWmlk+qqXH1sAX+h6bmugwm/hRHYo0EPwNmVuO3mWHg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Zi345PaYXOPVprffiFRmRieNI+wGmaIV4HgFiAKfv/0gFRBHVVU1TH2ebQBM0wZir7QPw1/5WFhKjfXWuAN8oxSCwZECmU8W91q/lS6hYdhsse1ubqKnzS+MKYKiauFbACtbQZv1HQcmY2uOJv7sA6ummIzMkJisP9BN2a8b1qw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mails.tsinghua.edu.cn; spf=pass smtp.mailfrom=mails.tsinghua.edu.cn; dkim=pass (1024-bit key) header.d=mails.tsinghua.edu.cn header.i=@mails.tsinghua.edu.cn header.b=gMiR/2uP; arc=none smtp.client-ip=162.243.161.220 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mails.tsinghua.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mails.tsinghua.edu.cn Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mails.tsinghua.edu.cn header.i=@mails.tsinghua.edu.cn header.b="gMiR/2uP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mails.tsinghua.edu.cn; s=dkim; h=Received:From:To:Cc:Subject: Date:Message-ID:MIME-Version:Content-Transfer-Encoding; bh=AWOX/ QA4lxWbbgTp0kHZQSWyFT1DkSSDXx/yLXG6gH0=; b=gMiR/2uPqV9NSQhs2eAEQ ELlSt17/L7HhG+H29OOykY28KTH7uZP0cyMZDnI0/aiQH/6JlDJ00Qj0xG4jEo7I Z1nHheQOSs3EuDz9MPG6XAxFZz4s0ZUeotfJGe12Oprj85A9MnJ3pm4+/ZslhBxy FiJMQUmI2bD2Y5nNCPnm/A= Received: from localhost.localdomain (unknown [211.102.241.99]) by web2 (Coremail) with SMTP id yQQGZQAH4ZgVVxlqibzdAQ--.12846S2; Fri, 29 May 2026 17:06:29 +0800 (CST) From: Yizhou Zhao To: v9fs@lists.linux.dev Cc: Yizhou Zhao , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , linux-kernel@vger.kernel.org, Yuxiang Yang , Ao Wang , Xuewei Feng , Qi Li , Ke Xu Subject: [PATCH v2] 9p: use fc->net_ns for network namespace in RDMA and socket transports Date: Fri, 29 May 2026 17:06:24 +0800 Message-ID: <20260529090625.78761-1-zhaoyz24@mails.tsinghua.edu.cn> X-Mailer: git-send-email 2.46.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: yQQGZQAH4ZgVVxlqibzdAQ--.12846S2 X-Coremail-Antispam: 1UD129KBjvJXoWxXF4UCFWrtr13JFW8Cr1DAwb_yoWrJr45pF W8ur98J3y8JFy7Zan8tayqk343Gr4vkayrGryvk3sxAFs0gr1YvF10k3yYvrW5AFWqg34j 9FWUtFs0yr1DZrUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUP014x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4U JVW0owA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAac4AC62xK8xCEY4vEwIxC4wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC 0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr 1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IE rcIFxwACI402YVCY1x02628vn2kIc2xKxwCY1x0262kKe7AKxVWUtVW8ZwCY02Avz4vE14 v_GFWl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AK xVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrx kI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v2 6r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8Jw CI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43ZEXa7VUjWxR3UU UUU== X-CM-SenderInfo: 52kd05r2suqzpdlo2hxwvl0wxkxdhvlgxou0/1tbiAQICAWoZNVlhZwAAsZ Content-Type: text/plain; charset="utf-8" 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 fc->net_ns for both the RDMA and socket transports instead, so that transport setup follows the VFS mount namespace context rather than depending on the calling process's current namespace. 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 Reported-by: Yuxiang Yang Reported-by: Ao Wang Reported-by: Xuewei Feng Reported-by: Qi Li Reported-by: Ke Xu Suggested-by: Dominique Martinet Assisted-by: GLM:GLM-5.1 Signed-off-by: Yizhou Zhao --- Changes in v2: - Use fc->net_ns instead of current->nsproxy->net_ns in trans_rdma.c (per Dominique Martinet's suggestion: fc->net_ns is the VFS mount namespace, more correct than current->nsproxy->net_ns) - Also fix trans_fd.c which has the same issue: 3 occurrences of current->nsproxy->net_ns replaced with fc->net_ns - Link to v1: https://lore.kernel.org/v9fs/20260529070817.76798-1-zhaoyz24@= mails.tsinghua.edu.cn/ --- net/9p/trans_fd.c | 6 +++--- net/9p/trans_rdma.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index dbad3213b..868882258 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c @@ -887,7 +887,7 @@ p9_fd_create_tcp(struct p9_client *client, struct fs_co= ntext *fc) return -EINVAL; sprintf(port_str, "%u", opts.port); - err =3D inet_pton_with_scope(current->nsproxy->net_ns, AF_UNSPEC, addr, + err =3D inet_pton_with_scope(fc->net_ns, AF_UNSPEC, addr, port_str, &stor); if (err < 0) return err; @@ -896,7 +896,7 @@ p9_fd_create_tcp(struct p9_client *client, struct fs_co= ntext *fc) client->trans_opts.tcp.port =3D opts.port; client->trans_opts.tcp.privport =3D opts.privport; - err =3D __sock_create(current->nsproxy->net_ns, stor.ss_family, + err =3D __sock_create(fc->net_ns, stor.ss_family, SOCK_STREAM, IPPROTO_TCP, &csocket, 1); if (err) { pr_err("%s (%d): problem creating socket\n", @@ -948,7 +948,7 @@ p9_fd_create_unix(struct p9_client *client, struct fs_c= ontext *fc) sun_server.sun_family =3D PF_UNIX; strcpy(sun_server.sun_path, addr); - err =3D __sock_create(current->nsproxy->net_ns, PF_UNIX, + err =3D __sock_create(fc->net_ns, PF_UNIX, SOCK_STREAM, 0, &csocket, 1); if (err < 0) { pr_err("%s (%d): problem creating socket\n", diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c index aa5bd74d3..b3d6c27d7 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_c= ontext *fc) return -ENOMEM; /* Create the RDMA CM ID */ - rdma->cm_id =3D rdma_create_id(&init_net, p9_cm_event_handler, client, + rdma->cm_id =3D rdma_create_id(fc->net_ns, p9_cm_event_handler, client, RDMA_PS_TCP, IB_QPT_RC); if (IS_ERR(rdma->cm_id)) goto error; -- 2.43.0