All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] nvmet: Handle a NULL admin queue in nvmet_queue_tls_keyid()
@ 2026-10-29  3:43 Guixin Liu
  2026-10-29  3:50 ` sashiko-bot
  2026-10-29 12:15 ` Christoph Hellwig
  0 siblings, 2 replies; 3+ messages in thread
From: Guixin Liu @ 2026-10-29  3:43 UTC (permalink / raw)
  To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
	Nilay Shroff, Daniel Wagner, Hannes Reinecke
  Cc: linux-nvme

The admin queue is not necessarily installed when the tls_key debugfs
entry is read: it may not have been created yet, or it may have been
destroyed already.  nvmet_queue_tls_keyid() then dereferences a NULL
sq.

Guard the helper and return 0 instead, which also covers the read
racing with admin queue teardown.

Fixes: 316dabe6089fe ("nvmet: add tls_concat and tls_key debugfs entries")
Cc: stable@vger.kernel.org
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
---

Changes since v1:
- Simply return 0 when the admin queue is absent in
  nvmet_queue_tls_keyid() instead of dereferencing it, covering the
  not-yet-created and already-destroyed windows (Hannes Reinecke)
 drivers/nvme/target/nvmet.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index e315f1c24e73..4e988488497b 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -957,6 +957,8 @@ static inline void nvmet_req_bio_put(struct nvmet_req *req, struct bio *bio)
 #ifdef CONFIG_NVME_TARGET_TCP_TLS
 static inline key_serial_t nvmet_queue_tls_keyid(struct nvmet_sq *sq)
 {
+	if (!sq)
+		return 0;
 	return sq->tls_key ? key_serial(sq->tls_key) : 0;
 }
 static inline void nvmet_sq_put_tls_key(struct nvmet_sq *sq)
-- 
2.43.7



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-29 12:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-29  3:43 [PATCH v2] nvmet: Handle a NULL admin queue in nvmet_queue_tls_keyid() Guixin Liu
2026-10-29  3:50 ` sashiko-bot
2026-10-29 12:15 ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.