Re: [PATCH v6 0/9] nvme-auth: switch to use the kernel keyring

From: Eric Biggers

Date: Tue Nov 24 2026 - 16:32:31 EST


On Tue, Nov 24, 2026 at 03:50:14PM -0500, Martin Belanger wrote:
> On 11/24/26 15:11, Eric Biggers wrote:
> > Keys not being readable from userspace is one of the usual reasons
> > people think they want to use the keyrings. The cover letter should say
> > what this series is actually trying to accomplish. Currently, it only
> > mentions making it so that keys no longer need to be specified on the
> > command line. But when stated like that, it's a userspace issue: if the
> > nvme program doesn't accept keys on stdin like keyctl does, that's an
> > issue in the nvme program, not the kernel.
>
> The goal from the user side is that no DH-HMAC-CHAP secret appears on a
> command line, in a connect string or in a configuration file. These end
> up in shell scripts, config files and logs, where unprivileged users can
> read them. With the keyring, the configuration only names the key.
> nvme-keysd (in nvme-cli) imports the secrets into the keyring from
> systemd credentials or from a KMS, and the connection passes only the
> key description.

That is a userspace issue though, unless you also need the key to be
kept out of the /dev/nvme-fabrics connect string or sysfs/configfs show
output. Note that this patchset also keeps the keyring keys readable by
userspace still.

> > It sounds like the idea is that the kernel would look up the 'struct
> > key' by description again at runtime, such as on reset? But this series
> > doesn't actually do that. The lookup just happens once, when the option
> > or sysfs/configfs attribute is written to. The key is not updatable
> > either, so an external provider that rotates the key has to write to the
> > attribute. So there's no benefit to keeping the 'struct key' around
> > after that write.
>
> That is the part that does not work for a key provider. The secret
> behind a key description can change at any time, and the new secret
> must be used at the next authentication. This includes a controller
> that is in a reconnect loop, which can last for a long time.
>
> v6 looks up the key by description once, when the connect options are
> parsed, and keeps it in opts->dhchap_key for the lifetime of the
> controller. Every reconnect uses that same key. When nvme-keysd
> replaces the key with add_key(), the controller keeps the old secret.
> When the old key is revoked instead, the reconnect fails with -ENOKEY.
>
> The same happens when an admin changes the secret on the storage
> system. The host must use the new secret at the next reconnect,
> otherwise every reconnect fails until someone writes the new secret to
> the sysfs attribute or connects the controller again.
>
> Copying the secret into 'struct nvme_dhchap_key' once has the same
> problem. What the provider needs is a lookup by description at each
> authentication, the way NVMe/TCP TLS without a pinned key already
> works: nvme_tcp_alloc_admin_queue() calls nvme_tls_psk_default() at
> each reconnect. That lookup runs in a kernel worker, which has no
> process keyrings, so it also needs a fixed keyring: '.nvme', or the one
> given with the 'keyring' option.

Even if you actually need runtime key rotation without touching
configfs/sysfs (why, when nvme-keysd could just write those files
itself?), this series doesn't actually implement that.

- Eric