Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Seong Hyeon <ihopenre@gmail.com>
To: linux-nvme@lists.infradead.org
Cc: hare@kernel.org, hch@lst.de, sagi@grimberg.me, kch@nvidia.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH RESEND 0/2] nvmet-auth: fix use-after-free and out-of-bounds read across queues
Date: Sat,  5 Dec 2026 07:48:14 +0700	[thread overview]
Message-ID: <20261205004816.2017-1-ihopenre@gmail.com> (raw)

Resending to linux-nvme as Christoph and Hannes asked. The first posting
went to the maintainers and security@kernel.org 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



             reply	other threads:[~2026-12-05  0:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  0:48 Lee Seong Hyeon [this message]
2026-12-05  0:48 ` [PATCH RESEND 1/2] nvmet-auth: serialize the controller authentication state Lee Seong Hyeon
2026-12-05  0:48 ` [PATCH RESEND 2/2] nvmet-auth: fail the transaction when the hash was changed Lee Seong Hyeon
2026-12-05  1:12   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261205004816.2017-1-ihopenre@gmail.com \
    --to=ihopenre@gmail.com \
    --cc=hare@kernel.org \
    --cc=hch@lst.de \
    --cc=kch@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox