Re: [PATCH v7 09/14] nvme: allow to pass in key description as dhchap secret

From: Martin Belanger

Date: Tue Dec 01 2026 - 06:28:16 EST




On 12/1/26 05:21, Hannes Reinecke wrote:
> We have been there before with the TLS keys, and found that using
> serial numbers to identify keys is really a bad idea if you want
> to store it in a configuration file.

Agreed, and I did not mean that. A serial cannot go into a
configuration file. It changes each time a key is added to the
keyring. The configuration holds the key description.

> And there's an additional attribute dhchap_key and dhchap_ctrl_key
> which will display the key serial.

You are right, v7 already has them, and I missed them. libnvme can
use the presence of this attribute to detect keyring support. That
is all it needs. For everything else, the description that
dhchap_secret shows for a pre-provisioned key is enough, because
the kernel accepts it on connect.

On the names: I would still prefer kxchap_key and kxchap_ctrl_key.
These attributes are new ABI. Base 2.4 renamed DH-HMAC-CHAP to
KX-HMAC-CHAP because the key exchange is no longer only
Diffie-Hellman (ML-KEM). The same key is used with any of these
key exchanges. Also, nvmet configfs already has a dhchap_key
attribute, and there it holds the secret. A host attribute with
the same name that shows a serial would be confusing. The
existing attributes keep their names.

> To honour you original request of not allowing to rotate
> pre-provisioned keys we could return -EBUSY (-EINVAL?)
> when someone writes to dhchap_secret / dhchap_ctrl_secret
> of a pre-provisioned key, and allow writes to dhchap_key /
> dhchap_ctrl_key for pre-provisioned keys.

My request was a little different. A pre-provisioned key should be
rotated in the keyring: keyctl update changes the payload, the
serial stays the same, and the next authentication uses the new
key. I would like that to be the only way to change such a key.

So I would prefer kxchap_key and kxchap_ctrl_key to stay
read-only, as in v7. A write can be added later if someone needs
it. Once it is released, it cannot be removed.

Returning -EBUSY on a write to dhchap_secret for a pre-provisioned
key is fine with me. libnvme only reads that attribute.

Martin