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

Hannes Reinecke hare at suse.de
Tue Dec 1 02:21:21 PST 2026


On 11/27/26 3:35 PM, Martin Belanger wrote:
> 
> 
> On 11/26/26 09:12, Hannes Reinecke wrote:
>> diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
> [ ... ]
>> -     }
>> +     } else
>> +             count = sysfs_emit(buf, "%s\n", key->description);
>>        up_read(&key->sem);
> 
> In my reply to the v6 cover letter (Nov 25), I asked that a read of
> dhchap_secret returns the key serial. I would like to change that
> request.
> 
> libnvme reads dhchap_secret and passes the value back on the next
> connect. A serial in dhchap_secret would change what existing user
> space gets from this attribute. Showing the description, as v7 does,
> is fine there: the kernel accepts it on connect.
> 
> Could v8 add the serial as separate, read-only attributes instead,
> kxchap_key_serial and kxchap_ctrl_key_serial ("%08x", like tls_key)?
> NVMe Base 2.4 renamed DH-HMAC-CHAP to KX-HMAC-CHAP, so new attributes
> could use the new name. libnvme can then use the serial, and it can
> tell from the presence of the attribute whether the kernel supports
> keyring keys. Today it cannot, because dhchap_secret= takes all forms.
> 

Grin.
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.

The plan is (and was, before someone asked me to change it :-)
to have the existing dhchap_ctrl_secret and dhchap_secret to
return either the encoded from (if it was auto-generated) or
the key description (if it was pre-provisioned).
And there's an additional attribute dhchap_key and dhchap_ctrl_key
which will display the key serial.

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.
That should cover everything I guess.

And, of course, naming can be changed.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare at suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich



More information about the Linux-nvme mailing list