From: Sagi Grimberg <sagi@grimberg.me>
To: Hannes Reinecke <hare@kernel.org>, Christoph Hellwig <hch@lst.de>
Cc: Keith Busch <kbusch@kernel.org>, linux-nvme@lists.infradead.org
Subject: Re: [PATCH 6/9] nvme: allow to pass in key description as dhchap secret
Date: Mon, 1 Dec 2025 00:06:13 +0200 [thread overview]
Message-ID: <7567cbdc-440e-4e58-bb54-87879c004601@grimberg.me> (raw)
In-Reply-To: <20250528140517.3284-7-hare@kernel.org>
On 28/05/2025 17:05, Hannes Reinecke wrote:
> In order to use pre-populated keys update the parsing for
> DH-HMAC-CHAP secret to allow for a key description instead
> of an encoded binary secret.
Would it be possible to paste an example "dhchap_secret=%s"
for before and after?
>
> Signed-off-by: Hannes Reinecke <hare@kernel.org>
> ---
> drivers/nvme/common/auth.c | 15 ++++++---
> drivers/nvme/host/auth.c | 17 ++++++++--
> drivers/nvme/host/fabrics.c | 24 ++++++++++----
> drivers/nvme/host/fabrics.h | 4 +++
> drivers/nvme/host/nvme.h | 2 ++
> drivers/nvme/host/sysfs.c | 60 ++++++++++++++++++++++------------
> drivers/nvme/target/auth.c | 20 ++++++++++--
> drivers/nvme/target/configfs.c | 10 +++---
> drivers/nvme/target/nvmet.h | 2 ++
> include/linux/nvme-auth.h | 3 +-
> 10 files changed, 116 insertions(+), 41 deletions(-)
>
> diff --git a/drivers/nvme/common/auth.c b/drivers/nvme/common/auth.c
> index 8c2ccbfb9986..cbf35a7c3105 100644
> --- a/drivers/nvme/common/auth.c
> +++ b/drivers/nvme/common/auth.c
> @@ -156,14 +156,21 @@ size_t nvme_auth_hmac_hash_len(u8 hmac_id)
> EXPORT_SYMBOL_GPL(nvme_auth_hmac_hash_len);
>
> struct key *nvme_auth_extract_key(struct key *keyring, const u8 *secret,
> - size_t secret_len)
> + size_t secret_len, bool *generated)
> {
> struct key *key;
>
> + key = nvme_dhchap_psk_lookup(keyring, secret);
> + if (!IS_ERR(key)) {
> + *generated = false;
> + return key;
> + }
> key = nvme_dhchap_psk_refresh(keyring, secret, secret_len);
> - if (!IS_ERR(key))
> - pr_debug("generated dhchap key %08x\n",
> - key_serial(key));
> + if (!IS_ERR(key)) {
> + *generated = true;
Can you explain what exactly is being "generated" here?
Is this intermediate key you are generating is because the
user passed in a legacy dhchap_secret?
If this is the case, can we please wrap this call in something like:
nvme_auth_extract_key_legacy() and head it with some documentation?
also the patch description should discuss this. It is not easy to understand
from simply reading the code.
> + pr_debug("generated dhchap key %s\n",
> + key->description);
> + }
> return key;
> }
> EXPORT_SYMBOL_GPL(nvme_auth_extract_key);
> diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c
> index 0e8a5b544f63..0464e23b2a21 100644
> --- a/drivers/nvme/host/auth.c
> +++ b/drivers/nvme/host/auth.c
> @@ -1057,19 +1057,29 @@ static void nvme_ctrl_auth_work(struct work_struct *work)
> static void nvme_auth_clear_key(struct nvme_ctrl *ctrl, bool is_ctrl)
> {
> struct key *key;
> + bool generated;
>
> if (is_ctrl) {
> key = ctrl->ctrl_key;
> ctrl->ctrl_key = NULL;
> + generated = ctrl->ctrl_key_generated;
> + ctrl->ctrl_key_generated = false;
> } else {
> key = ctrl->host_key;
> ctrl->host_key = NULL;
> + generated = ctrl->host_key_generated;
> + ctrl->host_key_generated = false;
> }
> if (key) {
> - dev_dbg(ctrl->device, "%s: revoke%s key %08x\n",
> + if (generated) {
> + dev_dbg(ctrl->device, "%s: revoke%s key %08x\n",
> + __func__, is_ctrl ? " ctrl" : "",
> + key_serial(key));
> + key_revoke(key);
> + }
> + dev_dbg(ctrl->device, "%s: drop%s key %08x\n",
> __func__, is_ctrl ? " ctrl" : "",
> key_serial(key));
> - key_revoke(key);
> key_put(key);
> }
> }
> @@ -1099,6 +1109,7 @@ int nvme_auth_init_ctrl(struct nvme_ctrl *ctrl)
> key_serial(ctrl->opts->dhchap_key));
> return -ENOKEY;
> }
> + ctrl->host_key_generated = ctrl->opts->dhchap_key_generated;
Why do we have this in both ctrl and opts? this is very very confusing.
I think I mentioned this before, I really don't think that we should
be adding state to opts.
opts is intended to store user opts and state should remain under ctrl.
next prev parent reply other threads:[~2025-11-30 22:06 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-28 14:05 [PATCHv2 0/9] nvme-auth: switch to use the kernel keyring Hannes Reinecke
2025-05-28 14:05 ` [PATCH 1/9] nvme-auth: modify nvme_auth_transform_key() to return status Hannes Reinecke
2025-11-26 7:39 ` Sagi Grimberg
2025-11-27 8:01 ` Hannes Reinecke
2025-11-30 21:42 ` Sagi Grimberg
2025-12-01 8:49 ` Hannes Reinecke
2025-05-28 14:05 ` [PATCH 2/9] nvme-keyring: add 'dhchap' key type Hannes Reinecke
2025-06-03 0:32 ` Shinichiro Kawasaki
2025-06-03 6:11 ` Hannes Reinecke
2025-11-26 7:46 ` Sagi Grimberg
2025-11-27 8:06 ` Hannes Reinecke
2025-05-28 14:05 ` [PATCH 3/9] nvme-auth: switch to use 'struct key' Hannes Reinecke
2025-11-26 7:53 ` Sagi Grimberg
2025-11-27 8:15 ` Hannes Reinecke
2025-11-30 21:44 ` Sagi Grimberg
2025-12-01 8:50 ` Hannes Reinecke
2025-05-28 14:05 ` [PATCH 4/9] nvme: parse dhchap keys during option parsing Hannes Reinecke
2025-11-26 9:04 ` Sagi Grimberg
2025-05-28 14:05 ` [PATCH 5/9] nvmet-auth: parse dhchap key from configfs attribute Hannes Reinecke
2025-11-30 21:53 ` Sagi Grimberg
2025-12-01 9:02 ` Hannes Reinecke
2025-05-28 14:05 ` [PATCH 6/9] nvme: allow to pass in key description as dhchap secret Hannes Reinecke
2025-11-30 22:06 ` Sagi Grimberg [this message]
2025-05-28 14:05 ` [PATCH 7/9] nvme-auth: wait for authentication to finish when changing keys Hannes Reinecke
2025-11-30 22:08 ` Sagi Grimberg
2025-05-28 14:05 ` [PATCH 8/9] nvme-fabrics: allow to pass in keyring by name Hannes Reinecke
2025-11-30 22:11 ` Sagi Grimberg
2025-05-28 14:05 ` [PATCH 9/9] nvmet: add configfs attribute 'dhchap_keyring' Hannes Reinecke
2025-11-30 22:14 ` Sagi Grimberg
2025-07-03 9:39 ` [PATCHv2 0/9] nvme-auth: switch to use the kernel keyring Christoph Hellwig
2025-07-03 9:43 ` Hannes Reinecke
2025-11-30 22:15 ` Sagi Grimberg
2025-09-30 12:27 ` Keith Busch
2025-12-01 17:02 ` Keith Busch
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=7567cbdc-440e-4e58-bb54-87879c004601@grimberg.me \
--to=sagi@grimberg.me \
--cc=hare@kernel.org \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.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