* [PATCH] nvmet: bound the admin queue size of a Connect
@ 2026-12-04 6:48 kq5y
2026-12-04 8:21 ` Christoph Hellwig
2026-12-04 11:55 ` [PATCH v2] " Shu Takahashi (Velcore Consulting Inc.)
0 siblings, 2 replies; 4+ 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] 4+ 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
2026-12-04 11:55 ` [PATCH v2] " Shu Takahashi (Velcore Consulting Inc.)
1 sibling, 0 replies; 4+ 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] 4+ messages in thread
* [PATCH v2] 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
@ 2026-12-04 11:55 ` Shu Takahashi (Velcore Consulting Inc.)
2026-12-04 15:36 ` Keith Busch
1 sibling, 1 reply; 4+ messages in thread
From: Shu Takahashi (Velcore Consulting Inc.) @ 2026-12-04 11:55 UTC (permalink / raw)
To: Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni
Cc: Keith Busch, Max Gurtovoy, linux-nvme@lists.infradead.org
From: Shu Takahashi (Velcore Consulting Inc.) <kq5y@proton.me>
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
Changes in v2:
- Preserve the full author attribution with an in-body From header.
- Add Christoph Hellwig's Reviewed-by tag.
- No code changes.
Link: https://lore.kernel.org/linux-nvme/20261204064802.42918-1-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] 4+ messages in thread* Re: [PATCH v2] nvmet: bound the admin queue size of a Connect
2026-12-04 11:55 ` [PATCH v2] " Shu Takahashi (Velcore Consulting Inc.)
@ 2026-12-04 15:36 ` Keith Busch
0 siblings, 0 replies; 4+ messages in thread
From: Keith Busch @ 2026-12-04 15:36 UTC (permalink / raw)
To: Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni,
Shu Takahashi (Velcore Consulting Inc.)
Cc: Max Gurtovoy, linux-nvme
On Fri, 04 Dec 2026 11:55:42 +0000, Shu Takahashi (Velcore Consulting Inc.) wrote:
> 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.
>
> [...]
Thanks, applied to nvme-7.5.
[1/1] nvmet: bound the admin queue size of a Connect
commit: 951860bb8701ce3ccfec41364867784fa950a345
--
Keith Busch <kbusch@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-04 15:38 UTC | newest]
Thread overview: 4+ 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
2026-12-04 11:55 ` [PATCH v2] " Shu Takahashi (Velcore Consulting Inc.)
2026-12-04 15:36 ` Keith Busch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox