From patchwork Mon Oct 23 14:00:01 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: 156897 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1316569vqx; Mon, 23 Oct 2023 07:01:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGvOnzj41HhBqdkUijnUSMZ02AL3XqD1MdMG1K2aysG7MN4PQ1Tfci1UXZllJD2RuSBwV13 X-Received: by 2002:a05:6359:3285:b0:168:decd:9551 with SMTP id rk5-20020a056359328500b00168decd9551mr2829372rwb.4.1698069697899; Mon, 23 Oct 2023 07:01:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698069697; cv=none; d=google.com; s=arc-20160816; b=gun6pQLU8toKRwz38GbT47t/jR/+KkOOQm/hlRNqJ9LqOI8iMXsPbLBk9HGhf16fqk IVF1XXuZg5bNu/fAOWv3bNE206SKhqL4wByvOX8qBgSXZI6IbL4S3TntVduWMk0e2ETZ yImfoVE6H52Ai2acWAdglQjLumwlHOrUMq7RUGMIomcNnnXKNT/k1rG8PX8dEQhtl6wM 8d37xO63BQXCInzqX1VOpLOY9IqjHoU+hhiAuI/lgaSTI3PAoyh//0BfJysKgCgG8lAA bprypjTQy02GMdLJDE6V+JwqG9MqNExSgNs7PPvFQfdriU9XGSNdyk9o9/YAawPhrSN3 ZNPg== 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=QnAjvfjWFnCpRxuxioGHpQr5KpcVIkWFE2DSEbIq2A4=; fh=nK/B2gIzvYPsKU0sJgdKEVdz5eoE00hHt727sEimwsQ=; b=Tz+QJwOR5JgFAIvM5ln5UWhrCjHP+Oj8Fh8Dr+yHgZZQYZKjHL3Ras8NanuR+5vp1M Cb5VJa5sOLOfIUX5j3+H7b3Skqr0vg7iuk5mrKubCr6jy9jFTSmP7s0v4V4DH+/HGSpA VNZNscNwMRj0nrWTEoVze3AyENryKzMjYa0aXcg1408tfxs0F7p0+v/kgu9qgYDmaviA 61Bh0bynsOrSwDz+pgwfjVLHbTcBEg9+v6weSIyXuCNTXZa30jJq/KRDTivLEldDZkNR j6rOauP/FR/knmXzfNO7Tjjq2GnMxTu/IvpN7uSZWpmwEo6OrvJrH6KzOghJ4ULWbmbx wn5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=qpGm7DQ7; 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id ck4-20020a056a02090400b005b81f21a261si6554462pgb.747.2023.10.23.07.01.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 07:01:37 -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=qpGm7DQ7; 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 50F85807F2B7; Mon, 23 Oct 2023 07:00:48 -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 S231387AbjJWOAX (ORCPT + 27 others); Mon, 23 Oct 2023 10:00:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231136AbjJWOAS (ORCPT ); Mon, 23 Oct 2023 10:00:18 -0400 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1710D73 for ; Mon, 23 Oct 2023 07:00:16 -0700 (PDT) Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 609DC240029 for ; Mon, 23 Oct 2023 16:00:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1698069615; bh=Fig6sNGtNPtLEqdibiKwrPwhe4ldPvHG+L+Zwf6xQc0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version: Content-Transfer-Encoding:From; b=qpGm7DQ7F5jjomuPr+/Fq4TA4UceNKtt5zNG8KACUt/gWWCQh5ca7oRofj833f3ns 1HcLzNJTLA36h4OiLeGfZrMxFSS1JrGY/EM4Hom0Y93KKvUANBnV+B8AlZYG0/Nyq7 R6bAdpqL6ZfKMCbQhsj3RUkaFR6M/q+B/lKgFElW/AkZ/W6uPvp/CA1BGxG9hpLfpG c2JHS8QGRKILvD5891iRTr37j8dE0OoihV0den5o1fu1xVbBpZ2RGG1GeFzRiI3p2m 5s1cg8cGfKOKfCh2mke5k0YJ6cMdeawc8rq3XHZc55qgeoqU6ExdQ4OJOA9uJALo/7 BA+8zCZTEQ2Iw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4SDcJt0HvNz6tsB; Mon, 23 Oct 2023 16:00:13 +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 1/3] nvme-auth: auth success1 msg always includes resp Date: Mon, 23 Oct 2023 14:00:01 +0000 Message-Id: <20231023140003.58019-2-shiftee@posteo.net> In-Reply-To: <20231023140003.58019-1-shiftee@posteo.net> References: <20231023140003.58019-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 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]); Mon, 23 Oct 2023 07:00:48 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780555131692707978 X-GMAIL-MSGID: 1780555131692707978 In cases where RVALID is false, the response is still transmitted, but is cleared to zero. Relevant extract from the spec: Response R2, if valid (i.e., if the RVALID field is set to 01h), cleared to 0h otherwise Signed-off-by: Mark O'Donovan Reviewed-by: Hannes Reinecke Reviewed-by: Sagi Grimberg Reviewed-by: Christoph Hellwig --- v1: used incorrect prefix nvme-tcp v2: rebase on latest git drivers/nvme/host/auth.c | 5 +---- include/linux/nvme.h | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c index 064592a5d546..e0fc33d41baa 100644 --- a/drivers/nvme/host/auth.c +++ b/drivers/nvme/host/auth.c @@ -339,10 +339,7 @@ static int nvme_auth_process_dhchap_success1(struct nvme_ctrl *ctrl, struct nvme_dhchap_queue_context *chap) { struct nvmf_auth_dhchap_success1_data *data = chap->buf; - size_t size = sizeof(*data); - - if (chap->s2) - size += chap->hash_len; + size_t size = sizeof(*data) + chap->hash_len; if (size > CHAP_BUF_SIZE) { chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD; diff --git a/include/linux/nvme.h b/include/linux/nvme.h index 26dd3f859d9d..8d8df9c15b74 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h @@ -1722,7 +1722,7 @@ struct nvmf_auth_dhchap_success1_data { __u8 rsvd2; __u8 rvalid; __u8 rsvd3[7]; - /* 'hl' bytes of response value if 'rvalid' is set */ + /* 'hl' bytes of response value */ __u8 rval[]; }; From patchwork Mon Oct 23 14:00:02 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: 156896 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1316212vqx; Mon, 23 Oct 2023 07:01:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzjH64bHqsETWFLuJ33KyiWMjHrUq8IWw+1Blp1bcQBy9GQfO8lay0jD20bCHENFk+V8Ji X-Received: by 2002:a05:6a00:b8c:b0:690:cae9:714d with SMTP id g12-20020a056a000b8c00b00690cae9714dmr7827932pfj.13.1698069674656; Mon, 23 Oct 2023 07:01:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698069674; cv=none; d=google.com; s=arc-20160816; b=dBXImj7+d18s5Wgkz26bdtwnycWV0gdu2Wr59AyJB2KilhIMLzasTFWLWc2IX/BPp9 VZrx0a8/TVkcQs8POJF/AYtxCdGlRFNytEWNgz74iR/w4PiMiGGCd65jVf1LLM9duec3 JwRU3q+y0pGsw80JRfuVsQU0gHSXWHYUu2dXGPXKXqND0UqdApK4Sj0EBqpbalOTEvTA PuPLfpGKLbqkKr+F96kTNFmy8bNpgT8fgX4PJK+qnljropNhWdSLb6jhyci/oBMcJJuO 1TecCsE7ZlXcYHK79EDuMffb96aoxIK0sRVtJSMxEXxjXchVHy0hbUJxDMAiVoSWrA9i diSw== 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 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 t8-20020a056a0021c800b006b440b5ace9si6602599pfj.44.2023.10.23.07.01.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 07:01:14 -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=Jp4DwJ0n; 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 47699807C746; Mon, 23 Oct 2023 07:00:45 -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 S231370AbjJWOAc (ORCPT + 27 others); Mon, 23 Oct 2023 10:00:32 -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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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]); Mon, 23 Oct 2023 07:00:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780555107093841508 X-GMAIL-MSGID: 1780555107093841508 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); From patchwork Mon Oct 23 14:00:03 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: 156895 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1316121vqx; Mon, 23 Oct 2023 07:01:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHoqGi/0V4Emc8wifHAf4M1yWME1IU0YlXExui1C9gtUJDWSudxiKtATQh2++Ae1WZXwSr1 X-Received: by 2002:a92:d5c8:0:b0:351:526a:4b6 with SMTP id d8-20020a92d5c8000000b00351526a04b6mr9293739ilq.18.1698069669754; Mon, 23 Oct 2023 07:01:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698069669; cv=none; d=google.com; s=arc-20160816; b=byiRHQ04GsAUiyvdVARsBkVvi8RQYKNwiFIPaEV5cqKI6m/zL05umy3H3bj1y/Dhay qa2eahEG9kiYqKbUOaHZHLqZB07iplXx8VdHEoNnMrwrisL1uxFurt1aYX/NNLUO40p3 LyTne50rdQ9f5EylOpk8cJzp8J8KRm7yKcL7b+4ri9oJPH9aBArdEmff0m1wU9T2Du8R AezlqsLC7qbHTCePJDf7Ahvi/pvlyB+McYYObyx/LIdzHPriOLHkKO5R7XX1uvwtFajW caBFR9wWUGHmnzsRscBzWidobtP4/0RW1XBgaT8U9qMtftS4AUZyaDhfr+iFTICvrgQ5 +viw== 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=Z40SyYvGLYKyXDNKbsBhnEqwiclPjo8D1fWa8Ktd7Ak=; fh=nK/B2gIzvYPsKU0sJgdKEVdz5eoE00hHt727sEimwsQ=; b=rA8TRELl2nJj7bNbESD5TmsO23imHbKN6hi3QJY8lRvjIqY4r2mJIkJ/ade3TitB1/ zh+7kyLiUs//Q5CT6jKZv706kEoq8WmiNY4LCb+qTCgn5FNvIQfjJDqXSQCO8NQYXCwH lhYkuyNbqi13Bg04FgeQSrvzqSyyGUxiVLVS9X6dK0+ks7tYSF6/ZDYYzUdhBHU9MXJe NmFaV7HlsnDXszi3TeYRpSoFq6OCFCt/c2YT/U79kpU6I+DtSmw+CqPpvRThI/7VO8JO xtNjHn5xo+qyd1Z2fvRj2qZ4RpoEnu050jFo5tKqeHbWxt69omb1t1mhm9q8kh99PmcM 56Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b="U/K/JPNl"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id bq21-20020a056a02045500b005b7c45b1f95si6877818pgb.555.2023.10.23.07.00.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 07:01:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b="U/K/JPNl"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 25553807C5EB; Mon, 23 Oct 2023 07:00:49 -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 S231367AbjJWOA2 (ORCPT + 27 others); Mon, 23 Oct 2023 10:00:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231208AbjJWOAV (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 2D0D5D73 for ; Mon, 23 Oct 2023 07:00:19 -0700 (PDT) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id CB1E8240104 for ; Mon, 23 Oct 2023 16:00:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1698069617; bh=zwCuyhVmMr+6W+Jc6uApqtn4VjGeJRlPp4FvHh/J5fE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version: Content-Transfer-Encoding:From; b=U/K/JPNl04rAE19qY8DvRu5Br7MpMde5s1OJ5R3sxavfVW42n8At+nCx1j0iD0fVi 4U/tn30rzk8OhC4sFUHEZWy+ZeeSauqtA7ctggg+9PFW+eH1uBLVI4fig4z0cubJTg niTI3XC2IfEO/WNXa5JmQyVLwe0Vtz/xe8NNNqDxSBctzymKUBeCZsbSjz05lano9w JpyHLkwzH2gs5Kn/0U6DAkzdQy4T4Rs75CHO1YUGZk2FuhbXJ2uF43iZf+Kr/XjWn2 Rrr5q6Z712DILTvX2X8BmXz9Q9Uwcocj4B/M18P9FoDqPiA2bdO3P1xRzh/C5o8LX2 L003NwS1i8arQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4SDcJw3V66z6tsB; Mon, 23 Oct 2023 16:00:16 +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 3/3] nvme-auth: always set valid seq_num in dhchap reply Date: Mon, 23 Oct 2023 14:00:03 +0000 Message-Id: <20231023140003.58019-4-shiftee@posteo.net> In-Reply-To: <20231023140003.58019-1-shiftee@posteo.net> References: <20231023140003.58019-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 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:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780555101813733283 X-GMAIL-MSGID: 1780555101813733283 Currently a seqnum of zero is sent during uni-directional authentication. The zero value is reserved for the secure channel feature which is not yet implemented. Relevant extract from the spec: The value 0h is used to indicate that bidirectional authentication is not performed, but a challenge value C2 is carried in order to generate a pre-shared key (PSK) for subsequent establishment of a secure channel Signed-off-by: Mark O'Donovan Reviewed-by: Christoph Hellwig --- v1: used incorrect prefix nvme-tcp v2: added spec extract to commit message drivers/nvme/host/auth.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c index 8558a02865ac..7f6b2e99a78c 100644 --- a/drivers/nvme/host/auth.c +++ b/drivers/nvme/host/auth.c @@ -316,15 +316,14 @@ static int nvme_auth_set_dhchap_reply_data(struct nvme_ctrl *ctrl, chap->bi_directional = true; get_random_bytes(chap->c2, chap->hash_len); data->cvalid = 1; - chap->s2 = nvme_auth_get_seqnum(); memcpy(data->rval + chap->hash_len, chap->c2, chap->hash_len); dev_dbg(ctrl->device, "%s: qid %d ctrl challenge %*ph\n", __func__, chap->qid, (int)chap->hash_len, chap->c2); } else { memset(chap->c2, 0, chap->hash_len); - chap->s2 = 0; } + chap->s2 = nvme_auth_get_seqnum(); data->seqnum = cpu_to_le32(chap->s2); if (chap->host_key_len) { dev_dbg(ctrl->device, "%s: qid %d host public key %*ph\n",