[PATCH v2 0/5] nvme: target and host fixes from a drivers/nvme audit

Guixin Liu kanie at linux.alibaba.com
Wed Dec 2 03:58:51 PST 2026


A static audit of drivers/nvme turned up these independent bugs. Each
patch has its own reproducer and regression run, described in the notes
below its diff.

  nvme: mask the status before checking for Host Identifier Inconsistent
    The EDS->legacy reservation report fallback never triggers when the
    controller sets DNR.

  nvmet: read CRTO from the capability register
    The CRTO property is extracted from CSTS and always reads zero.

  nvmet: complete the passthru request after applying command effects
    nvme_passthru_end() reads req->cmd after the loop host request has
    been freed.

  nvmet-auth: reject negotiation when the configured DH group is not
    offered
    DH group negotiation advertises a group the host did not offer.

  nvmet-auth: require a DH value when a DH group was negotiated
    A reply with dhvlen == 0 bypasses the negotiated DH key exchange.

Testing: QEMU/KVM guest, 7.3.0 kernel with KASAN, nvmet-tcp, nvme-loop
and nvmet passthru to a QEMU nvme backend. Each fix was reproduced on
the unpatched code, verified with the same recipe after patching, and
regression-tested with the test-only injections removed. The
passthru use-after-free is evidenced by free/read address tracking; the
test kernel's module-side KASAN does not splat on that access, as noted
in patch 3. The test-only injections live in the test environment only,
not in these patches.

---
Changes since v1:
- passthru: apply the command effects before completing the target
  request instead of snapshotting req->cmd, which also keeps the
  passthru reference alive across nvme_passthru_end() (Sashiko).
- auth negotiation: drop the fallback to another offered group; it
  races on the controller-wide DH context across queues and downgrades
  to NULL DH. Require the configured group to be offered instead
  (Sashiko).
- Add a fix for a pre-existing DH exchange bypass: a reply with
  dhvlen == 0 was accepted even when a non-null DH group was negotiated
  (Sashiko).

v1: https://lore.kernel.org/all/20261202034707.3844378-1-kanie@linux.alibaba.com/

Guixin Liu (5):
  nvme: mask the status before checking for Host Identifier Inconsistent
  nvmet: read CRTO from the capability register
  nvmet: complete the passthru request after applying command effects
  nvmet-auth: reject negotiation when the configured DH group is not
    offered
  nvmet-auth: require a DH value when a DH group was negotiated

 drivers/nvme/host/pr.c                 |  2 +-
 drivers/nvme/target/fabrics-cmd-auth.c | 32 ++++++++------------------
 drivers/nvme/target/fabrics-cmd.c      |  2 +-
 drivers/nvme/target/passthru.c         | 10 +++++++-
 4 files changed, 20 insertions(+), 26 deletions(-)

-- 
2.43.7




More information about the Linux-nvme mailing list