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 43493606A31C for ; Mon, 30 Nov 2026 13:01:30 +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=Gul+2X74; dkim=pass (2048-bit key, unprotected) header.d=stellman-greene-com.20260707.gappssmtp.com header.i=@stellman-greene-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=kwGYy3U3 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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=DfuqwSZ3ub8fZMQj8lkPjcIgewakLb+2pb2+0mcvGYo=; b=Gul+2X74XCItvF CUpQDz+TmGpbxZsGi851odO27HtIgwgX4+i2lBw1XbS0wtiHG+5W1TtitUSY7caMlz1MMTcW61fWH bj7tUw8tMMA3Pg03MSIjEzmL8KM2OmjJN+C7MkavH7T/T66KvdEA1Y4WQXxZhVXE9YhZpoU5C7Vvv w+Dot15FvzqT1EcNf3ml7LM7d6XG4OPJg0HaeTQ0CZPUalwjc4mMQSVv2kwF9BFqqgRuyPmRQSBQM y/dPnCpWnmzaX/PVUjZHn6tcwFU64G5v3plsUxOABvaWCeHKrS6Vb3RXHX+U7oIFVJNbINtu55dlL +PXnKCpqiDyiRtx56Pvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xY10Z-00000004bQG-1Ofs; Mon, 30 Nov 2026 13:01:27 +0000 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xY10G-00000004bN0-0RC6 for linux-nvme@lists.infradead.org; Mon, 30 Nov 2026 13:01:25 +0000 Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-4e4a4d77e5bso7090326b6e.0 for ; Mon, 30 Nov 2026 05:01:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stellman-greene-com.20260707.gappssmtp.com; s=20260707; t=1796043667; x=1796648467; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=DfuqwSZ3ub8fZMQj8lkPjcIgewakLb+2pb2+0mcvGYo=; b=kwGYy3U3NxsMpilPWXvcK+pMEvBuxO3nvf7/PIq460JFE2sN8YUvcsnP4/3uyNJG7W cDIOJ9WaFQM17u/TPvxDjfw7cpYB3+nLSra2BLs43wiJijJbi6cIyNLR30wuzxRavXnv glu1836PjyEhwxrFPziULSyHutKH8jbmUdLuExzD1+PlzpKZUFs9KRaOfIyiNp+8nQyG GZ77Lk4Anmi27IIDU9ypkzZ8583JSaZ+RZq1jUBZdbfA+BETN7RJHom9aX/6s5lucnGq ORMkBfLFilW0/fFxonSxg8sgUmRtSq36WyaMqBETDpweJqlfGhFv1vvB7joVRLSjn7Gs 255A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796043667; x=1796648467; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=DfuqwSZ3ub8fZMQj8lkP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Htb+lsqA3KoPogXjj4K1waY73Z q6tNVGzGwxq1qKz3ji+HnjxuOAVAY30M8t6R398cjNAlgm7vn4jJi7k4j7O+y2OhiXg+nJ+oD+8 OMS0PDojh+hncDynKzSZlOCCTwHrsHsIrx3eA7H7jCkStgN3VsaJVUrxiT+asiEZ0Fd6b2l287Y 9phT7lwoOubnV9qwxhGffgSLIxjv/HhFWT17ERfrQl8fORpUhpFfw/MJVkgGLtXPT66MaHsuP8t KrQ== X-Received: by 2002:a05:6808:16a4:b0:540:8ca:36e3 with SMTP id 5614622812f47-5797c1b5467mr24125167b6e.19.1796043664103; Mon, 30 Nov 2026 05:01:04 -0800 (PST) Received: from Mac.mynetworksettings.com ([2600:4041:5c28:200:c430:30ff:570a:a90e]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-921349f2186sm299551696d6.29.2026.11.30.05.01.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 30 Nov 2026 05:01:03 -0800 (PST) From: Andrew Stellman To: Hannes Reinecke , Keith Busch , Christoph Hellwig , Sagi Grimberg Cc: Jens Axboe , linux-nvme@lists.infradead.org Subject: [PATCH v2] nvme-auth: validate DH value length when reusing a group Date: Mon, 30 Nov 2026 08:01:02 -0500 Message-ID: <20261130130102.22839-1-bugs@stellman-greene.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261129135247.80697-1-bugs@stellman-greene.com> References: <20261129135247.80697-1-bugs@stellman-greene.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261130_050108_213344_5ED009E5 X-CRM114-Status: GOOD ( 19.44 ) 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=-21.9 required=3.0 tests=BAYES_00,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_GIT 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 From: Andrew Stellman 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 Signed-off-by: Andrew Stellman --- 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);