[PATCH v2] nvme-auth: validate DH value length when reusing a group
Andrew Stellman
bugs at stellman-greene.com
Mon Nov 30 05:01:02 PST 2026
From: Andrew Stellman <astellman at stellman-greene.com>
When a DH-HMAC-CHAP challenge names the DH group that's already in use,
nvme_auth_process_dhchap_challenge() skips the DH value length checks.
A challenge with an empty DH value for a non-NULL group, or with a DH
value for the NULL group, then returns 0, even though the same
challenge for a new group is rejected.
Run the same two checks before reusing the group.
Found with Quality Playbook
(https://github.com/andrewstellman/quality-playbook).
Fixes: b61775d185a3 ("nvme-auth: Diffie-Hellman key exchange support")
Reviewed-by: Hannes Reinecke <hare at kernel.org>
Signed-off-by: Andrew Stellman <astellman at stellman-greene.com>
---
Christoph, I rewrote the commit log to be short, as you asked.
v1: https://lore.kernel.org/linux-nvme/20261129135247.80697-1-bugs@stellman-greene.com/
I tested this in an arm64 QEMU guest (full disclosure: I used OpenAI
Codex to do a lot of the tedious setup for me) with a test-only hook
that passes synthetic challenges to the function. Both malformed
challenges returned 0 without the patch and -EPROTO with it. That
reproducer is available on request.
I found this issue running Quality Playbook, an open-source code review
tool that I maintain, with Claude Opus 5.5, and confirmed it with
Claude Opus 4.8, OpenAI GPT-6 Sol and Claude Sonnet 5.5. The fix was
drafted with OpenAI GPT-6 (Codex). I reviewed everything, but I'm new
to this codebase, so I relied heavily on AI explanations of things.
Quality Playbook also found 37 other possible issues in
drivers/nvme/host that I haven't reviewed or reproduced yet. I only send
Linux bugs that I've reviewed and can actually reproduce, so I'll work
through them (at my slow human speed, not AI speed) and send the ones I
can verify. I'm happy to send you the list privately if it would help.
Andrew
drivers/nvme/host/auth.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c
index 9a3da74dec5aa..c45f88ca5db34 100644
--- a/drivers/nvme/host/auth.c
+++ b/drivers/nvme/host/auth.c
@@ -219,6 +219,19 @@ static int nvme_auth_process_dhchap_challenge(struct nvme_ctrl *ctrl,
if (chap->dhgroup_id == data->dhgid &&
(data->dhgid == NVME_AUTH_DHGROUP_NULL || chap->dh_tfm)) {
+ if (data->dhgid != NVME_AUTH_DHGROUP_NULL && !dhvlen) {
+ dev_warn(ctrl->device, "qid %d: empty DH value\n",
+ chap->qid);
+ chap->status = NVME_AUTH_DHCHAP_FAILURE_DHGROUP_UNUSABLE;
+ return -EPROTO;
+ }
+ if (data->dhgid == NVME_AUTH_DHGROUP_NULL && dhvlen) {
+ dev_warn(ctrl->device,
+ "qid %d: invalid DH value for NULL DH\n",
+ chap->qid);
+ chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD;
+ return -EPROTO;
+ }
dev_dbg(ctrl->device,
"qid %d: reuse existing DH group %s\n",
chap->qid, gid_name);
More information about the Linux-nvme
mailing list