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 06/14] nvme-auth: switch to use 'struct key'
Date: Thu, 26 Nov 2026 14:33:18 +0000 [thread overview]
Message-ID: <sashiko-outbox-235725@kernel.org> (raw)
In-Reply-To: <20261126-dhchap-keyring-v4-v7-6-ee438ffea527@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] nvme-keyring: nvme_dhchap_psk_create() overwrites
key_create() error codes
--
commit d2027ac3b70964c8a70b1644b2224565f8d1e622
Author: Hannes Reinecke <hare@kernel.org>
nvme-auth: switch to use 'struct key'
This commit replaces struct nvme_dhchap_key with the kernel keyring's
struct key using the "dhchap" key type for storing and transforming
DH-HMAC-CHAP keys.
> diff --git a/drivers/nvme/common/keyring.c b/drivers/nvme/common/keyring.c
> index 0fc6b4825c2dd..dc0a4fb9296f1 100644
> --- a/drivers/nvme/common/keyring.c
> +++ b/drivers/nvme/common/keyring.c
> @@ -464,6 +464,91 @@ static struct key_type nvme_dhchap_psk_key_type = {
> .read = nvme_dhchap_psk_read,
> };
>
> +/**
> + * nvme_dhchap_psk_create - Create DH-HMAC-CHAP key
> + * @data: Key data
> + * @data_len: Length of @data
> + *
> + * Creates a new DH-HMAC-CHAP key with a random UUID as the key identity.
> + * Returns the new key or an error pointer on failure.
> + */
> +struct key *nvme_dhchap_psk_create(const char *data, size_t data_len)
> +{
> + key_perm_t keyperm =
> + KEY_POS_SEARCH | KEY_POS_VIEW | KEY_POS_READ |
> + KEY_POS_WRITE | KEY_POS_LINK | KEY_POS_SETATTR |
> + KEY_USR_SEARCH | KEY_USR_VIEW | KEY_USR_READ;
> + char *identity;
> + key_ref_t keyref;
> + struct key *key;
> + uuid_t key_uuid;
> +
> + if (data == NULL || !data_len)
> + return ERR_PTR(-EINVAL);
> +
> + generate_random_uuid(key_uuid.b);
> + identity = kasprintf(GFP_KERNEL, "%pU", &key_uuid);
> + if (!identity)
> + return ERR_PTR(-ENOMEM);
> +
> + pr_debug("generate dhchap psk '%s'\n", identity);
> + keyref = key_create(make_key_ref(nvme_keyring, true),
> + "dhchap", identity, data, data_len,
> + keyperm, KEY_ALLOC_NOT_IN_QUOTA |
> + KEY_ALLOC_BUILT_IN |
> + KEY_ALLOC_BYPASS_RESTRICTION);
> + if (IS_ERR(keyref)) {
> + pr_warn("refresh dhchap psk '%s' failed, error %ld\n",
> + identity, PTR_ERR(keyref));
> + kfree(identity);
> + return ERR_PTR(-ENOKEY);
> + }
[Severity: Medium]
Should this return ERR_CAST(keyref) instead of ERR_PTR(-ENOKEY)?
When key_create() fails in nvme_dhchap_psk_preparse(), such as returning
-EINVAL for a malformed secret or -EKEYREJECTED for a CRC mismatch,
discarding PTR_ERR(keyref) causes nvme_auth_extract_key() callers like
dhchap_secret_store() to report -ENOKEY to userspace instead of the
underlying error code.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-dhchap-keyring-v4-v7-0-ee438ffea527@kernel.org?part=6
next prev parent reply other threads:[~2026-11-26 14:33 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 [this message]
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
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-235725@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.