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
Subject: Re: [PATCH v7 10/14] nvme-auth: allow to specify the key by key serial
Date: Thu, 26 Nov 2026 14:26:03 +0000 [thread overview]
Message-ID: <sashiko-outbox-235696@kernel.org> (raw)
In-Reply-To: <20261126-dhchap-keyring-v4-v7-10-ee438ffea527@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] nvme-auth: missing key type validation in
nvme_auth_extract_key()
- [Low] nvme-auth: key_serial truncation to key_serial_t in
nvme_auth_extract_key()
--
commit 7d31006b6164c1d407e94a069e4daf6dec180cf1
Author: Hannes Reinecke <hare@kernel.org>
nvme-auth: allow to specify the key by key serial
This commit updates nvme_auth_extract_key() to parse a numeric key serial
and look up the key via key_lookup() before falling back to key description
lookup or key generation.
> diff --git a/drivers/nvme/common/auth.c b/drivers/nvme/common/auth.c
> index 15e72fe8868af..e336c698437dc 100644
> --- a/drivers/nvme/common/auth.c
> +++ b/drivers/nvme/common/auth.c
> @@ -148,7 +148,7 @@ EXPORT_SYMBOL_GPL(nvme_auth_hmac_hash_len);
> * @generated: indicate whether a key has been generated
> *
> * Extracts or generates a key from @input.
> - * @input can either be a key description or raw key data; in
> + * @input can be a key serial, a key description or raw key data; in
> * the latter case a key is generated from @input and
> * @generated is set to 'true'.
> *
> @@ -158,7 +158,18 @@ struct key *nvme_auth_extract_key(const char *input, size_t input_len,
> bool *generated)
> {
> struct key *key;
> -
> + unsigned long key_serial;
> + int err;
> +
> + /* Check if @input is a key serial */
> + err = kstrtoul(input, 0, &key_serial);
> + if (!err) {
> + key = key_lookup(key_serial);
[Severity: Low]
Can kstrtoul() silently truncate 64-bit values when key_serial is passed to
key_lookup()? key_serial_t is int32_t and valid serials are positive, so a
numeric string larger than INT_MAX on 64-bit platforms is narrowed to its
lower 32 bits instead of being rejected. Parsing with kstrtos32() and
checking key_serial > 0 would avoid this.
> + if (!IS_ERR(key)) {
> + *generated = false;
> + return key;
> + }
> + }
[Severity: High]
Can key_lookup() return a key that is not a positively instantiated
nvme_dhchap_psk_key_type key?
Unlike nvme_dhchap_psk_lookup(), key_lookup() searches the global serial
tree without checking key->type or instantiation state. When
nvme_auth_transform_key() later runs, it unconditionally calls user_read()
and nvme_dhchap_psk_hash(), which read key->payload.rcu_data0 as a struct
user_key_payload and access 6 bytes past upayload->datalen:
drivers/nvme/common/keyring.c:nvme_dhchap_psk_hash() {
...
upayload = user_key_payload_locked(key);
hmac = upayload->data[upayload->datalen + 5];
return hmac;
}
Passing the serial of an uninstantiated key, a keyring, or another key type
(such as user, logon, or NVMe TLS PSK, where user_preparse() only allocates
upayload->datalen bytes) causes a NULL pointer dereference, type confusion,
or a 6-byte slab out-of-bounds read.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-dhchap-keyring-v4-v7-0-ee438ffea527@kernel.org?part=10
next prev parent reply other threads:[~2026-11-26 14:26 UTC|newest]
Thread overview: 43+ 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 15:08 ` Hannes Reinecke
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 19:49 ` kernel test robot
2026-11-26 20:22 ` kernel test robot
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-27 7:23 ` Hannes Reinecke
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-27 7:32 ` Hannes Reinecke
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-27 7:34 ` Hannes Reinecke
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-27 7:40 ` Hannes Reinecke
2026-11-27 14:35 ` Martin Belanger
2026-12-01 10:21 ` Hannes Reinecke
2026-12-01 11:27 ` Martin Belanger
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 [this message]
2026-11-27 9:13 ` Hannes Reinecke
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-27 10:14 ` Hannes Reinecke
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 16:49 ` Martin Belanger
2026-11-27 9:39 ` Hannes Reinecke
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
2026-11-27 10:48 ` Hannes Reinecke
2026-11-26 21:15 ` kernel test robot
2026-11-26 16:00 ` [PATCH v7 00/14] nvme-auth: switch to use the kernel keyring Jarkko Sakkinen
2026-11-26 16:03 ` Jarkko Sakkinen
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-235696@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=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 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.