Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10B1F606A32E for ; Mon, 30 Nov 2026 08:49:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=FsCFfDHA DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=ndYWpn2Zojmo1MHykR/qKhj00ykrCEZ/bjKfb5+Y7mI=; b=FsCFfDHAecxv7LwqUHFq13KR0N 1eXuAdfwCpM6CTE6SUp52yzAQZD8co0r7NqndT4yrQ/b7TY+vui/jkuRHMTODUcaloyF0uz23B3Zl RGL5wgSG9wX6U5YdKo4yXLQfVHX0xuGr/YeOvz25hCAXlrfe+KNQkXuQuVZjMTNr6/uvX6L0kMb9p jFtQaB71XGVVgywU4D1imzQ+4/2oWX7IPm7BOtZ2BzS/04785AhEVHppu52AfXFrFF6y4iWCu5o7X OzvseMNXlLlFxZX/r5uqgVuKBVhjHXaaab615K9vLBGjsoyGXgSud4bc+IqHmZ9geqEy06btSL3cz ELDq9oRA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXx4a-00000003pHu-0W1B; Mon, 30 Nov 2026 08:49:20 +0000 Received: from verein.lst.de ([213.95.11.211]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXx4U-00000003pDX-0PQI for linux-nvme@lists.infradead.org; Mon, 30 Nov 2026 08:49:15 +0000 Received: by verein.lst.de (Postfix, from userid 2407) id 92DA868C4E; Mon, 30 Nov 2026 09:49:10 +0100 (CET) Date: Mon, 30 Nov 2026 09:49:10 +0100 From: Christoph Hellwig To: Andrew Stellman Cc: Hannes Reinecke , Keith Busch , Christoph Hellwig , Sagi Grimberg , Jens Axboe , linux-nvme@lists.infradead.org Subject: Re: [PATCH] nvme-auth: validate DH value length when reusing a group Message-ID: <20261130084910.GB11248@lst.de> References: <20261129135247.80697-1-bugs@stellman-greene.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261129135247.80697-1-bugs@stellman-greene.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261130_004914_284743_017BBE20 X-CRM114-Status: GOOD ( 27.63 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" X-Spam-Status: No, score=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Please write a sensible and short commit log yourself. Thank you. On Sun, Nov 29, 2026 at 08:52:47AM -0500, Andrew Stellman wrote: > From: Andrew Stellman > > 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 > --- > 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); ---end quoted text---