kresults

← Back

nvme-auth: switch to use the kernel keyring

v7.4-rc1-102-gc1f00d7ebc22

Author
Hannes Reinecke <hare@kernel.org>
Date
Fri, 20 Nov 2026 11:13:59 +0000
Change-id
20261120-dhchap-keyring-v4-09f0bac1d8c5
Thread
20261120-dhchap-keyring-v4-v4-0-5f8c7d9926ee@kernel.org
Mailing lists
LKMLlinux-nvme
Ref
b4/20261120-dhchap-keyring-v4-v4-0-5f8c7d9926ee
Patches
9
Base
v7.4-rc1-93-g68099cf27253 68099cf27253
Report
report.txt
Producer
kdevops-ng 6716e3c, kdevops-ng 6c9113f, kdevops-ng 9e5246d, kdevops-ng b1987d2, kdevops-ng d21d96d

Cover letter

72 lines
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.

The entire patchset can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/hare/nvme.git
branch dhchap-keyring.v4

As usual, comments and reviews are welcome.

Changes to v3:
- Update to 7.4
- Add patch to set keyring for nvmet

Changes to v2:
- Update to v7.1
- Include reviews fromn Sagi
- Clarify decoded PSK length
- Add more function descriptions

Changes to the original submission:
- Dropped patches merged with upstream
- Modified the interface to refer to keys via the description
  and not the serial number

Signed-off-by: Hannes Reinecke <hare@kernel.org>
---
Hannes Reinecke (9):
      nvme-auth: modify nvme_auth_transform_key() to return status
      nvme-keyring: add 'dhchap' key type
      nvme-auth: switch to use 'struct key'
      nvme: parse dhchap keys during option parsing
      nvmet-auth: parse dhchap key from configfs attribute
      nvme: allow to pass in key description as dhchap secret
      nvme-auth: wait for authentication to finish when changing keys
      nvme-fabrics: allow to pass in keyring by name
      nvmet: add configfs attribute 'dhchap_keyring'

 drivers/nvme/common/Kconfig    |   1 +
 drivers/nvme/common/auth.c     | 213 ++++++++++++----------------
 drivers/nvme/common/keyring.c  | 314 +++++++++++++++++++++++++++++++++++++++++
 drivers/nvme/host/Kconfig      |   1 -
 drivers/nvme/host/auth.c       | 171 +++++++++++++++-------
 drivers/nvme/host/fabrics.c    | 121 +++++++++++-----
 drivers/nvme/host/fabrics.h    |  12 +-
 drivers/nvme/host/nvme.h       |   6 +-
 drivers/nvme/host/sysfs.c      | 212 +++++++++++++++++++++-------
 drivers/nvme/target/Kconfig    |   1 -
 drivers/nvme/target/auth.c     | 229 +++++++++++++++++++-----------
 drivers/nvme/target/configfs.c | 144 ++++++++++++++++---
 drivers/nvme/target/nvmet.h    |  16 +--
 include/linux/nvme-auth.h      |  11 +-
 include/linux/nvme-keyring.h   |  26 +++-
 15 files changed, 1092 insertions(+), 386 deletions(-)

Patches

PatchSubjectAuthorCommit
1/9nvme-auth: modify nvme_auth_transform_key() to return statusHannes Reinecke <hare@kernel.org>0eca1044b5ce
2/9nvme-keyring: add 'dhchap' key typeHannes Reinecke <hare@kernel.org>116fd5ce8dac
3/9nvme-auth: switch to use 'struct key'Hannes Reinecke <hare@kernel.org>2f3399626586
4/9nvme: parse dhchap keys during option parsingHannes Reinecke <hare@kernel.org>4fe287533f16
5/9nvmet-auth: parse dhchap key from configfs attributeHannes Reinecke <hare@kernel.org>2126979c85cf
6/9nvme: allow to pass in key description as dhchap secretHannes Reinecke <hare@kernel.org>fe4a46515454
7/9nvme-auth: wait for authentication to finish when changing keysHannes Reinecke <hare@kernel.org>edbcc6dc0d73
8/9nvme-fabrics: allow to pass in keyring by nameHannes Reinecke <hare@kernel.org>5ff6694c886c
9/9nvmet: add configfs attribute 'dhchap_keyring'Hannes Reinecke <hare@kernel.org>c1f00d7ebc22

