From: Martin George <martinus.gpy@gmail.com>
To: linux-nvme@lists.infradead.org
Cc: hch@lst.de, kbusch@kernel.org, sagi@grimberg.me, hare@kernel.org
Subject: [PATCH 1/2] nvme-sysfs: use kfree_sensitive() for DH-HMAC-CHAP secrets
Date: Mon, 16 Nov 2026 15:32:43 +0530 [thread overview]
Message-ID: <20261116100244.7824-2-marting@netapp.com> (raw)
In-Reply-To: <20261116100244.7824-1-marting@netapp.com>
dhchap_secret_store() and dhchap_ctrl_secret_store() free the raw
"DHHC-1:..." secret with plain kfree(), leaving it in the freed
slab. As these are the runtime rotation handlers, every secret
change also leaves the previous secret behind. Free them with
kfree_sensitive() instead.
Signed-off-by: Martin George <marting@netapp.com>
---
drivers/nvme/host/sysfs.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
index 9672ca3f74d2..35f871e3e0c0 100644
--- a/drivers/nvme/host/sysfs.c
+++ b/drivers/nvme/host/sysfs.c
@@ -850,10 +850,10 @@ static ssize_t dhchap_secret_store(struct device *dev,
ret = nvme_auth_parse_key(dhchap_secret, &key);
if (ret) {
- kfree(dhchap_secret);
+ kfree_sensitive(dhchap_secret);
return ret;
}
- kfree(opts->dhchap_secret);
+ kfree_sensitive(opts->dhchap_secret);
opts->dhchap_secret = dhchap_secret;
host_key = ctrl->host_key;
mutex_lock(&ctrl->dhchap_auth_mutex);
@@ -861,7 +861,7 @@ static ssize_t dhchap_secret_store(struct device *dev,
mutex_unlock(&ctrl->dhchap_auth_mutex);
nvme_auth_free_key(host_key);
} else
- kfree(dhchap_secret);
+ kfree_sensitive(dhchap_secret);
/* Start re-authentication */
dev_info(ctrl->device, "re-authenticating controller\n");
queue_work(nvme_wq, &ctrl->dhchap_auth_work);
@@ -907,10 +907,10 @@ static ssize_t dhchap_ctrl_secret_store(struct device *dev,
ret = nvme_auth_parse_key(dhchap_secret, &key);
if (ret) {
- kfree(dhchap_secret);
+ kfree_sensitive(dhchap_secret);
return ret;
}
- kfree(opts->dhchap_ctrl_secret);
+ kfree_sensitive(opts->dhchap_ctrl_secret);
opts->dhchap_ctrl_secret = dhchap_secret;
ctrl_key = ctrl->ctrl_key;
mutex_lock(&ctrl->dhchap_auth_mutex);
@@ -918,7 +918,7 @@ static ssize_t dhchap_ctrl_secret_store(struct device *dev,
mutex_unlock(&ctrl->dhchap_auth_mutex);
nvme_auth_free_key(ctrl_key);
} else
- kfree(dhchap_secret);
+ kfree_sensitive(dhchap_secret);
/* Start re-authentication */
dev_info(ctrl->device, "re-authenticating controller\n");
queue_work(nvme_wq, &ctrl->dhchap_auth_work);
--
2.53.0
next prev parent reply other threads:[~2026-11-16 10:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 10:02 [PATCH 0/2] nvme: use kfree_sensitive() for DH-HMAC-CHAP secrets Martin George
2026-11-16 10:02 ` Martin George [this message]
2026-11-16 10:14 ` [PATCH 1/2] nvme-sysfs: " sashiko-bot
2026-11-16 10:02 ` [PATCH 2/2] nvme-fabrics: use kfree_sensitive() for the old DH-HMAC-CHAP secret Martin George
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=20261116100244.7824-2-marting@netapp.com \
--to=martinus.gpy@gmail.com \
--cc=hare@kernel.org \
--cc=hch@lst.de \
--cc=kbusch@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