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

From: Martin Belanger

Date: Mon Nov 23 2026 - 10:32:24 EST




On 11/23/26 07:59, Martin Belanger wrote:
> How should nvme-cli determine whether the kernel accepts a key
> description for DH-HMAC-CHAP?
[...]
> 2. Use a separate option for the key description, for example
> dhchap_key=%s and dhchap_ctrl_key=%s. nvme-cli would then detect
> support through /dev/nvme-fabrics, as it does for the other
> options. It also avoids having one string that can mean either a
> description or key data.

Hi Hannes,

A follow-up with test results. I added DH-HMAC-CHAP support to
nvme-keysd and tested it with v5 in a VM, with nvmet over TCP and keys
in both directions. Import, connect by key description, a wrong key,
and a key replacement all work.

For detection, nvme-keysd now uses add_key(): it fails with ENODEV
when the 'dhchap' key type does not exist. On an older kernel, the
connect fails with "Invalid DH-CHAP secret <name>", which is clear
enough. So nvme-cli does not need a new option for this. A separate
option would still avoid the ambiguity between a description and key
data, but that is your decision.

One finding: add_key() with the exact secret length, without a
trailing NUL, fails at random with EPERM. nvme_dhchap_psk_preparse()
treats the payload as a C string and reads past it (the bug Sashiko
reported), and base64_decode() returns -1. User space passes the
length without a NUL, keyctl(1) too. Could v6 parse exactly
prep->datalen bytes? For now nvme-keysd passes the NUL.

Martin