From: sashiko-bot@kernel.org
To: "Hannes Reinecke" <hare@kernel.org>,
"Keith Busch" <kbusch@kernel.org>, "Jens Axboe" <axboe@kernel.dk>,
"Christoph Hellwig" <hch@lst.de>,
"Sagi Grimberg" <sagi@grimberg.me>,
"Hannes Reinecke" <hare@suse.de>,
"Chaitanya Kulkarni" <kch@nvidia.com>,
"Eric Biggers" <ebiggers@kernel.org>,
"David Howells" <dhowells@redhat.com>,
"Jarkko Sakkinen" <jarkko@kernel.org>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Kees Cook" <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: linux-nvme@lists.infradead.org, keyrings@vger.kernel.org,
"Martin Belanger" <martin.nvme.dev@gmail.com>
Subject: Re: [PATCH v7 14/14] nvme-auth: allow to update pre-provisioned keys
Date: Thu, 26 Nov 2026 14:31:58 +0000 [thread overview]
Message-ID: <sashiko-outbox-235712@kernel.org> (raw)
In-Reply-To: <20261126-dhchap-keyring-v4-v7-14-ee438ffea527@kernel.org>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] nvme-auth: uninitialized old_key dereference in
dhchap_*_secret_store()
- [High] nvme-keyring: .update callback added to psk instead of dhchap
key_type
- [Medium] nvme-auth: wrong pre-populated key check in
dhchap_*_secret_store()
--
commit 3ccb1f2ff3d815bafe5e4d68e5e266a56f5a6f51
Author: Hannes Reinecke <hare@kernel.org>
nvme-auth: allow to update pre-provisioned keys
This commit attempts to support rotating pre-provisioned DH-HMAC-CHAP keys
via keyctl update by adding a key_type .update callback and disallowing
sysfs key replacements for pre-populated controller keys.
> diff --git a/drivers/nvme/common/keyring.c b/drivers/nvme/common/keyring.c
> index bee64c592752a..ffabd37cd090d 100644
> --- a/drivers/nvme/common/keyring.c
> +++ b/drivers/nvme/common/keyring.c
> @@ -100,6 +100,7 @@ static struct key_type nvme_tls_psk_key_type = {
> .free_preparse = user_free_preparse,
> .match_preparse = nvme_tls_psk_match_preparse,
> .instantiate = generic_key_instantiate,
> + .update = user_update,
> .revoke = user_revoke,
> .destroy = user_destroy,
> .describe = nvme_tls_psk_describe,
[Severity: High]
Was .update added to nvme_tls_psk_key_type instead of
nvme_dhchap_psk_key_type? Because nvme_dhchap_psk_key_type still has no
.update callback, calling keyctl update on a dhchap key fails with
-EOPNOTSUPP.
> diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
> index 0ffea12fcfb6b..0eb68b3973a1e 100644
> --- a/drivers/nvme/host/sysfs.c
> +++ b/drivers/nvme/host/sysfs.c
> @@ -887,9 +887,17 @@ static ssize_t dhchap_secret_store(struct device *dev,
> kfree_sensitive(dhchap_secret);
> return ret;
> }
> + if (!generated &&
> + key_serial(old_key) != key_serial(key)) {
[Severity: Medium]
Should this check !ctrl->host_key_generated under ctrl->dhchap_auth_mutex
instead of !generated (and similarly !ctrl->ctrl_key_generated in
dhchap_ctrl_secret_store())?
nvme_auth_extract_key() sets generated based on whether the newly written
sysfs input is a raw DHHC-1 secret or an existing key lookup, not whether
the controller's current key was pre-populated. Writing a raw DHHC-1
secret sets generated = true, bypassing this check and overwriting a
pre-populated ctrl->host_key with a newly generated key, while writing a
pre-populated key identifier to a controller that currently uses a
generated key is rejected with -EPERM.
> + dev_warn(ctrl->device, "cannot change pre-populated key %08x\n",
> + key_serial(old_key));
> + key_put(key);
> + kfree_sensitive(dhchap_secret);
> + return -EPERM;
> + }
> mutex_lock(&ctrl->dhchap_auth_mutex);
> old_key = ctrl->host_key;
[Severity: High]
Does key_serial(old_key) dereference an uninitialized old_key pointer in
both dhchap_secret_store() and dhchap_ctrl_secret_store()?
old_key is declared on the stack without an initializer and is only
assigned from ctrl->host_key (or ctrl->ctrl_key) after acquiring
ctrl->dhchap_auth_mutex below. When writing a pre-populated key to sysfs
(generated == false), key_serial(old_key) reads old_key->serial from the
uninitialized pointer, or returns 0 when CONFIG_INIT_STACK_ALL_ZERO=y and
causes every re-authentication write to fail with -EPERM.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-dhchap-keyring-v4-v7-0-ee438ffea527@kernel.org?part=14
prev parent reply other threads:[~2026-11-26 14:32 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 14:12 [PATCH v7 00/14] nvme-auth: switch to use the kernel keyring Hannes Reinecke
2026-11-26 14:12 ` [PATCH v7 01/14] nvme-auth: modify nvme_auth_transform_key() to return status Hannes Reinecke
2026-11-26 14:12 ` [PATCH v7 02/14] nvme-keyring: add 'dhchap' key type Hannes Reinecke
2026-11-26 14:32 ` sashiko-bot
2026-11-26 14:12 ` [PATCH v7 03/14] nvme-keyring: drop nvme_tls_psk_revoked() Hannes Reinecke
2026-11-26 14:12 ` [PATCH v7 04/14] Documentation/security/keys: fixup function name Hannes Reinecke
2026-11-26 14:12 ` [PATCH v7 05/14] nvme-keyring: link addtional keyring into .nvme keyring Hannes Reinecke
2026-11-26 14:24 ` sashiko-bot
2026-11-26 14:12 ` [PATCH v7 06/14] nvme-auth: switch to use 'struct key' Hannes Reinecke
2026-11-26 14:33 ` sashiko-bot
2026-11-26 14:12 ` [PATCH v7 07/14] nvme: parse dhchap keys during option parsing Hannes Reinecke
2026-11-26 14:29 ` sashiko-bot
2026-11-26 14:12 ` [PATCH v7 08/14] nvmet-auth: parse dhchap key from configfs attribute Hannes Reinecke
2026-11-26 14:30 ` sashiko-bot
2026-11-26 14:12 ` [PATCH v7 09/14] nvme: allow to pass in key description as dhchap secret Hannes Reinecke
2026-11-26 14:27 ` sashiko-bot
2026-11-26 14:12 ` [PATCH v7 10/14] nvme-auth: allow to specify the key by key serial Hannes Reinecke
2026-11-26 14:26 ` sashiko-bot
2026-11-26 14:12 ` [PATCH v7 11/14] nvme-auth: wait for authentication to finish when changing keys Hannes Reinecke
2026-11-26 14:12 ` [PATCH v7 12/14] nvme-fabrics: allow to pass in keyring by name Hannes Reinecke
2026-11-26 14:31 ` sashiko-bot
2026-11-26 14:12 ` [PATCH v7 13/14] nvme-auth: link pre-provisioned keys into .nvme keyring Hannes Reinecke
2026-11-26 14:30 ` sashiko-bot
2026-11-26 14:12 ` [PATCH v7 14/14] nvme-auth: allow to update pre-provisioned keys Hannes Reinecke
2026-11-26 14:31 ` sashiko-bot [this message]
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-235712@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=axboe@kernel.dk \
--cc=corbet@lwn.net \
--cc=dhowells@redhat.com \
--cc=ebiggers@kernel.org \
--cc=gustavoars@kernel.org \
--cc=hare@kernel.org \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=jarkko@kernel.org \
--cc=kbusch@kernel.org \
--cc=kch@nvidia.com \
--cc=kees@kernel.org \
--cc=keyrings@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=martin.nvme.dev@gmail.com \
--cc=rdunlap@infradead.org \
--cc=sagi@grimberg.me \
--cc=sashiko-reviews@lists.linux.dev \
--cc=skhan@linuxfoundation.org \
/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