[PATCH RESEND 0/2] nvmet-auth: fix use-after-free and out-of-bounds read across queues
From: Lee Seong Hyeon
Date: Fri Dec 04 2026 - 19:49:06 EST
Resending to linux-nvme as Christoph and Hannes asked. The first posting
went to the maintainers and security@xxxxxxxxxx only. The only change is
the Reviewed-by from Hannes on both patches, and the rebase onto
007722b8211f, where they apply without changes.
The DH-HMAC-CHAP keys and the negotiated hash live in struct nvmet_ctrl
and are shared by all queues, but each queue processes AUTH_Send and
AUTH_Receive on its own and sq->auth_lock is per queue.
1. AUTH_Negotiate on one queue frees ctrl->host_key in nvmet_setup_auth()
while a Reply on another queue uses it (KASAN use-after-free read).
2. AUTH_Negotiate on any queue can change ctrl->shash_id. A queue that got
its challenge for SHA-256 and replies with hl=64 after another queue
negotiated SHA-512 makes nvmet_auth_host_hash() read 64 bytes from the
32 byte sq->dhchap_c1 (KASAN slab-out-of-bounds read).
Conditions: CONFIG_NVME_TARGET_AUTH and a subsystem exported to a host
that has a dhchap_key set. A Connect for an I/O queue is accepted while
the admin queue is unauthenticated, and both queues accept authentication
commands. (1) is a race between two connections, (2) is deterministic.
Tested in QEMU with KASAN over nvmet-tcp, on 20eef29b7c84 and again on
007722b8211f. Unpatched: both reports. Both patches: neither shows in a
20 second race run. With both patches the in-kernel nvme-tcp host still
connects with dhchap_secret (SHA-256, NULL DH group), with and without
dhchap_ctrl_secret, and reads and writes the namespace; a wrong secret is
still rejected. W=1 and checkpatch --strict are clean.
Not tested: lockdep (patch 1 adds a mutex nested inside sq->auth_lock;
the lock order was checked by reading only), DH groups other than NULL,
TLS, RDMA, FC and loop transports.
Both patches were found and drafted with the help of an AI coding
assistant; this is stated in each commit message.
Lee Seong Hyeon (2):
nvmet-auth: serialize the controller authentication state
nvmet-auth: fail the transaction when the hash was changed
drivers/nvme/target/auth.c | 2 ++
drivers/nvme/target/core.c | 3 +++
drivers/nvme/target/fabrics-cmd-auth.c | 31 ++++++++++++++++++++++++++
drivers/nvme/target/nvmet.h | 3 +++
4 files changed, 39 insertions(+)
base-commit: 007722b8211f7b34fdf21b1e6a9c32497633ea29
--
2.53.0