lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <SN7PR20MB6609903F74075383EC400BFC808FA@SN7PR20MB6609.namprd20.prod.outlook.com>
Date:   Mon, 11 Dec 2023 21:37:07 +0000
From:   Evan Burgess <evan.burgess@...gate.com>
To:     Christoph Hellwig <hch@....de>,
        "sagi@...mberg.me" <sagi@...mberg.me>,
        Chaitanya Kulkarni <kch@...dia.com>
CC:     "linux-nvme@...ts.infradead.org" <linux-nvme@...ts.infradead.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [RFC] nvmet: configfs: use ctrl->instance to track passthru
 subsystems

To prevent enabling more than one passthrough subsystem per NVMe
controller, passthru.c maintains an xarray indexed by cntlid values.
An nvmet subsystem cannot enable passthrough via configfs if its
passthru_ctrl->cntlid value is already accounted for by the xarray. 

However, according to the NVMe base spec (rev 2.0c, p.145), "The
Controller ID (CNTLID) value returned in the Identify Controller data
structure may be used to uniquely identify a controller within an NVM 
subsystem," meaning that cntlid values are not guaranteed to be
globally unique across multiple subsystems. Instead, the cntlid only 
uniquely identifies multiple controllers _within_ a subsystem.

As a result, multiple unique & valid NVMe targets can be blocked from
enabling passthrough at the same time if their controllers share cntlid
values, a behavior (seemingly) allowed by the spec. This could be
remedied by indexing the xarray with passthru_ctrl->instance values, 
which are allocated per controller by IDA and thus should act as truly
unique controller identifiers.

I have seen this issue in practice, but have found a suspicious lack of 
corroboration across this ML and elsewhere (so far). So, I am not 
discounting a possible misunderstanding of the spec and/or code here.

Signed-off-by: Evan Burgess <evan.burgess@...gate.com>
---
 drivers/nvme/target/passthru.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/target/passthru.c b/drivers/nvme/target/passthru.c
index 9fe07d7efa96..f2d963e1fe94 100644
--- a/drivers/nvme/target/passthru.c
+++ b/drivers/nvme/target/passthru.c
@@ -602,7 +602,7 @@ int nvmet_passthru_ctrl_enable(struct nvmet_subsys *subsys)
 		goto out_put_file;
 	}
 
-	old = xa_cmpxchg(&passthru_subsystems, ctrl->cntlid, NULL,
+	old = xa_cmpxchg(&passthru_subsystems, ctrl->instance, NULL,
 			 subsys, GFP_KERNEL);
 	if (xa_is_err(old)) {
 		ret = xa_err(old);
@@ -635,7 +635,7 @@ int nvmet_passthru_ctrl_enable(struct nvmet_subsys *subsys)
 static void __nvmet_passthru_ctrl_disable(struct nvmet_subsys *subsys)
 {
 	if (subsys->passthru_ctrl) {
-		xa_erase(&passthru_subsystems, subsys->passthru_ctrl->cntlid);
+		xa_erase(&passthru_subsystems, subsys->passthru_ctrl->instance);
 		module_put(subsys->passthru_ctrl->ops->module);
 		nvme_put_ctrl(subsys->passthru_ctrl);
 	}
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