From: sashiko-bot@kernel.org
To: "Martin George" <martinus.gpy@gmail.com>, linux-nvme@lists.infradead.org
Subject: Re: [PATCH 1/2] nvme-sysfs: use kfree_sensitive() for DH-HMAC-CHAP secrets
Date: Mon, 16 Nov 2026 10:14:02 +0000 [thread overview]
Message-ID: <sashiko-outbox-216698@kernel.org> (raw)
In-Reply-To: <20261116100244.7824-2-marting@netapp.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] nvme: double-free and use-after-free in
nvme_ctrl_dhchap_secret_store() [1]
--
commit 86ec9e603dccdb522db4b07402c30b2c18b2a11b
Author: Martin George <martinus.gpy@gmail.com>
nvme-sysfs: use kfree_sensitive() for DH-HMAC-CHAP secrets
This commit replaces kfree() with kfree_sensitive() when freeing DH-HMAC-CHAP
secret strings in dhchap_secret_store() and dhchap_ctrl_secret_store().
> diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
> index 10018c6356b62..5a195b8971f21 100644
> --- a/drivers/nvme/host/sysfs.c
> +++ b/drivers/nvme/host/sysfs.c
> @@ -849,10 +849,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);
[Severity: Critical]
This problem wasn't introduced by this patch, but can concurrent sysfs accesses
[1] trigger a double free or use-after-free on opts->dhchap_secret and
ctrl->host_key?
In dhchap_secret_store(), opts->dhchap_secret is freed and replaced without
holding a lock, and ctrl->host_key is read before acquiring
ctrl->dhchap_auth_mutex:
CPU0 CPU1
dhchap_secret_store() dhchap_secret_store()
kfree_sensitive(opts->dhchap_secret)
kfree_sensitive(opts->dhchap_secret)
<-- double free
opts->dhchap_secret = dhchap_secret
host_key = ctrl->host_key
host_key = ctrl->host_key
mutex_lock(&ctrl->dhchap_auth_mutex)
ctrl->host_key = key
mutex_unlock(&ctrl->dhchap_auth_mutex)
nvme_auth_free_key(host_key)
mutex_lock(&ctrl->dhchap_auth_mutex)
ctrl->host_key = key
mutex_unlock(&ctrl->dhchap_auth_mutex)
nvme_auth_free_key(host_key)
<-- double free
A concurrent dhchap_secret_show() or strcmp() in dhchap_secret_store() can
also read opts->dhchap_secret while it is being freed, causing a
use-after-free. The same unlocked accesses exist in
dhchap_ctrl_secret_store() and dhchap_ctrl_secret_show() for
opts->dhchap_ctrl_secret and ctrl->ctrl_key.
[1] https://sashiko.dev/#/bug/linux-d9bcd9ea-2b96-4998-b954-e0e2557a158a
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116100244.7824-1-marting@netapp.com?part=1
next prev parent reply other threads:[~2026-11-16 10:14 UTC|newest]
Thread overview: 7+ 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 ` [PATCH 1/2] nvme-sysfs: " Martin George
2026-11-16 10:14 ` sashiko-bot [this message]
2026-11-16 13:44 ` Hannes Reinecke
2026-11-16 10:02 ` [PATCH 2/2] nvme-fabrics: use kfree_sensitive() for the old DH-HMAC-CHAP secret Martin George
2026-11-16 13:45 ` Hannes Reinecke
2026-11-16 16:18 ` [PATCH 0/2] nvme: use kfree_sensitive() for DH-HMAC-CHAP secrets Keith Busch
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=sashiko-outbox-216698@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=martinus.gpy@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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 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.