From nobody Fri Sep 25 17:45:57 2026 Received: from mail-m49198.qiye.163.com (mail-m49198.qiye.163.com [45.254.49.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF87A3AA50B; Thu, 10 Sep 2026 04:54:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789016064; cv=none; b=YRnB+u9xsgN+tayaszHVHRrQgoQ/QsDGQkT4lPzZKBoWdXw8wqOcaouQtJfiDLDSHk7SfdvJOenmEXKC6I0U67I2QyW93sYKKqbR/xqvnD/+tnHeVuuXc9p5VXwpbmYV532sQ+uIvFu5M8llG4AEOR1mh5XGBEHpSRoCEZfkKr0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789016064; c=relaxed/simple; bh=+bNs+NW2eCTrCiW0lbLUtsxaYY6RHpLaZqrdvKV1WXk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n7uHl1kMO+TlteDMThiympHfwYASFiWxivAgF+HDYpBXGp+Mk5NKzf/FT34wSCsthAVhom1C1pPeGdeiwGiCp9RIJtqlx+wiXd4slOl8PWC3s5dmATKxh9tAw7W/otKnUQdLV5UiZWQGv9EZDkulVSMFKuLvhtpnm8V37J3Mzxs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn; spf=pass smtp.mailfrom=seu.edu.cn; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b=bSkdwyPI; arc=none smtp.client-ip=45.254.49.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b="bSkdwyPI" Received: from PC-202605011814.localdomain (unknown [223.112.146.162]) by smtp.qiye.163.com (Hmail) with ESMTP id 4d3a5a3c9; Thu, 10 Sep 2026 12:54:09 +0800 (GMT+08:00) From: Runyu Xiao To: Christoph Hellwig Cc: Sagi Grimberg , Chaitanya Kulkarni , Andreas Hindborg , Breno Leitao , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Jianhao Xu Subject: [PATCH v3 1/3] fs: configfs: add helper to identify configfs paths Date: Thu, 10 Sep 2026 12:53:58 +0800 Message-Id: <20260910045400.1201582-2-runyu.xiao@seu.edu.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260910045400.1201582-1-runyu.xiao@seu.edu.cn> References: <20260902103202.GB8095@lst.de> <20260910045400.1201582-1-runyu.xiao@seu.edu.cn> 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-HM-Tid: 0aa089aa866303a1kunm413fe85d18135b X-HM-MType: 10 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWRgWCB1ZQUpXWS1ZQUlXWQ8JGhUIEh9ZQVkaHkJCVk1PSk0YShlDSRgdTFYeHw 5VEwETFhoSFyQUDg9ZV1kYEgtZQVlJSUhVSkpJVUpPTVVKTUlZV1kWGg8SFR0UWUFZT0tIVUpLSE pOTE5VSktLVUpCS0tZBg++ DKIM-Signature: a=rsa-sha256; b=bSkdwyPIcJ3stD5RnvEHmBu4J8+aXeueNw7X0bCyuiDoWWKPxbu8raIot9k1oHoO0PBVBccZ/WevE9Z9hRhvQNWHqM6SYF6Hic9+NcocCi6lkkDNa7sq2ofxusZIsS+YmiApuSuPY5gnvSnC1yiUJGjTSGVEFjx+7TCdBb+QUaE=; c=relaxed/relaxed; s=default; d=seu.edu.cn; v=1; bh=WNhizG42jNgFw5zLdHr3DZPLKap23a4IhuZPG0ipX6E=; h=date:mime-version:subject:message-id:from; Content-Type: text/plain; charset="utf-8" Keep the configfs filesystem type check in configfs so callers can classify resolved paths without comparing filesystem name strings or using filesystem-specific magic numbers. Export the helper for configfs users that need to reject paths into the configuration filesystem while running from a configfs callback. Reviewed-by: Christoph Hellwig Reviewed-by: Sagi Grimberg Assisted-by: LLM Codex Signed-off-by: Runyu Xiao --- fs/configfs/mount.c | 6 ++++++ include/linux/configfs.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c index d8cac1cbf..8abbe3afa 100644 --- a/fs/configfs/mount.c +++ b/fs/configfs/mount.c @@ -118,6 +118,12 @@ static struct file_system_type configfs_fs_type =3D { }; MODULE_ALIAS_FS("configfs"); =20 +bool configfs_path_is_configfs(const struct path *path) +{ + return path->dentry->d_sb->s_type =3D=3D &configfs_fs_type; +} +EXPORT_SYMBOL_GPL(configfs_path_is_configfs); + struct dentry *configfs_pin_fs(void) { int err =3D simple_pin_fs(&configfs_fs_type, &configfs_mount, diff --git a/include/linux/configfs.h b/include/linux/configfs.h index ef65c75be..55df734da 100644 --- a/include/linux/configfs.h +++ b/include/linux/configfs.h @@ -34,6 +34,7 @@ struct configfs_group_operations; struct configfs_attribute; struct configfs_bin_attribute; struct configfs_subsystem; +struct path; =20 struct config_item { char *ci_name; @@ -243,6 +244,7 @@ void configfs_unregister_subsystem(struct configfs_subs= ystem *subsys); int configfs_register_group(struct config_group *parent_group, struct config_group *group); void configfs_unregister_group(struct config_group *group); +bool configfs_path_is_configfs(const struct path *path); =20 void configfs_remove_default_groups(struct config_group *group); =20 --=20 2.34.1 From nobody Fri Sep 25 17:45:57 2026 Received: from mail-m49198.qiye.163.com (mail-m49198.qiye.163.com [45.254.49.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B67D1384CDD; Thu, 10 Sep 2026 04:54:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789016065; cv=none; b=YDcGp1HcnZ0iCj3pUl7BTkaJn216yozWoTYYZSoWilJOK6QhKmk6SG1ECV2Bzarw+hhb2oNueWwynzH1wfgo9Rs2EvlEaMyk9371J4ho8It7Tlh9LYijLsNFjLjUNR1rfK47RfG5OVB/gM45aNOPKaYM1HcBm5ZvqW7byfgYrRI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789016065; c=relaxed/simple; bh=Ug7qX+4vRsUXWFK8FGHW49zfSGDgtHiJD4+F9815LM0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mp6jj/ihpMZVGW91mVE85h3uSUxA+wf1kLuNgA8uQS6+E1tJW6if+XN8e6CYvMwZ0RXfVZJMaIUp80bKAj6+47XUS+4ugd1n/SFuA5et2+FMcwbmpn+s4NBkovG9k+l5stEqJienVW21DXLnbDeB2yNWy5wM/ZkWJao2tvM4V/s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn; spf=pass smtp.mailfrom=seu.edu.cn; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b=l7QwzizM; arc=none smtp.client-ip=45.254.49.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b="l7QwzizM" Received: from PC-202605011814.localdomain (unknown [223.112.146.162]) by smtp.qiye.163.com (Hmail) with ESMTP id 4d3a5a3cc; Thu, 10 Sep 2026 12:54:11 +0800 (GMT+08:00) From: Runyu Xiao To: Christoph Hellwig Cc: Sagi Grimberg , Chaitanya Kulkarni , Andreas Hindborg , Breno Leitao , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Jianhao Xu Subject: [PATCH v3 2/3] nvmet: avoid recursive configfs open for file-backed namespaces Date: Thu, 10 Sep 2026 12:53:59 +0800 Message-Id: <20260910045400.1201582-3-runyu.xiao@seu.edu.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260910045400.1201582-1-runyu.xiao@seu.edu.cn> References: <20260902103202.GB8095@lst.de> <20260910045400.1201582-1-runyu.xiao@seu.edu.cn> 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-HM-Tid: 0aa089aa8dcf03a1kunm413fe85d18135f X-HM-MType: 10 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWRgWCB1ZQUpXWS1ZQUlXWQ8JGhUIEh9ZQVlDShhCVhlITk0aGR8aSExJQ1YeHw 5VEwETFhoSFyQUDg9ZV1kYEgtZQVlJSUhVSkpJVUpPTVVKTUlZV1kWGg8SFR0UWUFZT0tIVUpLSU hOQ0NVSktLVUtZBg++ DKIM-Signature: a=rsa-sha256; b=l7QwzizMF6Qh78XoOPLh1sRc0qLZV3i91uLMhEcyX0d8TtDDnG3017L22U9hv3N0Wiq/hQXUKZtXxWjNcKKY3gOHEf07LPn6C05fcogHHjY3AueL0Vxwh5XSUkwkJHPqSyl+XF70/wkhnBhtOzEffSmnlqWg61sN6TUrDRMa3Sc=; c=relaxed/relaxed; s=default; d=seu.edu.cn; v=1; bh=xh7JsIVIqlqNdpmS1/fMVr20nh1KQUtlcaOcE6VOBMI=; h=date:mime-version:subject:message-id:from; Content-Type: text/plain; charset="utf-8" nvmet_ns_enable_store() runs as a configfs store callback while configfs holds the item's frag_sem. A file-backed namespace then opens the configured device_path with filp_open(). If the path resolves into configfs, the open path re-enters __configfs_open_file() and attempts to acquire the same frag_sem again. Resolve the configured path first, reject paths resolved on configfs, and open the resolved path with file_open_root(). This preserves the standard open-time permission checks without performing a second pathname walk. Use the configfs helper for the filesystem type check so this caller shares the classification with other configfs users. Fixes: d5eff33ee6f8 ("nvmet: add simple file backed ns support") Cc: stable@vger.kernel.org Reviewed-by: Sagi Grimberg Assisted-by: LLM Codex Signed-off-by: Runyu Xiao --- drivers/nvme/target/io-cmd-file.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd= -file.c index 0b22d183f..fbe58aa4a 100644 --- a/drivers/nvme/target/io-cmd-file.c +++ b/drivers/nvme/target/io-cmd-file.c @@ -8,7 +8,9 @@ #include #include #include +#include #include +#include #include "nvmet.h" =20 #define NVMET_MIN_MPOOL_OBJ 16 @@ -33,12 +35,28 @@ void nvmet_file_ns_disable(struct nvmet_ns *ns) int nvmet_file_ns_enable(struct nvmet_ns *ns) { int flags =3D O_RDWR | O_LARGEFILE; + struct path path; int ret =3D 0; =20 if (!ns->buffered_io) flags |=3D O_DIRECT; =20 - ns->file =3D filp_open(ns->device_path, flags, 0); + ret =3D kern_path(ns->device_path, LOOKUP_FOLLOW, &path); + if (ret) { + pr_err("failed to open file %s: (%d)\n", + ns->device_path, ret); + return ret; + } + + if (configfs_path_is_configfs(&path)) { + pr_err("configfs paths cannot back namespace %s\n", + ns->device_path); + path_put(&path); + return -EINVAL; + } + + ns->file =3D file_open_root(&path, "", flags, 0); + path_put(&path); if (IS_ERR(ns->file)) { ret =3D PTR_ERR(ns->file); pr_err("failed to open file %s: (%d)\n", --=20 2.34.1 From nobody Fri Sep 25 17:45:57 2026 Received: from mail-m155101.qiye.163.com (mail-m155101.qiye.163.com [101.71.155.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CCCB3B52EF; Thu, 10 Sep 2026 04:54:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=101.71.155.101 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789016065; cv=none; b=c91hI0WOGtDO2qAiGoIH7HttZNGctpSBa0G3eynLu+L2KLYv26TwFMiRmoT2B3iM/vAso9RGgPhXw6Kv4zV7nJX8INhMmc2nP+iv8HzIc0Z1Q2SmpLD0/eVIopV4HNm39nbIa1+KBG2Z+dXGR7ywfri6bikqfQT5up/2V7Hf1J4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789016065; c=relaxed/simple; bh=agw5GRV8zJ0ivu0/kYq8UcseI+WEQ+kU4Nt10keaXUQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WDVXQbiGW4MYKP+CixUluDQKdj1lzUsuq7ah2LSf247Wy0D51kvTWs/I9ZuRufl+WxmMvLeRk1O/82AQwMwpac+qpjLm8btaM3GUfSxlf88K3WRiRz2wqt7/TUGerMtkRD+z+jeejVR0PIY67DhgbxCCCD+Zno1ZZrC5C4CAw2k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn; spf=pass smtp.mailfrom=seu.edu.cn; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b=VHpAZOtP; arc=none smtp.client-ip=101.71.155.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b="VHpAZOtP" Received: from PC-202605011814.localdomain (unknown [223.112.146.162]) by smtp.qiye.163.com (Hmail) with ESMTP id 4d3a5a3ce; Thu, 10 Sep 2026 12:54:12 +0800 (GMT+08:00) From: Runyu Xiao To: Christoph Hellwig Cc: Sagi Grimberg , Chaitanya Kulkarni , Andreas Hindborg , Breno Leitao , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Jianhao Xu Subject: [PATCH v3 3/3] nvmet: avoid recursive configfs open for passthru Date: Thu, 10 Sep 2026 12:54:00 +0800 Message-Id: <20260910045400.1201582-4-runyu.xiao@seu.edu.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260910045400.1201582-1-runyu.xiao@seu.edu.cn> References: <20260902103202.GB8095@lst.de> <20260910045400.1201582-1-runyu.xiao@seu.edu.cn> 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-HM-Tid: 0aa089aa943003a1kunm413fe85d181362 X-HM-MType: 10 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWRgWCB1ZQUpXWS1ZQUlXWQ8JGhUIEh9ZQVkZHhlKVhkdSRpPS0hDTU9MTVYeHw 5VEwETFhoSFyQUDg9ZV1kYEgtZQVlJSUhVSkpJVUpPTVVKTUlZV1kWGg8SFR0UWUFZT0tIVUpLSU hOQ0NVSktLVUtZBg++ DKIM-Signature: a=rsa-sha256; b=VHpAZOtPlL/oqxx6NnJst7DEVqW4wFH1X3/fNiAwrbUptRyGG7E9+Cq/fuSkrkeeOWwLhNKrSQvNd+Vm2kRO8BgzKQ5FYK2ID95DZQXEKNbF4WVhkuVIa448msJyYUQXmA4sNIZWU/jIZPNm3I81lWOFaBQdG+7PVhBMjr+6kO0=; c=relaxed/relaxed; s=default; d=seu.edu.cn; v=1; bh=wPPMTFM/RlLKVmOG8oGw1kTaF1eOnMkGUDWNx0SoHbM=; h=date:mime-version:subject:message-id:from; Content-Type: text/plain; charset="utf-8" nvmet_passthru_enable_store() runs as a configfs store callback while configfs holds the item's frag_sem. Enabling passthru then opens the configured passthru_ctrl_path with filp_open(). If that path resolves into configfs, the open path re-enters __configfs_open_file() and attempts to acquire the same frag_sem again. Resolve the configured path first, reject paths resolved on configfs, and open the resolved path with file_open_root(). This preserves the standard open-time permission checks without performing a second pathname walk. Use the configfs helper for the filesystem type check so this caller shares the classification with other configfs users. Fixes: cae5b01a2afc ("nvmet: introduce the passthru configfs interface") Cc: stable@vger.kernel.org Reviewed-by: Sagi Grimberg Assisted-by: LLM Codex Signed-off-by: Runyu Xiao --- drivers/nvme/target/passthru.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/target/passthru.c b/drivers/nvme/target/passthru.c index fa6527c53..aa1778c9e 100644 --- a/drivers/nvme/target/passthru.c +++ b/drivers/nvme/target/passthru.c @@ -9,6 +9,8 @@ */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include +#include =20 #include "../host/nvme.h" #include "nvmet.h" @@ -588,6 +590,7 @@ int nvmet_passthru_ctrl_enable(struct nvmet_subsys *sub= sys) { struct nvme_ctrl *ctrl; struct file *file; + struct path path; int ret =3D -EINVAL; void *old; =20 @@ -602,7 +605,19 @@ int nvmet_passthru_ctrl_enable(struct nvmet_subsys *su= bsys) goto out_unlock; } =20 - file =3D filp_open(subsys->passthru_ctrl_path, O_RDWR, 0); + ret =3D kern_path(subsys->passthru_ctrl_path, LOOKUP_FOLLOW, &path); + if (ret) + goto out_unlock; + + if (configfs_path_is_configfs(&path)) { + pr_err("configfs paths cannot back passthru controller %s\n", + subsys->passthru_ctrl_path); + path_put(&path); + goto out_unlock; + } + + file =3D file_open_root(&path, "", O_RDWR, 0); + path_put(&path); if (IS_ERR(file)) { ret =3D PTR_ERR(file); goto out_unlock; --=20 2.34.1