From nobody Thu Jan 1 12:25:31 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3147FC004C0 for ; Mon, 23 Oct 2023 14:00:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231265AbjJWOAd (ORCPT ); Mon, 23 Oct 2023 10:00:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231277AbjJWOAV (ORCPT ); Mon, 23 Oct 2023 10:00:21 -0400 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D5DFD78 for ; Mon, 23 Oct 2023 07:00:18 -0700 (PDT) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id CCC40240104 for ; Mon, 23 Oct 2023 16:00:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1698069616; bh=0vrbnyHS0xkur/iRrIzIOiA16As3+vBu5X3xM21fRts=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version: Content-Transfer-Encoding:From; b=Jp4DwJ0n/3HJyx1M1Cy4sqSqnwAeHCRGXdighjLLYWiMVt2CW01aYRTixUJYKY85s beLaZwHZRUJmncMUIpKY527kFUCsBa3Zg1dmjMHrLYzUnLd+wh0peRc13tTrbmRomV 1iacZUce7jT2Bmjq7JDv+H+578cTqy9SWs2FIT7V9+KK3DGX9BAITFsmK2hxr9xrXL 5zP6GFxRgdUmvlKoS+y9aee8pDZ9Nz4ySMvWKKN4ELGwQhZ0jvnL+M/cpHADRboeTM PJ5KbxdUHz4xJ0ugSYeds2sycm84Y11kcs3SDij0gIt/d10JgRH71Yz2bQfW4vxMhl 46Mr0pEXMJHAw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4SDcJv279xz6txG; Mon, 23 Oct 2023 16:00:15 +0200 (CEST) From: Mark O'Donovan To: linux-kernel@vger.kernel.org Cc: linux-nvme@lists.infradead.org, sagi@grimberg.me, hch@lst.de, axboe@kernel.dk, kbusch@kernel.org, hare@suse.de, Mark O'Donovan Subject: [PATCH v2 2/3] nvme-auth: add flag for bi-directional auth Date: Mon, 23 Oct 2023 14:00:02 +0000 Message-Id: <20231023140003.58019-3-shiftee@posteo.net> In-Reply-To: <20231023140003.58019-1-shiftee@posteo.net> References: <20231023140003.58019-1-shiftee@posteo.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Introduces an explicit variable for bi-directional auth. The currently used variable chap->s2 is incorrectly zeroed for uni-directional auth. That will be fixed in the next patch so this needs to change to avoid sending unexpected success2 messages Signed-off-by: Mark O'Donovan Reviewed-by: Christoph Hellwig --- drivers/nvme/host/auth.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c index e0fc33d41baa..8558a02865ac 100644 --- a/drivers/nvme/host/auth.c +++ b/drivers/nvme/host/auth.c @@ -28,6 +28,7 @@ struct nvme_dhchap_queue_context { int error; u32 s1; u32 s2; + bool bi_directional; u16 transaction; u8 status; u8 dhgroup_id; @@ -312,6 +313,7 @@ static int nvme_auth_set_dhchap_reply_data(struct nvme_= ctrl *ctrl, data->dhvlen =3D cpu_to_le16(chap->host_key_len); memcpy(data->rval, chap->response, chap->hash_len); if (ctrl->ctrl_key) { + chap->bi_directional =3D true; get_random_bytes(chap->c2, chap->hash_len); data->cvalid =3D 1; chap->s2 =3D nvme_auth_get_seqnum(); @@ -660,6 +662,7 @@ static void nvme_auth_reset_dhchap(struct nvme_dhchap_q= ueue_context *chap) chap->error =3D 0; chap->s1 =3D 0; chap->s2 =3D 0; + chap->bi_directional =3D false; chap->transaction =3D 0; memset(chap->c1, 0, sizeof(chap->c1)); memset(chap->c2, 0, sizeof(chap->c2)); @@ -822,7 +825,7 @@ static void nvme_queue_auth_work(struct work_struct *wo= rk) goto fail2; } =20 - if (chap->s2) { + if (chap->bi_directional) { /* DH-HMAC-CHAP Step 5: send success2 */ dev_dbg(ctrl->device, "%s: qid %d send success2\n", __func__, chap->qid); --=20 2.39.2