Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1242616rda; Mon, 23 Oct 2023 07:00:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/Yf6X5mOAz25MQYXnpLg0CPpK9duge2en9bWmZEmGFn3819gn4Mkp6O+Y4PN2DMOmFhWf X-Received: by 2002:a05:6a20:4c82:b0:15b:c800:48af with SMTP id fq2-20020a056a204c8200b0015bc80048afmr6634835pzb.23.1698069658841; Mon, 23 Oct 2023 07:00:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698069658; cv=none; d=google.com; s=arc-20160816; b=TYeUtimzX6Q9g63n4MMb87VLR2uhr3E+nAPlySwRw3BxuHx1NRZN3NyKGK+42x7QsD hKHBYLJ01ttRd47vSKqUZwuSD9GQKrcAm6D/nWWDVnWiNr3dSVQv8+dtZO3jKtyitfsh qaWCKMMg8sIN6FE9200E7qJrwDlxRA0GKSqjz67+VTPhoAj5iwzlbh211PeSJFxtn6Ga KE4n1sh3Dtx2PEplE5xF9bxgt91ddwP8Vb/pJX2vZmGGGbz7GlrCMkH847grlLvhNMZv 82KN++JBLVjymUHzp5m7On4qCE+EIod4PrOQBrCZkudTfea8g2iONvs3RvEkadACExfh 6USA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XqA07HvUvcOA+3RenJOMQ9GBsQotLcUylVbTXtqnn4w=; fh=nK/B2gIzvYPsKU0sJgdKEVdz5eoE00hHt727sEimwsQ=; b=q34ABM/PAJVZTFx2PKGszYJuCMtAGg+1zc6WTjtnrLVBE0KvEqB/oc9WHboITpclcF jHBTdfOytS8yuxoZpVswREhjI65TjTWl7qmPaVSIhjxLbDIpe7CyL/E9YVp/93AkxKAW fU4JKfYiPv4nYgzVpARbLKzOvFj/s4dDoSAjsA2uOmFTYmuJjHT6FMNtfjYYe5DkvL4e Q2ap5gz454+Ff3Rq2RM06q+yQkPkxxlJSu1DNK3gezcLk/7a+qlgJypf9a7nf4Gnv9P8 E6bBzliqydi/CmkZSnP+V9y0XncEba6UIG0h6D6WATKy5hUboM4ktltD1GNOGp6Cp7wj JYPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=Jp4DwJ0n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id h6-20020a056a00170600b0068895dea43csi6594778pfc.78.2023.10.23.07.00.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 07:00:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=Jp4DwJ0n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id DAE13807C57C; Mon, 23 Oct 2023 07:00:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231591AbjJWOAb (ORCPT + 99 others); Mon, 23 Oct 2023 10:00:31 -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: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 23 Oct 2023 07:00:51 -0700 (PDT) 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 --- 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 = cpu_to_le16(chap->host_key_len); memcpy(data->rval, chap->response, chap->hash_len); if (ctrl->ctrl_key) { + chap->bi_directional = true; get_random_bytes(chap->c2, chap->hash_len); data->cvalid = 1; chap->s2 = nvme_auth_get_seqnum(); @@ -660,6 +662,7 @@ static void nvme_auth_reset_dhchap(struct nvme_dhchap_queue_context *chap) chap->error = 0; chap->s1 = 0; chap->s2 = 0; + chap->bi_directional = false; chap->transaction = 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 *work) goto fail2; } - 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); -- 2.39.2