From patchwork Fri Oct 13 20:28:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark O'Donovan X-Patchwork-Id: 152725 Return-Path: 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 + 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 ); 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 ; 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 ; 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 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 , Akash Appaiah 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 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: 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 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 Signed-off-by: Akash Appaiah Signed-off-by: Mark O'Donovan --- 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); From patchwork Fri Oct 13 20:28:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark O'Donovan X-Patchwork-Id: 152726 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp2137226vqb; Fri, 13 Oct 2023 13:29:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFP+dVaFbGaXjqKnindutLZCjRcvjNZkgNord1nRsJ53Tk18KiX3oDbwvZPDBJqDwtTxnmj X-Received: by 2002:a05:6871:8a18:b0:1e9:bb3a:9a32 with SMTP id tl24-20020a0568718a1800b001e9bb3a9a32mr4843844oab.0.1697228960270; 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=kOh6VEulSIp+KRmbHyK2KJTIqIgLGAerTC9V/fgr5aBlxxcEbtONI/NzBCyIM6v2hk 9tMqpDWgAFgRGvRbUuUshCY1lwqydz7wlyKJeAmToNJuREwMkg0v94MQ1wjN+MLGQXgi skyB8ClJD30hkg9sInEy9i5sxiE9U4mgjYoCjgvxDMdYoO5mXCQg83IDNzLaTntBnffD P+aDB0QcWv4WGSFYQAeY6rMMZ7F+jgIQGb+OPgMzd9PEO7exUiPZtzu+zyIhtMJLiwLY QT+XHPbNK5BUJv4zwpkF/lek58Z3axl+0nL59tWt2PraSU3X5ywud9lssjNhSb362WDI GpIg== 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=1GLFrwGH4uXeFR8RVOdSkxb/2TdBOc0jUn6jf8KiE5U=; fh=OK6NlIuxAObXnbB+YsmCJIFQ9spAlQ71xiCElZ04Vio=; b=ADvyDDZ0yC6uu+nWp/SSLBcMubTxTvPDOY28zmwD26WskjbCnMKfgaq12nBGlPL35P EmpPp3rkpTxz6h520tcvZq34U0CvGF7YHcpjsitudMLNbhNV+QSFP5SPUAjUcVs/MbSB HB2ygY9tRzOfuA1iKpvqMYoavPUsq5MNM8iRw7LtnHHbOcOLrZ5TFPusZVRkPdmr0xLX DMCFzaWvjMhg4PmaP3iyFr5xxtNmQub+x3D86JcI8ZirSSzzkqZ8rl7L/HYFgcaHAXIb pJZWiubYgCPpuSFAJcg7SH8mm9CypRPZIdF/xHENDqxgara0Qc8FpELft6jKZufVT9/G 8KrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=p21QMCQZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id l191-20020a6391c8000000b00585a02550e1si5594378pge.50.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 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=p21QMCQZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 9F1358345280; Fri, 13 Oct 2023 13:29:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232256AbjJMU3N (ORCPT + 19 others); Fri, 13 Oct 2023 16:29:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232197AbjJMU3L (ORCPT ); Fri, 13 Oct 2023 16:29:11 -0400 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 840AABE for ; Fri, 13 Oct 2023 13:29:09 -0700 (PDT) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 0E3EE240103 for ; Fri, 13 Oct 2023 22:29:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1697228948; bh=PZesDCIO0qB1QiAn0VpqqXvIqc6VhWTAaPu3kq45sGo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version: Content-Transfer-Encoding:From; b=p21QMCQZptEMN8nCgKKrSJyOyuSRMzuXEZInHKUlwjZmVMFuJHrKcz8TcT8Q5ijVU P43BfasODEUKbqFXO9F01rmPwq5DRdF+NXCZQsVnmK5/FSX3z+04vB1/hnyFk4k4Td q8WLruBeboMc5YIg/sVAfI1aeZq1gZRoXo816fyEM1valib3PmSo+RRqJLq3Cdcgaf GgEf4Q9OLc32FJE6fz6Lyes1HNk9LPRLIPAFmP5+049kCOcGSijQI7G6dFGi8RupOH rYLndMQal2wARJf1uLBEiw2hsixheq5cgvSysDglPh+fDIKoeX3iWSy9JZHDGq8XRF V0iUHB9Qub+5A== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4S6dQB5FQ1z9rxF; Fri, 13 Oct 2023 22:29:06 +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 , Akash Appaiah Subject: [PATCH 2/2] nvme-auth: allow mixing of secret and hash lengths Date: Fri, 13 Oct 2023 20:28:27 +0000 Message-Id: <20231013202827.2262708-3-shiftee@posteo.net> In-Reply-To: <20231013202827.2262708-1-shiftee@posteo.net> References: <20231013202827.2262708-1-shiftee@posteo.net> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Fri, 13 Oct 2023 13:29:19 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779673554014833296 X-GMAIL-MSGID: 1779673554014833296 We can now use any of the secret transformation hashes with a secret, regardless of the secret size. e.g. a 32 byte key with the SHA-512(64 byte) hash. The example secret from the spec should now be permitted with any of the following: DHHC-1:00:ia6zGodOr4SEG0Zzaw398rpY0wqipUWj4jWjUh4HWUz6aQ2n: DHHC-1:01:ia6zGodOr4SEG0Zzaw398rpY0wqipUWj4jWjUh4HWUz6aQ2n: DHHC-1:02:ia6zGodOr4SEG0Zzaw398rpY0wqipUWj4jWjUh4HWUz6aQ2n: DHHC-1:03:ia6zGodOr4SEG0Zzaw398rpY0wqipUWj4jWjUh4HWUz6aQ2n: Note: Secrets are still restricted to 32,48 or 64 bits. Co-developed-by: Akash Appaiah Signed-off-by: Akash Appaiah Signed-off-by: Mark O'Donovan Reviewed-by: Hannes Reinecke --- drivers/nvme/common/auth.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/nvme/common/auth.c b/drivers/nvme/common/auth.c index d90e4f0c08b7..176855f86f0d 100644 --- a/drivers/nvme/common/auth.c +++ b/drivers/nvme/common/auth.c @@ -187,14 +187,6 @@ struct nvme_dhchap_key *nvme_auth_extract_key(unsigned char *secret, goto out_free_secret; } - if (key_hash > 0 && - (key_len - 4) != nvme_auth_hmac_hash_len(key_hash)) { - pr_err("Mismatched key len %d for %s\n", key_len, - nvme_auth_hmac_name(key_hash)); - ret = -EINVAL; - goto out_free_secret; - } - /* The last four bytes is the CRC in little-endian format */ key_len -= 4; /*