[PATCH] nvme-auth: validate DH value length when reusing a group
Hannes Reinecke
hare at suse.de
Sun Nov 29 23:11:12 PST 2026
On 11/29/26 2:52 PM, Andrew Stellman wrote:
> From: Andrew Stellman <astellman at stellman-greene.com>
>
> When a DH-HMAC-CHAP challenge names the DH group already in use,
> nvme_auth_process_dhchap_challenge() jumps to skip_kpp before 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. The
> fresh-group path rejects both.
>
> Apply the same two checks, with the same error and status codes, on
> the reuse path before the jump. These challenges are now rejected with
> -EPROTO.
>
> Tested on mainline 7.4.0-rc4-g4f069ab1ec24 in an arm64 QEMU guest,
> using a test-only debugfs hook that calls the function with synthetic
> challenges: both malformed reuse cases returned 0 without the patch and
> -EPROTO with it, and the three control cases (an empty DH value for a
> fresh group, and valid challenges for a reused NULL and non-NULL group)
> gave the same results either way. Not tested over a live NVMe/TCP
> connection.
>
> The issue was found by Claude Opus 5.5, Claude Opus 4.8, OpenAI GPT-6
> Sol and Claude Sonnet 5.5 running Quality Playbook, an LLM-driven code
> review tool:
> https://github.com/andrewstellman/quality-playbook
> The fix was drafted with OpenAI GPT-6 (Codex) and this changelog with
> Claude Opus 5.5, and both were reviewed by me.
>
> Fixes: b61775d185a3 ("nvme-auth: Diffie-Hellman key exchange support")
> Signed-off-by: Andrew Stellman <astellman at stellman-greene.com>
> ---
> A reproducer is available on request.
>
> 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);
Reviewed-by: Hannes Reinecke <hare at kernel.org>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare at suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
More information about the Linux-nvme
mailing list