Builds

ConfigurationArchCompilerFindingsRecordedProducer
no buildcheckpatch.pl 12026-11-21 18:53kdevops-ng b1987d2
blktests, block-layer, guest, nvm-express-driverx86_64gccmerge_config.sh ✓ make ✓ blktests 7 20 +23 −20 sparse 1 +1 smatch 1 +82026-11-23 13:41kdevops-ng 6716e3c, kdevops-ng 6c9113f, kdevops-ng 9e5246d, kdevops-ng b1987d2, kdevops-ng d21d96d

b4

What b4 printed applying the series: how it came to the base, and each base the series would not apply onto first.

Looking up 20261120-dhchap-keyring-v4-v4-0-5f8c7d9926ee@kernel.org
Checking for newer revisions
Grabbing search results from lore.kernel.org
Analyzing 31 messages in the thread
Looking for additional code-review trailers on lore.kernel.org
Analyzing 19 code-review messages
Checking attestation on all messages, may take a moment...
---
  ✗ [PATCH v4 1/9] nvme-auth: modify nvme_auth_transform_key() to return status
    + Link: https://patch.msgid.link/20261120-dhchap-keyring-v4-v4-1-5f8c7d9926ee@kernel.org
  ✗ [PATCH v4 2/9] nvme-keyring: add 'dhchap' key type
    + Link: https://patch.msgid.link/20261120-dhchap-keyring-v4-v4-2-5f8c7d9926ee@kernel.org
  ✗ [PATCH v4 3/9] nvme-auth: switch to use 'struct key'
    + Link: https://patch.msgid.link/20261120-dhchap-keyring-v4-v4-3-5f8c7d9926ee@kernel.org
  ✗ [PATCH v4 4/9] nvme: parse dhchap keys during option parsing
    + Link: https://patch.msgid.link/20261120-dhchap-keyring-v4-v4-4-5f8c7d9926ee@kernel.org
  ✗ [PATCH v4 5/9] nvmet-auth: parse dhchap key from configfs attribute
    + Link: https://patch.msgid.link/20261120-dhchap-keyring-v4-v4-5-5f8c7d9926ee@kernel.org
  ✗ [PATCH v4 6/9] nvme: allow to pass in key description as dhchap secret
    + Link: https://patch.msgid.link/20261120-dhchap-keyring-v4-v4-6-5f8c7d9926ee@kernel.org
  ✗ [PATCH v4 7/9] nvme-auth: wait for authentication to finish when changing keys
    + Link: https://patch.msgid.link/20261120-dhchap-keyring-v4-v4-7-5f8c7d9926ee@kernel.org
  ✗ [PATCH v4 8/9] nvme-fabrics: allow to pass in keyring by name
    + Link: https://patch.msgid.link/20261120-dhchap-keyring-v4-v4-8-5f8c7d9926ee@kernel.org
  ✗ [PATCH v4 9/9] nvmet: add configfs attribute 'dhchap_keyring'
    + Link: https://patch.msgid.link/20261120-dhchap-keyring-v4-v4-9-5f8c7d9926ee@kernel.org
  ---
  ✗ No key: ed25519/hare@kernel.org
  ✓ Signed: DKIM/kernel.org
---
Total patches: 9
---
 Base: 68099cf27253a8c89d703a282d3d811446d9453b (use --merge-base to override)
Magic: Preparing a sparse worktree
---
Applying: nvme-auth: modify nvme_auth_transform_key() to return status
Applying: nvme-keyring: add 'dhchap' key type
Applying: nvme-auth: switch to use 'struct key'
Applying: nvme: parse dhchap keys during option parsing
Applying: nvmet-auth: parse dhchap key from configfs attribute
Applying: nvme: allow to pass in key description as dhchap secret
Applying: nvme-auth: wait for authentication to finish when changing keys
Applying: nvme-fabrics: allow to pass in keyring by name
Applying: nvmet: add configfs attribute 'dhchap_keyring'
---
Fetching into FETCH_HEAD
You can now merge or checkout FETCH_HEAD
  e.g.: git merge --no-ff -F .git/b4-cover --no-edit FETCH_HEAD --signoff