From nobody Mon Sep 28 18:36:44 2026 Received: from mail-m49197.qiye.163.com (mail-m49197.qiye.163.com [45.254.49.197]) (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 33F4D480DCD; Wed, 19 Aug 2026 15:52:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787154792; cv=none; b=g2sl0KYt19KA6WjdIxFUMeUWZblKY48xpIJXcdYijT3cX/W/spNvQDEQxs60Yurnv5FbBa+HahQb7HTyfpF2fvM1iQwA26/q4MWpMFCopbO15qpnCrtWOiGlJpNjbemu5oBKJPFgn3Yc8b5ioQP6gZh+5vZdqPGpU9tPDancJl0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787154792; c=relaxed/simple; bh=dISYKAJ7ZTYFk9RiBLR7zVrw1iL2r8Ul9aDfuHAiFOc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MEhMdvQc0vWXDEzRk4fj8aKy5CkYNpnw9mrVJkGkpgrbxw4zmX30/IqW/nHHoilVjBVle+67MvDRaoEc7wWo+2Kmzx7p/1vhcv4XEBQhatu2BjNl+VubFrXVXr/vURLbkk/KCc5T3uxC4VO75VSkhN/QwuzT7e9Q4rpQPajOGXw= 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=W6UvOtxS; arc=none smtp.client-ip=45.254.49.197 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="W6UvOtxS" Received: from PC-202605011814.localdomain (unknown [58.241.16.34]) by smtp.qiye.163.com (Hmail) with ESMTP id 4a95ff6de; Wed, 19 Aug 2026 23:52:41 +0800 (GMT+08:00) From: Runyu Xiao To: Christoph Hellwig Cc: Sagi Grimberg , Chaitanya Kulkarni , Keith Busch , Logan Gunthorpe , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Runyu Xiao , Jianhao Xu Subject: [PATCH v2 1/3] fs: configfs: add helper to identify configfs paths Date: Wed, 19 Aug 2026 23:52:26 +0800 Message-Id: <20260819155228.84938-2-runyu.xiao@seu.edu.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260819155228.84938-1-runyu.xiao@seu.edu.cn> References: <20260817143714.1344255-1-runyu.xiao@seu.edu.cn> <20260819155228.84938-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: 0aa01ab9890a03a1kunm38a93da01445bb X-HM-MType: 10 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWRgWCB1ZQUpXWS1ZQUlXWQ8JGhUIEh9ZQVkZQxhCVk5CSUJDTEMYGB9OGVYeHw 5VEwETFhoSFyQUDg9ZV1kYEgtZQVlOQ1VJT0pVSk1VSE9ZV1kWGg8SFR0UWUFZT0tIVUpLSEpPSE xVSktLVUpCS0tZBg++ DKIM-Signature: a=rsa-sha256; b=W6UvOtxSnCsHUR6W1AH8fkpsNrYUexXjJ9zDaDbaFzvYUxx8h1E7Wk1ZxgK9OXKvXWX2b7GswVYoHCNIQuzS5FjJ/D1FDnJQF0SutYEfQb+qvdAVE608fcMEwkSwgYuDWIP+x1kh845EOaKTShiLjtpF3w5UwWt+U14FQrjvlaE=; c=relaxed/relaxed; s=default; d=seu.edu.cn; v=1; bh=zYlm9WNLox2kaFNQpUZgFMheB5hPrtAfLIyn5XxB4ik=; h=date:mime-version:subject:message-id:from; Content-Type: text/plain; charset="utf-8" Several nvmet paths need to identify configfs-backed resolved paths while already running under configfs callbacks. Keep the classification in configfs itself so callers can reuse the filesystem-type test instead of open-coding string comparisons. Signed-off-by: Runyu Xiao Reviewed-by: Christoph Hellwig Reviewed-by: Sagi Grimberg --- 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 456c4a2efb53..1204421b61df 100644 --- a/fs/configfs/mount.c +++ b/fs/configfs/mount.c @@ -120,6 +120,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 698520b1bfdb..b3426c952835 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 Mon Sep 28 18:36:44 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 D49C247F774; Wed, 19 Aug 2026 15:52:56 +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=1787154780; cv=none; b=hjcuoQF+K+lewVPIEF2WFbYSm3myW5v6t3iVcx4WjKqQie14pUSYJ6eDO0RHlhmp0o63fFGFMLcfukPgzxvXGeLOcXF8pT5YgAVTduRNrMe69lHjy7CDdJPk8wUiLOQxGKmxz90B60r5qLSKWDubsr1Sb5BH2w5U74oO0nUSj0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787154780; c=relaxed/simple; bh=pDKk4+GUwUyyh1k3sTrw/lc/j9k9uzdFhvH1nfTjD6E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pERivCCETyzWwISSPc1W8P22d7X/oYnHspA9aVsbBu3hzM5+U4H1lQ1Kk7oA44ZlVuCFI878UCed/jv/OHxOCmT4CGRUgDnpvqZ0mHri4J26YIfGta+FQV9jYl5OPtvBeP80VxJzxfArZmUtrKuG51FE0r05z13a3dDqT7MXNRs= 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=mpKv67VH; 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="mpKv67VH" Received: from PC-202605011814.localdomain (unknown [58.241.16.34]) by smtp.qiye.163.com (Hmail) with ESMTP id 4a95ff6df; Wed, 19 Aug 2026 23:52:43 +0800 (GMT+08:00) From: Runyu Xiao To: Christoph Hellwig Cc: Sagi Grimberg , Chaitanya Kulkarni , Keith Busch , Logan Gunthorpe , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Runyu Xiao , Jianhao Xu Subject: [PATCH v2 2/3] nvmet: avoid recursive configfs open for file-backed namespaces Date: Wed, 19 Aug 2026 23:52:27 +0800 Message-Id: <20260819155228.84938-3-runyu.xiao@seu.edu.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260819155228.84938-1-runyu.xiao@seu.edu.cn> References: <20260817143714.1344255-1-runyu.xiao@seu.edu.cn> <20260819155228.84938-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: 0aa01ab98f8203a1kunm38a93da01445bd X-HM-MType: 10 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWRgWCB1ZQUpXWS1ZQUlXWQ8JGhUIEh9ZQVkaHUxCVh5KSUkaTxhJH09JTVYeHw 5VEwETFhoSFyQUDg9ZV1kYEgtZQVlOQ1VJT0pVSk1VSE9ZV1kWGg8SFR0UWUFZT0tIVUpLSEpPSE xVSktLVUpCS0tZBg++ DKIM-Signature: a=rsa-sha256; b=mpKv67VHtJPQgFBgJxZRmLRJC0FADyvLmsSLm0dZy/Iub6qfGqshWoE2P1/tX3+shlprVcekw8XoOWIHTc98Cb9jBIJTZ4hKJ4lVgBoZLBn8DPQzA2oYKdFnIUjCRsCa1ENJ00gmDAoL9idyyys/Vx5EpupWGH0G0Nj16rVES4Y=; c=relaxed/relaxed; s=default; d=seu.edu.cn; v=1; bh=jZ8LIQ9IsX5SI4Y97L1IUaZXjjXymwc4snkScUx/aks=; h=date:mime-version:subject:message-id:from; Content-Type: text/plain; charset="utf-8" nvmet_ns_enable_store() runs under configfs frag_sem. If a file-backed namespace path resolves into configfs, filp_open() can re-enter configfs and recurse on the same semaphore. Reject configfs-backed paths after kern_path() and open the resolved path with dentry_open() instead. Fixes: d5eff33ee6f8 ("nvmet: add simple file backed ns support") Cc: stable@vger.kernel.org Signed-off-by: Runyu Xiao Reviewed-by: Sagi Grimberg --- 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 2d068439b129..4ba3ebb82e6a 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 dentry_open(&path, flags, current_cred()); + 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 Mon Sep 28 18:36:44 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 44EDC48123E; Wed, 19 Aug 2026 15:52:54 +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=1787154778; cv=none; b=SDQfbapvV+9/kQIJ2fNqQFuCj6jtUbiVZff/NFGXYvK3WVBQyL83TxUsCeovAw8JjtnWcznDquEqfNut/o/wX9ZrZCuZ5GsXPTMQtsQujxLafbdvZWB+aRQ9OEwbJr3DPN74LUuiyigG73VcstPAi0s2qeT02vNcdq2gdZRKoNU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787154778; c=relaxed/simple; bh=qumvmFUxjqL7+H+Sf/xcg3B2pURzdDZt02BUC/vMl38=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MXMv1oBRATlORPR2QvtKH9xSKauPPP9KkuqF83w6GLVyBsSe3h8Wj5EhY9s+8KiRRVCbf8m2Z7ebgmwTy+Ki1YLTApI8gM/+bHkWqt7Fn0+NpIL6wULEXqejOa/S9JM1nNDDKMXWN6KQZFaZOVVq0uQjM7HYKva0vaTzZPKecZs= 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=MjX3Td8f; 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="MjX3Td8f" Received: from PC-202605011814.localdomain (unknown [58.241.16.34]) by smtp.qiye.163.com (Hmail) with ESMTP id 4a95ff6e1; Wed, 19 Aug 2026 23:52:45 +0800 (GMT+08:00) From: Runyu Xiao To: Christoph Hellwig Cc: Sagi Grimberg , Chaitanya Kulkarni , Keith Busch , Logan Gunthorpe , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Runyu Xiao , Jianhao Xu Subject: [PATCH v2 3/3] nvmet: avoid recursive configfs open for passthru Date: Wed, 19 Aug 2026 23:52:28 +0800 Message-Id: <20260819155228.84938-4-runyu.xiao@seu.edu.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260819155228.84938-1-runyu.xiao@seu.edu.cn> References: <20260817143714.1344255-1-runyu.xiao@seu.edu.cn> <20260819155228.84938-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: 0aa01ab9958f03a1kunm38a93da01445c0 X-HM-MType: 10 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWRgWCB1ZQUpXWS1ZQUlXWQ8JGhUIEh9ZQVkaT0xJVkkaHh1JHxhCHk5NSVYeHw 5VEwETFhoSFyQUDg9ZV1kYEgtZQVlOQ1VJT0pVSk1VSE9ZV1kWGg8SFR0UWUFZT0tIVUpLSEpPSE xVSktLVUpCS0tZBg++ DKIM-Signature: a=rsa-sha256; b=MjX3Td8fO9zdpAjI8ziB+YxXTGbtgmZGeDSj11H+VqU0HQGNSzpmnqi4jak2mLRyAlaZmb5bROCEOwLBFT+o25Amklx6ClrNEVtm509XW0RXDPRv9WOm++kD6vMM8b76f/W9UO//yULlJvx/E0MOBhjcxj36WJzTY1754aKy36k=; c=relaxed/relaxed; s=default; d=seu.edu.cn; v=1; bh=ibe22cMUDWrdIKNBbA5Osf/dOdBYA7FGe74ypRustCg=; h=date:mime-version:subject:message-id:from; Content-Type: text/plain; charset="utf-8" nvmet_passthru_ctrl_enable() runs under configfs frag_sem. If the configured passthru controller path resolves into configfs, filp_open() can re-enter configfs and recurse on the same semaphore. Reject configfs-backed paths after kern_path() and open the resolved path with dentry_open() instead. Fixes: cae5b01a2afc ("nvmet: introduce the passthru configfs interface") Cc: stable@vger.kernel.org Signed-off-by: Runyu Xiao Reviewed-by: Sagi Grimberg --- 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 0c361b1e3566..b3c57bf033e1 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" @@ -578,6 +580,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 @@ -592,7 +595,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 dentry_open(&path, O_RDWR, current_cred()); + path_put(&path); if (IS_ERR(file)) { ret =3D PTR_ERR(file); goto out_unlock; --=20 2.34.1