* [PATCH] nvmet: bound the admin queue size of a Connect
@ 2026-12-04 6:48 kq5y
2026-12-04 8:21 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: kq5y @ 2026-12-04 6:48 UTC (permalink / raw)
To: Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni
Cc: Keith Busch, Max Gurtovoy, linux-nvme@lists.infradead.org
Since commit 143667ee9a9c ("nvmet: compare mqes and sqsize only for IO
SQ") nvmet_install_queue() accepts any non-zero sqsize for the admin
queue. Transports size per-queue resources from it, and nvmet-tcp can
allocate an excessive amount of memory for one connection.
The discovery subsystem can be reached without authenticating to a data
subsystem on ports that permit plaintext connections. An oversized admin
queue can therefore exhaust target memory before access to a data
subsystem is checked.
Discovery entries advertise NVME_AQ_DEPTH as the admin submission queue
size. Reject larger admin queues before allocating a controller, report
sqsize as the invalid Connect parameter, and rate-limit the diagnostic
because it is reachable from an unauthenticated peer.
This issue and fix were identified with AI assistance.
Fixes: 143667ee9a9c ("nvmet: compare mqes and sqsize only for IO SQ")
Signed-off-by: Shu Takahashi (Velcore Consulting Inc.) <kq5y@proton.me>
---
drivers/nvme/target/fabrics-cmd.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/nvme/target/fabrics-cmd.c b/drivers/nvme/target/fabrics-cmd.c
index 6f0fc695e649..e65a5f0374c5 100644
--- a/drivers/nvme/target/fabrics-cmd.c
+++ b/drivers/nvme/target/fabrics-cmd.c
@@ -312,6 +312,15 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req)
goto out;
}
+ if (le16_to_cpu(c->sqsize) >= NVME_AQ_DEPTH) {
+ pr_warn_ratelimited("admin sqsize %u is larger than %u\n",
+ le16_to_cpu(c->sqsize), NVME_AQ_DEPTH - 1);
+ args.status = NVME_SC_CONNECT_INVALID_PARAM | NVME_STATUS_DNR;
+ args.error_loc = offsetof(struct nvmf_connect_command, sqsize);
+ args.result = IPO_IATTR_CONNECT_SQE(sqsize);
+ goto out;
+ }
+
d->subsysnqn[NVMF_NQN_FIELD_LEN - 1] = '\0';
d->hostnqn[NVMF_NQN_FIELD_LEN - 1] = '\0';
--
2.56.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] nvmet: bound the admin queue size of a Connect
2026-12-04 6:48 [PATCH] nvmet: bound the admin queue size of a Connect kq5y
@ 2026-12-04 8:21 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2026-12-04 8:21 UTC (permalink / raw)
To: kq5y
Cc: Sagi Grimberg, Chaitanya Kulkarni, Keith Busch, Max Gurtovoy,
linux-nvme@lists.infradead.org
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-04 8:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 6:48 [PATCH] nvmet: bound the admin queue size of a Connect kq5y
2026-12-04 8:21 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox