From: Eric Biggers <ebiggers@kernel.org>
To: Hannes Reinecke <hare@kernel.org>
Cc: 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>,
linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
keyrings@vger.kernel.org
Subject: Re: [PATCH v6 0/9] nvme-auth: switch to use the kernel keyring
Date: Mon, 23 Nov 2026 21:21:05 +0000 [thread overview]
Message-ID: <20261123212105.GA18468@google.com> (raw)
In-Reply-To: <20261123-dhchap-keyring-v4-v6-0-5082a49715ab@kernel.org>
[ +Cc keyrings@vger.kernel.org ]
On Mon, Nov 23, 2026 at 06:10:00PM +0100, Hannes Reinecke wrote:
> Hey all,
>
> the current NVMe authentication code is using a hand-crafted key
> structure; idea was to have the initial implementation with a minimal
> set of dependencies.
> (And me not having a good grasp on how to use the kernel keyring :-)
> That had the drawback that keys always had to be specified on the
> nvme-cli commandline, which is far from ideal from a security standpoint.
>
> So this patchset switches the authentication code over to use the
> kernel keyring. User-facing interface (namely argument to 'nvme
> connect') remain the same, but the key data is converted into keys
> which are stored as a new key type 'dhchap' with a random UUID as
> description in the kernel keyring.
>
> With this I have updated the dhchap arguments to 'nvme connect' and
> the configfs interface to either be the keydata (ie the original
> interface) _or_ a key description referring to a pre-populated dhchap
> key in the kernel keyring. This allows for easier provisioning of keys
> and avoids the security risk from having to specify the key data on
> the kernel commandline.
[...]
> 16 files changed, 1140 insertions(+), 386 deletions(-)
This should have been Cc'ed to the keyrings mailing list. I found it
via lore search.
As far as I can tell, this series is trying to do two main things:
(1) parse secrets up front instead of keeping raw "DHHC-1:..."
strings around in 'opts' and 'nvmet_host'; and
(2) let userspace reference pre-loaded keys in a keyring so
cleartext secrets don't have to live in config files or
sysfs/configfs 'show' output.
(Patch 7's flush_work() change looks independent of the rest.)
Neither of those requires replacing 'struct nvme_dhchap_key' with
'struct key' at runtime, or synthesizing random-UUID keys in ".nvme"
when raw secrets are passed. Doing that adds a lot of complexity and
opportunity for bugs (as Sashiko's review already seems to show), for no
real gain. Note that 'user_key_payload' still lives in slab memory just
like 'struct nvme_dhchap_key' does.
The semantics of the keyrings subsystem just don't match storage very
well, and it's quite hard to integrate with correctly. In fscrypt, I
had to deal with a lot of bugs before moving away from the keyrings
subsystem almost entirely, due to issues with per-process keyring
scoping, delayed key destruction, locking, and LSM checks.
This series already runs into the first of these: patches 8-9 use
request_key(), which only searches the caller's process keyrings and
won't even find ".nvme". And keys are no longer wiped synchronously
with kfree_sensitive(), but rather whenever the last reference is
dropped and the garbage collector gets around to it.
Note that NVMe-TCP TLS isn't a relevant precedent here, either. TLS
handshakes run in userspace (tlshd), which needs to read the PSK via
keyctl, whereas DH-HMAC-CHAP is done entirely in-kernel.
This series also gives the 'dhchap' key type a ->read() method, so even
pre-populated keys remain readable from userspace via keyctl_read() (by
default, by any possessor).
And inserting raw secrets into ".nvme" with KEY_USR_READ makes them
readable via keyctl_read() by any process running as uid 0, even without
CAP_SYS_ADMIN and without access to sysfs or configfs. Due to the
KEY_USR_* permissions on ".nvme" and the keys, such processes can also
invalidate or revoke in-use keys, breaking authentication. (Separately,
the existing nvmet dhchap_key and dhchap_ctrl_key configfs attributes
are 0644 world-readable, which should be fixed regardless.)
How about keeping 'struct nvme_dhchap_key' as the runtime
representation, and just parsing into it up front in 'opts' and
'nvmet_host'? The sysfs/configfs 'show' methods could re-encode the
secret if really needed, though not exposing it at all would be better.
Then if keyring-based provisioning is still wanted so config files don't
need raw secrets, it could work like "fscrypt-provisioning" keys: define
a write-only key type (no ->read(), ->update(), or ->revoke()), look up
the key by serial number with lookup_user_key() once when the
option/attribute is written, copy the decoded key (and description, if
needed for 'show') into 'struct nvme_dhchap_key', and immediately
key_put() it.
Raw secrets wouldn't touch keyrings at all, and the keyrings subsystem
would stay out of the runtime path.
- Eric
prev parent reply other threads:[~2026-11-23 21:21 UTC|newest]
Thread overview: 11+ 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:10 ` [PATCH v6 3/9] nvme-auth: switch to use 'struct key' Hannes Reinecke
2026-11-23 17:10 ` [PATCH v6 4/9] nvme: parse dhchap keys during option parsing 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:10 ` [PATCH v6 6/9] nvme: allow to pass in key description as dhchap secret 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:10 ` [PATCH v6 9/9] nvmet: add configfs attribute 'dhchap_keyring' Hannes Reinecke
2026-11-23 21:21 ` Eric Biggers [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=20261123212105.GA18468@google.com \
--to=ebiggers@kernel.org \
--cc=axboe@kernel.dk \
--cc=hare@kernel.org \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=kch@nvidia.com \
--cc=keyrings@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/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