Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2469417rda; Wed, 25 Oct 2023 03:52:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGvlFpzB4Rd6pql3iWThKH9CYQWccyxFruJy0p5kvv6tH6I53Nz/wHPL+d+mf+N0eCAmk2P X-Received: by 2002:a0d:df44:0:b0:5a8:2037:36d9 with SMTP id i65-20020a0ddf44000000b005a8203736d9mr14882509ywe.25.1698231137620; Wed, 25 Oct 2023 03:52:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698231137; cv=none; d=google.com; s=arc-20160816; b=kRDsEDHwCyCIxOeIAYohzuylJsvpB4uvFwYRt90bANsvB5HDkY5kyBzqClYPa4Y1MZ /xENsD+U+nkuPydDaaI4Auugt1PrFnxc+HkXNrPnKl/eJjlvj3P7pV6dfiKMgN0l0d+F EcGKAqNTc0nwq0X18voLghyiKOajMvgUxy52p5V+VDYEWHHC8W6j0VGX9PFGiFU8t+rq dix2lI17+SoUbreX6p2pkiDPzoUK33UDsFiToyI0JWgxGACVCTRIJePWOFA2UaHiPuel hLwhJlrevloz8W+K4xY1Z6LTyLlgEOZRFtm53lHQ/Yf3JO5BPkkVc0UFi2ecV5Z5IVuF 6sAg== 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=ofbfEVVL4E62FvCq+MPrYUpLujp4AL1WHzfCF2qxQz0=; fh=nK/B2gIzvYPsKU0sJgdKEVdz5eoE00hHt727sEimwsQ=; b=uUO/z/2bViZlYvdwfMjY8Imz6dHwAI9J8SMdac+mwGnqt6s79uWoup9PbwxhhsWoV8 qiOMpSvzkAq2TCjDHGxq3fgLgQ88zxiDMt7FLo0Y/qxL192EA2bd9IpkxoBUvy/DFAnZ sg5n7rfziUz/DZMsaFhpJ0oNeB+Mb6Q882B6HRaFA8nC8exQ3gWbBwWDEobXh+KyA68B 5EhpUmDSVbZlXfcunN5B8Rdwgu0ugV8Pru+BwfX58iN8PSzlUD9aayY7VXO7sqUOcvjC KYmrSnOvJWW0eXxxjp0xH7IrPDeG0SPA9W+ohzx1xcBTJNLSmkTjwmB7BTVCqkn4NRkW Ozsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=JGX6rTQ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id v5-20020a81a545000000b005a7aef2e19dsi11022336ywg.156.2023.10.25.03.52.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 03:52:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=JGX6rTQ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 2049180BB21D; Wed, 25 Oct 2023 03:52:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234082AbjJYKvp (ORCPT + 99 others); Wed, 25 Oct 2023 06:51:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233153AbjJYKvn (ORCPT ); Wed, 25 Oct 2023 06:51:43 -0400 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 238148F for ; Wed, 25 Oct 2023 03:51:41 -0700 (PDT) Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id BEBA424002D for ; Wed, 25 Oct 2023 12:51:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1698231099; bh=Todilzex7SY38WlYbvcVBDp8UXS6ZQgCTD4taXoUATI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version: Content-Transfer-Encoding:From; b=JGX6rTQ5l/c+IsLYz+Fd6acI09fZ+QEBh6zBkFTylzWg+7Fl6j15+JNAZp6OlMG23 s3oFVVd/G43XPTxGnbCTYHKyhfVab2CVTqr1i2FmAmzV0abFM2yLLgBNvZONgLOwUy ONB4wPjvc6CLTJn30Kp12vuPQT4H6yUdYcqEuOdQRNVrnWqn2EG8c/Ti6p4f1n3COk EauXS1ju/bKixX5MlKRJT3AUc5guC9OcFJk7aeEEOOyDwo/FL8JoO0+CVR28/Dw42+ HjXBplrM/J7qIGW9hG/hgpm/LpLt3wLvWTnZHa4eZxTcw9XV+i58FiHBGz5uFNc53Y V6cel9BiM5AvQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4SFm2L1DMcz9rxN; Wed, 25 Oct 2023 12:51:38 +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 v3 2/3] nvme-auth: add flag for bi-directional auth Date: Wed, 25 Oct 2023 10:51:24 +0000 Message-Id: <20231025105125.134443-3-shiftee@posteo.net> In-Reply-To: <20231025105125.134443-1-shiftee@posteo.net> References: <20231025105125.134443-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 groat.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 (groat.vger.email [0.0.0.0]); Wed, 25 Oct 2023 03:52:14 -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 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 = 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