Message ID | 20231013202827.2262708-2-shiftee@posteo.net |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp2137225vqb; Fri, 13 Oct 2023 13:29:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5qGpdjsBKY3+CMNnwyDVZ2GHI6j2Sz8zuCqw8c78L01D5wZZZpOurBwkLEaudwoMVStXX X-Received: by 2002:a05:6358:c10a:b0:14a:cca4:55d7 with SMTP id fh10-20020a056358c10a00b0014acca455d7mr24361703rwb.3.1697228960077; Fri, 13 Oct 2023 13:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697228960; cv=none; d=google.com; s=arc-20160816; b=tghYEVOy6Qhb0d4XT59yIK8QvRKJ/Pjetw/hz8lSQ9Jef4zNYPLExXALXoC/vaj78q RLMGil0agqM+N3DKVIMr/fYpZdCl+aM5pylai9idb3gPGiC2tOFc9kO2U7ZYlHwxErB6 3K8uy2L/TT2R8xjuM9eLOV6y7s+IT1F+sA7p+/1VvVpPLxzn4SXfUiZdzRRREYcpU2O3 fRYYI3c9M06TJjVr2i0q62Ip5nHKZlrJnEfDB8cOg475w64SjeXiYQKV9w8tA3it6Iup dTuqi70u1XbucTK4wLOQKg1KQysnqTNaQWUX2nOTdZYOrw4XnfdxGomyAhoCO5stc7Um HyiQ== 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=kjcvHnJiyzpcF2Qs6RaXGnQYr+vhPGf833ujIMcqIHw=; fh=OK6NlIuxAObXnbB+YsmCJIFQ9spAlQ71xiCElZ04Vio=; b=x8QYMD3qeV5UxlZy67o9+Sk54v2//OjRDrcXf1/bSqojPAhNyi0jAn4SVX6t1kd3iA O1ddMN5QujRBcO5mlTHqNXzTlAA42yK8TWA6wSe0Sf010dx40ySotVChDvP5lVPCEoPT gDHY6F+ZHd8MQkuOjKAlwpsjXXvMU9dPN3iu03yTXvy78JsjrzvsApajEho8fCOrkvWG rqhzrYcGkFqIgbcetaVImZK0PzbyPFOetXBC6J8R3opk8dIbTt3WyuOJSaDEdHWxkjIZ uv3S9fXCcp2dXZVuEWD292ZJgV3A8xVPZ2hMHFlkPC5mZ1EGUALOENTYNVmi/r8O9lns rtmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=JIVIcEgv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id v3-20020a056a00148300b0069347c30c78si18178232pfu.230.2023.10.13.13.29.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 13:29:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=JIVIcEgv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 168CD82D9813; Fri, 13 Oct 2023 13:29:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232194AbjJMU3M (ORCPT <rfc822;rua109.linux@gmail.com> + 19 others); Fri, 13 Oct 2023 16:29:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232005AbjJMU3L (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 13 Oct 2023 16:29:11 -0400 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76F9D83 for <linux-kernel@vger.kernel.org>; Fri, 13 Oct 2023 13:29:08 -0700 (PDT) Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 200D724002A for <linux-kernel@vger.kernel.org>; Fri, 13 Oct 2023 22:29:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1697228947; bh=wCPxNhXED6Xa4hXVL029+O8olAaVDn+KVg7XUvMNVA4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version: Content-Transfer-Encoding:From; b=JIVIcEgvumkdb/aKU3G+lxzED3XX7aoaZ5ReEFljmhfXYoziONBFN6WVshOp5r2Mk 973rUH53cYgKyGvHCnzIMrQ58aU1FsT4ZguVtMwSgdxz6LKzaS7WAtFgs/KhA9ErgM U1i+0lKq5XiTFLfhVkiACL096l8IAr/HmC2TLehwU3GKoBw6ZTCHpfaq1BvKXuAXnf FDLbTjxXMuB1/iV1ivg2qfz7+903zzy4D5jG5cKSpMCi1QOnpY0pYrK+XP0YXocpib cwGNal6t9YdcgIeU3mF7KmXU+7v9FwX/vCXgKeMNDu2TgZpI/73mkF+XX6DFe6vuMT AR+UqFw/9k/hQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4S6dQ93TzBz9rxM; Fri, 13 Oct 2023 22:29:05 +0200 (CEST) From: Mark O'Donovan <shiftee@posteo.net> 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 <shiftee@posteo.net>, Akash Appaiah <Akash.Appaiah@dell.com> Subject: [PATCH 1/2] nvme-auth: use transformed key size to create resp Date: Fri, 13 Oct 2023 20:28:26 +0000 Message-Id: <20231013202827.2262708-2-shiftee@posteo.net> In-Reply-To: <20231013202827.2262708-1-shiftee@posteo.net> References: <20231013202827.2262708-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 agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 13 Oct 2023 13:29:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779673553770041201 X-GMAIL-MSGID: 1779673553770041201 |
Series |
Remove secret-size restrictions for hashes
|
|
Commit Message
Mark O'Donovan
Oct. 13, 2023, 8:28 p.m. UTC
This does not change current behaviour as the driver currently verifies that the secret size is the same size as the length of the transformation hash. Co-developed-by: Akash Appaiah <Akash.Appaiah@dell.com> Signed-off-by: Akash Appaiah <Akash.Appaiah@dell.com> Signed-off-by: Mark O'Donovan <shiftee@posteo.net> --- drivers/nvme/host/auth.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
Comments
On 10/13/23 22:28, Mark O'Donovan wrote: > This does not change current behaviour as the driver currently > verifies that the secret size is the same size as the length of > the transformation hash. > > Co-developed-by: Akash Appaiah <Akash.Appaiah@dell.com> > Signed-off-by: Akash Appaiah <Akash.Appaiah@dell.com> > Signed-off-by: Mark O'Donovan <shiftee@posteo.net> > --- > drivers/nvme/host/auth.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c > index daf5d144a8ea..e7d478d17b06 100644 > --- a/drivers/nvme/host/auth.c > +++ b/drivers/nvme/host/auth.c > @@ -418,6 +418,14 @@ static int nvme_auth_set_dhchap_failure2_data(struct nvme_ctrl *ctrl, > return size; > } > > +static int nvme_auth_dhchap_transformed_key_len(struct nvme_dhchap_key *key) > +{ > + if (key->hash) > + return nvme_auth_hmac_hash_len(key->hash); > + > + return key->len; > +} > + > static int nvme_auth_dhchap_setup_host_response(struct nvme_ctrl *ctrl, > struct nvme_dhchap_queue_context *chap) > { > @@ -442,7 +450,8 @@ static int nvme_auth_dhchap_setup_host_response(struct nvme_ctrl *ctrl, > } > > ret = crypto_shash_setkey(chap->shash_tfm, > - chap->host_response, ctrl->host_key->len); > + chap->host_response, > + nvme_auth_dhchap_transformed_key_len(ctrl->host_key)); > if (ret) { > dev_warn(ctrl->device, "qid %d: failed to set key, error %d\n", > chap->qid, ret); Hmm. Yeah, hash size vs secret size always gets me. However, wouldn't it be better to return the key size from nvme_auth_transform_key and us that directly? (cf the attached patch) Cheers, Hannes
On 14/10/2023 12:41, Hannes Reinecke wrote: > On 10/13/23 22:28, Mark O'Donovan wrote: >> This does not change current behaviour as the driver currently >> verifies that the secret size is the same size as the length of >> the transformation hash. >> >> Co-developed-by: Akash Appaiah <Akash.Appaiah@dell.com> >> Signed-off-by: Akash Appaiah <Akash.Appaiah@dell.com> >> Signed-off-by: Mark O'Donovan <shiftee@posteo.net> >> --- >> drivers/nvme/host/auth.c | 11 ++++++++++- >> 1 file changed, 10 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c >> index daf5d144a8ea..e7d478d17b06 100644 >> --- a/drivers/nvme/host/auth.c >> +++ b/drivers/nvme/host/auth.c >> @@ -418,6 +418,14 @@ static int nvme_auth_set_dhchap_failure2_data(struct nvme_ctrl *ctrl, >> return size; >> } >> +static int nvme_auth_dhchap_transformed_key_len(struct nvme_dhchap_key *key) >> +{ >> + if (key->hash) >> + return nvme_auth_hmac_hash_len(key->hash); >> + >> + return key->len; >> +} >> + >> static int nvme_auth_dhchap_setup_host_response(struct nvme_ctrl *ctrl, >> struct nvme_dhchap_queue_context *chap) >> { >> @@ -442,7 +450,8 @@ static int nvme_auth_dhchap_setup_host_response(struct nvme_ctrl *ctrl, >> } >> ret = crypto_shash_setkey(chap->shash_tfm, >> - chap->host_response, ctrl->host_key->len); >> + chap->host_response, >> + nvme_auth_dhchap_transformed_key_len(ctrl->host_key)); >> if (ret) { >> dev_warn(ctrl->device, "qid %d: failed to set key, error %d\n", >> chap->qid, ret); > > Hmm. Yeah, hash size vs secret size always gets me. > However, wouldn't it be better to return the key size from > nvme_auth_transform_key and us that directly? > (cf the attached patch) > > Cheers, > > Hannes Hi Hannes, I gave this a try and it ended up being easier to put it in struct nvme_dhchap_key. V2 also does the nvme target code, and this means the length is stored in the same place. Let me know if this works for you. Thanks, Mark
diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c index daf5d144a8ea..e7d478d17b06 100644 --- a/drivers/nvme/host/auth.c +++ b/drivers/nvme/host/auth.c @@ -418,6 +418,14 @@ static int nvme_auth_set_dhchap_failure2_data(struct nvme_ctrl *ctrl, return size; } +static int nvme_auth_dhchap_transformed_key_len(struct nvme_dhchap_key *key) +{ + if (key->hash) + return nvme_auth_hmac_hash_len(key->hash); + + return key->len; +} + static int nvme_auth_dhchap_setup_host_response(struct nvme_ctrl *ctrl, struct nvme_dhchap_queue_context *chap) { @@ -442,7 +450,8 @@ static int nvme_auth_dhchap_setup_host_response(struct nvme_ctrl *ctrl, } ret = crypto_shash_setkey(chap->shash_tfm, - chap->host_response, ctrl->host_key->len); + chap->host_response, + nvme_auth_dhchap_transformed_key_len(ctrl->host_key)); if (ret) { dev_warn(ctrl->device, "qid %d: failed to set key, error %d\n", chap->qid, ret);