Public bug reported:

Ubuntu 26.04 ships `ktls-utils 1.3.0-2`. After rotating the TLS PSK for
an NVMe/TCP connection, `tlshd` continues to use the previous PSK from
its long-lived session keyring. The kernel `.nvme` keyring already
contains the new key, but the next `nvme connect --tls` handshake fails
until the stale session key is removed; restarting the service is not a
reliable workaround.

Upstream fixed this in `ktls-utils 1.5.0` with commit `3a6658e` ("tlshd:
Link the NFS keyrings per handshake instead of at startup"). The same
commit changes the server PSK lookup to search the process keyring
first, which is the part that affects NVMe/TCP. `1.4.0` and `1.3.0`
search only the session keyring; `1.5.0` is the first release with the
process-keyring-first lookup. Please update `resolute` to 1.5.0, or
backport the keyring lookup fix.

## Environment

- Ubuntu 26.04 LTS (`resolute`), kernel `7.0.0-43-generic`
- `dpkg -l ktls-utils`: `ii  ktls-utils  1.3.0-2  amd64  TLS handshake support 
for NFS and other in-kernel TLS users`
- `/usr/sbin/tlshd --version`: `tlshd, built from ktls-utils 1.3.0 on Dec  5 
2025 01:01:23`
- Client tools: `nvme 2.16`, `keyutils 1.6.3`
- Target: NVMe/TCP with TLS 1.3, PSK authentication
- Kernel TLS handshake support enabled (`CONFIG_NVME_TCP_TLS=y`)

## Steps to reproduce

1. Configure an NVMe/TCP target with TLS 1.3 and a PSK.
2. Import the initial PSK into the client kernel `.nvme` keyring and connect 
with `nvme connect --tls`.
3. Confirm that the connection and handshake succeed.
4. Rotate the PSK on the target and replace the key in the client `.nvme` 
keyring. The key serial changes.
5. Disconnect and immediately reconnect with `nvme connect --tls` against the 
same target.
6. Observe the handshake result and the keyring lookup.

A trace of `tlshd` during step 5:

```text
keyctl_keyring_search(keyring=0xfffffffd /* session */, type="psk",
                      desc="NVMe0R01 <hostnqn> <subsysnqn>")
```

The search returns the previous key serial. At the same time, the
`.nvme` keyring contains the new serial.

## Expected

The new PSK in `.nvme` is used for the next handshake. Reconnecting
immediately after rotation succeeds.

## Actual

The handshake fails while the stale key remains in the session keyring.
Restarting `tlshd` is not reliable because the session keyring can
outlive the service process. This can leave a credential-rotation window
in which the target and client disagree.

Relevant kernel message:

```text
nvme nvmeX: queue 0: TLS handshake failed, error -<errno>
```

## Root cause

The kernel handshake upcall links the keyring named by the request (for
NVMe, `.nvme`) into the process keyring of the handshake child that
accepts the request.

`ktls-utils 1.3.0` `tlshd_server_psk_cb()` searches only
`KEY_SPEC_SESSION_KEYRING`. The long-lived `tlshd` parent keeps the
previous PSK in its session keyring, so a stale entry is found before
the new key in `.nvme`.

`ktls-utils 1.5.0` contains commit
`3a6658e2b99d8f20eeae160da5b4136961ec4a10`, which links the NFS keyrings
per handshake and searches the process keyring first. The `.nvme`
keyring keeps its startup link, but the process-keyring search is what
lets the per-handshake key win over the stale session entry. The private
process keyring is released when the handshake child exits, so a
previous PSK cannot survive into later handshakes.

## Request

Please update `ktls-utils` in `resolute` to 1.5.0. If a full version
update is not suitable for a stable series, a minimal backport of
`3a6658e` is acceptable; the change is limited to keyring linking and
PSK lookup order in `tlshd`.

The same stale-key behavior is present in `1.4.0` and `1.3.0`; this
report is scoped to the version shipped in 26.04.

## References

- Upstream repository: https://github.com/linux-nfs/ktls-utils
- Upstream release: 
https://github.com/linux-nfs/ktls-utils/releases/tag/ktls-utils-1.5.0
- Upstream fix: 
https://github.com/linux-nfs/ktls-utils/commit/3a6658e2b99d8f20eeae160da5b4136961ec4a10
- Ubuntu package: https://packages.ubuntu.com/resolute/ktls-utils

** Affects: ktls-utils (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2178406

Title:
  ktls-utils 1.3.0: stale PSK is used after NVMe/TCP TLS credential
  rotation

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ktls-utils/+bug/2178406/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to