From: sashiko-bot@kernel.org
To: "Hannes Reinecke" <hare@kernel.org>
Cc: linux-nvme@lists.infradead.org
Subject: Re: [PATCH v6 9/9] nvmet: add configfs attribute 'dhchap_keyring'
Date: Mon, 23 Nov 2026 17:33:13 +0000 [thread overview]
Message-ID: <sashiko-outbox-229765@kernel.org> (raw)
In-Reply-To: <20261123-dhchap-keyring-v4-v6-9-5082a49715ab@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] nvmet: writing .nvme to nvmet_host_dhchap_keyring_store()
fails with -ENOKEY
--
commit 11d3b355e4b75a4b62f576abb3e457739f6b882d
Author: Hannes Reinecke <hare@kernel.org>
nvmet: add configfs attribute 'dhchap_keyring'
This commit adds a dhchap_keyring configfs attribute to the nvmet host
directory so userspace can configure the keyring used for DH-HMAC-CHAP key
lookups.
> diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
> index e19af764561ec..179f6bef77372 100644
> --- a/drivers/nvme/target/configfs.c
> +++ b/drivers/nvme/target/configfs.c
> @@ -2350,6 +2350,64 @@ static ssize_t nvmet_host_dhchap_ctrl_key_store(struct config_item *item,
>
> CONFIGFS_ATTR(nvmet_host_, dhchap_ctrl_key);
>
> +static ssize_t nvmet_host_dhchap_keyring_show(struct config_item *item,
> + char *page)
> +{
> + struct nvmet_host *host = to_host(item);
> + struct key *keyring;
> + ssize_t ret;
> +
> + down_read(&nvmet_config_sem);
> + keyring = key_get(host->dhchap_keyring);
> + if (!keyring) {
> + page[0] = '\0';
> + ret = 0;
> + } else {
> + down_read(&keyring->sem);
> + if (key_validate(keyring))
> + ret = sprintf(page, "<invalidated>\n");
> + else
> + ret = scnprintf(page, PAGE_SIZE,
> + "%s\n", keyring->description);
> + up_read(&keyring->sem);
> + key_put(keyring);
> + }
> + up_read(&nvmet_config_sem);
> + return ret;
> +}
> +
> +static ssize_t nvmet_host_dhchap_keyring_store(struct config_item *item,
> + const char *page, size_t count)
> +{
> + struct nvmet_host *host = to_host(item);
> + struct key *keyring;
> + char *desc = NULL;
> + size_t len;
> + int ret = 0;
> +
> + len = strcspn(page, "\n");
> + if (len) {
> + desc = kstrndup(page, len, GFP_KERNEL);
> + if (!desc)
> + return -ENOMEM;
> + keyring = request_key(&key_type_keyring, desc, NULL);
> + } else
> + keyring = key_lookup(nvme_keyring_id());
[Severity: Medium]
Does writing ".nvme" to dhchap_keyring fail with -ENOKEY?
nvmet_hosts_make_group() initializes host->dhchap_keyring via
key_lookup(nvme_keyring_id()), so nvmet_host_dhchap_keyring_show() outputs
".nvme" by default (making the !keyring branch in show unreachable).
However, nvme_keyring_init() allocates the ".nvme" keyring with dest set to
NULL, so it is not linked into the calling task's process keyrings.
When a tool such as nvmetcli saves and restores the configuration by
writing ".nvme" back to dhchap_keyring, len is non-zero and
nvmet_host_dhchap_keyring_store() calls request_key(), which searches only
the process keyrings and fails with -ENOKEY unless ".nvme" was manually
linked into them.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-dhchap-keyring-v4-v6-0-5082a49715ab@kernel.org?part=9
prev parent reply other threads:[~2026-11-23 17:33 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 17:10 [PATCH v6 0/9] nvme-auth: switch to use the kernel keyring Hannes Reinecke
2026-11-23 17:10 ` [PATCH v6 1/9] nvme-auth: modify nvme_auth_transform_key() to return status Hannes Reinecke
2026-11-23 17:10 ` [PATCH v6 2/9] nvme-keyring: add 'dhchap' key type Hannes Reinecke
2026-11-23 17:31 ` sashiko-bot
2026-11-23 17:10 ` [PATCH v6 3/9] nvme-auth: switch to use 'struct key' Hannes Reinecke
2026-11-23 17:32 ` sashiko-bot
2026-11-23 17:10 ` [PATCH v6 4/9] nvme: parse dhchap keys during option parsing Hannes Reinecke
2026-11-23 17:26 ` sashiko-bot
2026-11-23 17:10 ` [PATCH v6 5/9] nvmet-auth: parse dhchap key from configfs attribute Hannes Reinecke
2026-11-23 17:30 ` sashiko-bot
2026-11-23 17:10 ` [PATCH v6 6/9] nvme: allow to pass in key description as dhchap secret Hannes Reinecke
2026-11-23 17:32 ` sashiko-bot
2026-11-23 17:10 ` [PATCH v6 7/9] nvme-auth: wait for authentication to finish when changing keys Hannes Reinecke
2026-11-23 17:10 ` [PATCH v6 8/9] nvme-fabrics: allow to pass in keyring by name Hannes Reinecke
2026-11-23 17:30 ` sashiko-bot
2026-11-23 17:10 ` [PATCH v6 9/9] nvmet: add configfs attribute 'dhchap_keyring' Hannes Reinecke
2026-11-23 17:33 ` 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-229765@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=hare@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox