Thread (10 messages) 10 messages, 3 authors, 2021-06-21
STALE1828d

[PATCH 2/3] nvmet: prevent creating ctrl with no namespace

From: Chaitanya Kulkarni <hidden>
Date: 2021-06-13 20:03:56
Subsystem: nvm express target driver, the rest · Maintainers: Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni, Linus Torvalds

From Spec :-

If the controller supports Asymmetric Namespace Access Reporting, then
MNAN shall be set to a non-zero value that is less than or equal
to the NN value.

In current implementation if subsys has 0 namespaces then we report
wrong MNAN value for the controller if we allow controller creation.

Prevent new controller creation if the subsys associated with the new
controller has no namespaces.

Signed-off-by: Chaitanya Kulkarni <redacted>
---
 drivers/nvme/target/core.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 146909486b8f..26d93ac9bd2e 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -1325,6 +1325,15 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
 		goto out;
 	}
 
+	mutex_lock(&subsys->lock);
+	if (!subsys->max_nsid) {
+		mutex_unlock(&subsys->lock);
+		pr_err("invalid mnan value for the ana enabled controller\n");
+		status = NVME_SC_INTERNAL;
+		goto out_put_subsystem;
+	}
+	mutex_unlock(&subsys->lock);
+
 	down_read(&nvmet_config_sem);
 	if (!nvmet_host_allowed(subsys, hostnqn)) {
 		pr_info("connect by host %s for subsystem %s not allowed\n",
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help