All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hannes Reinecke" <hare@kernel.org>
Cc: linux-nvme@lists.infradead.org
Subject: Re: [PATCH v6 4/9] nvme: parse dhchap keys during option parsing
Date: Mon, 23 Nov 2026 17:26:34 +0000	[thread overview]
Message-ID: <sashiko-outbox-229738@kernel.org> (raw)
In-Reply-To: <20261123-dhchap-keyring-v4-v6-4-5082a49715ab@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] nvme: dhchap_key_show() and dhchap_ctrl_key_show() return 0
  instead of none
- [Low] nvme-auth: log of unassigned ctrl->host_key in
  nvme_auth_init_ctrl()
--

commit bfaa9fb3c74e5de5eb5e03ecba9893bb438923f7
Author: Hannes Reinecke <hare@kernel.org>

nvme: parse dhchap keys during option parsing

This commit creates DH-HMAC-CHAP keys during fabric option parsing to store
struct key pointers instead of plain text secrets in nvmf_ctrl_options, and
adds dhchap_key and dhchap_ctrl_key sysfs attributes exposing their key
serial numbers.

> diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c
> index 0ddf3834f4ea2..26e8f321650e7 100644
> --- a/drivers/nvme/host/auth.c
> +++ b/drivers/nvme/host/auth.c
[ ... ]
> @@ -1029,40 +1024,100 @@ static void nvme_ctrl_auth_work(struct work_struct *work)
[ ... ]
> +	pr_debug("%s: using dhchap host key %08x\n",
> +	       __func__, key_serial(ctrl->host_key));
> +	if (ctrl->host_key)
> +		nvme_auth_clear_host_key(ctrl);
> +	ctrl->host_key = host_key;

[Severity: Low]
Should this pr_debug() pass key_serial(host_key) instead of
key_serial(ctrl->host_key)?  Because ctrl->host_key has not been assigned
yet, it logs 00000000 instead of the new key serial.

> diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
> index a5c1511e49ac2..6fab0d217e749 100644
> --- a/drivers/nvme/host/sysfs.c
> +++ b/drivers/nvme/host/sysfs.c
[ ... ]
> @@ -925,6 +985,52 @@ static ssize_t dhchap_ctrl_secret_store(struct device *dev,
>  
>  static DEVICE_ATTR_ADMIN_RW(dhchap_ctrl_secret);
> +
> +static ssize_t dhchap_key_show(struct device *dev,
> +		struct device_attribute *attr, char *buf)
> +{
> +	struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
> +	struct key *key;
> +	ssize_t count = 0;
> +
> +	mutex_lock(&ctrl->dhchap_auth_mutex);
> +	key = ctrl->host_key;
> +	if (key) {
> +		down_read(&key->sem);
> +		if (key_validate(key))
> +			count = sysfs_emit(buf, "<invalidated>\n");
> +		else
> +			count = sysfs_emit(buf, "%08x\n",
> +					   key_serial(key));
> +		up_read(&key->sem);
> +	}
> +	mutex_unlock(&ctrl->dhchap_auth_mutex);
> +	return count;
> +}
> +static DEVICE_ATTR_ADMIN_RO(dhchap_key);
> +
> +static ssize_t dhchap_ctrl_key_show(struct device *dev,
> +		struct device_attribute *attr, char *buf)
> +{
> +	struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
> +	struct key *key;
> +	ssize_t count = 0;
> +
> +	mutex_lock(&ctrl->dhchap_auth_mutex);
> +	key = ctrl->ctrl_key;
> +	if (key) {
> +		down_read(&key->sem);
> +		if (key_validate(key))
> +			count = sysfs_emit(buf, "<invalidated>\n");
> +		else
> +			count = sysfs_emit(buf, "%08x\n",
> +					   key_serial(key));
> +		up_read(&key->sem);
> +	}
> +	mutex_unlock(&ctrl->dhchap_auth_mutex);
> +	return count;
> +}
> +static DEVICE_ATTR_ADMIN_RO(dhchap_ctrl_key);

[Severity: Low]
Should dhchap_key_show() and dhchap_ctrl_key_show() emit "none\n" when key
is NULL?  The Documentation/ABI/stable/sysfs-nvme entry added in this patch
states that reading dhchap_key and dhchap_ctrl_key returns "none" if not
set, matching dhchap_secret_show() and dhchap_ctrl_secret_show(), but both
functions currently return 0 (empty output).

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-dhchap-keyring-v4-v6-0-5082a49715ab@kernel.org?part=4


  reply	other threads:[~2026-11-23 17:26 UTC|newest]

Thread overview: 32+ 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-24  7:39     ` Hannes Reinecke
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-24  7:43     ` Hannes Reinecke
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 [this message]
2026-11-24  7:51     ` Hannes Reinecke
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-24  7:55     ` Hannes Reinecke
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-24  8:31     ` Hannes Reinecke
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-24  9:21     ` Hannes Reinecke
2026-11-23 17:10 ` [PATCH v6 9/9] nvmet: add configfs attribute 'dhchap_keyring' Hannes Reinecke
2026-11-23 17:33   ` sashiko-bot
2026-11-23 21:21 ` [PATCH v6 0/9] nvme-auth: switch to use the kernel keyring Eric Biggers
2026-11-24 10:30   ` Hannes Reinecke
2026-11-24 20:11     ` Eric Biggers
2026-11-24 20:50       ` Martin Belanger
2026-11-24 21:32         ` Eric Biggers
2026-11-24 22:13           ` Martin Belanger
2026-11-25  7:26             ` Hannes Reinecke
2026-11-25 12:18               ` Martin Belanger
2026-11-25 15:43                 ` Hannes Reinecke

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-229738@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 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.