From: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
To: hare@kernel.org, hare@suse.de, hch@lst.de, kbusch@kernel.org,
kch@nvidia.com, sagi@grimberg.me
Cc: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org,
Sreeraj S Kurup <sreekuttan2156239@gmail.com>
Subject: [PATCH] nvmet: synchronize DH-CHAP secret removal
Date: Tue, 10 Nov 2026 07:57:33 +0000 [thread overview]
Message-ID: <20261110075733.2578-1-sreekuttan2156239@gmail.com> (raw)
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.
Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
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
next reply other threads:[~2026-11-10 7:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 7:57 Sreeraj S Kurup [this message]
2026-11-10 12:14 ` Hannes Reinecke
2026-11-10 12:54 ` Sreeraj S Kurup
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261110075733.2578-1-sreekuttan2156239@gmail.com \
--to=sreekuttan2156239@gmail.com \
--cc=hare@kernel.org \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=kch@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®