mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] nvmet: synchronize DH-CHAP secret removal
@ 2026-11-10  8:15 Sreeraj S Kurup
  2026-11-12 21:16 ` Christoph Hellwig
  2026-11-16 15:16 ` Keith Busch
  0 siblings, 2 replies; 4+ messages in thread
From: Sreeraj S Kurup @ 2026-11-10  8:15 UTC (permalink / raw)
  To: hare, hare, hch, kbusch, kch, sagi
  Cc: linux-kernel, linux-nvme, Sreeraj S Kurup

The empty-secret path in nvmet_auth_set_key() modifies and frees
host authentication secrets without holding nvmet_config_sem.

nvmet_setup_auth() accesses these fields under the read lock,
allowing concurrent secret removal to cause a use-after-free.

Acquire nvmet_config_sem for writing while clearing the secrets
to synchronize with authentication setup.

Fixes: bb2df18958b4 ("nvmet-auth: allow to clear DH-HMAC-CHAP keys")
Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
v2:
 - Add Fixes trailer.

 drivers/nvme/target/auth.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/nvme/target/auth.c b/drivers/nvme/target/auth.c
index ccba84b1344e..8fe521690ccd 100644
--- a/drivers/nvme/target/auth.c
+++ b/drivers/nvme/target/auth.c
@@ -26,6 +26,7 @@ int nvmet_auth_set_key(struct nvmet_host *host, const char *secret,
 	char *dhchap_secret;
 
 	if (!strlen(secret)) {
+		down_write(&nvmet_config_sem);
 		if (set_ctrl) {
 			kfree(host->dhchap_ctrl_secret);
 			host->dhchap_ctrl_secret = NULL;
@@ -35,6 +36,7 @@ int nvmet_auth_set_key(struct nvmet_host *host, const char *secret,
 			host->dhchap_secret = NULL;
 			host->dhchap_key_hash = 0;
 		}
+		up_write(&nvmet_config_sem);
 		return 0;
 	}
 	if (sscanf(secret, "DHHC-1:%hhd:%*s", &key_hash) != 1)
-- 
2.55.0


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

* Re: [PATCH v2] nvmet: synchronize DH-CHAP secret removal
  2026-11-10  8:15 [PATCH v2] nvmet: synchronize DH-CHAP secret removal Sreeraj S Kurup
@ 2026-11-12 21:16 ` Christoph Hellwig
  2026-11-16 15:16 ` Keith Busch
  1 sibling, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2026-11-12 21:16 UTC (permalink / raw)
  To: Sreeraj S Kurup; +Cc: hare, hare, kbusch, kch, sagi, linux-kernel, linux-nvme

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


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

* Re: [PATCH v2] nvmet: synchronize DH-CHAP secret removal
  2026-11-10  8:15 [PATCH v2] nvmet: synchronize DH-CHAP secret removal Sreeraj S Kurup
  2026-11-12 21:16 ` Christoph Hellwig
@ 2026-11-16 15:16 ` Keith Busch
  2026-11-16 16:08   ` Sreeraj S Kurup
  1 sibling, 1 reply; 4+ messages in thread
From: Keith Busch @ 2026-11-16 15:16 UTC (permalink / raw)
  To: hare, hare, hch, kch, sagi, Sreeraj S Kurup; +Cc: linux-kernel, linux-nvme

On Tue, 10 Nov 2026 08:15:59 +0000, Sreeraj S Kurup wrote:
> The empty-secret path in nvmet_auth_set_key() modifies and frees
> host authentication secrets without holding nvmet_config_sem.
> 
> nvmet_setup_auth() accesses these fields under the read lock,
> allowing concurrent secret removal to cause a use-after-free.
> 
> Acquire nvmet_config_sem for writing while clearing the secrets
> to synchronize with authentication setup.
> 
> [...]

Thanks, applied to nvme-7.4.

[1/1] nvmet: synchronize DH-CHAP secret removal
      commit: 706076f51eb78ebb4cc7fb06751bf09042fb515c
--
Keith Busch <kbusch@kernel.org>


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

* Re: [PATCH v2] nvmet: synchronize DH-CHAP secret removal
  2026-11-16 15:16 ` Keith Busch
@ 2026-11-16 16:08   ` Sreeraj S Kurup
  0 siblings, 0 replies; 4+ messages in thread
From: Sreeraj S Kurup @ 2026-11-16 16:08 UTC (permalink / raw)
  To: kbusch
  Cc: hare, hare, hch, kch, linux-kernel, linux-nvme, sagi, sreekuttan2156239

Hi,

Thanks for applying the patch!

Best regards,
Sreeraj

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

end of thread, other threads:[~2026-11-16 16:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10  8:15 [PATCH v2] nvmet: synchronize DH-CHAP secret removal Sreeraj S Kurup
2026-11-12 21:16 ` Christoph Hellwig
2026-11-16 15:16 ` Keith Busch
2026-11-16 16:08   ` Sreeraj S Kurup

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®