From patchwork Wed Oct 25 10:51:23 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: 158029 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp2509537vqx; Wed, 25 Oct 2023 03:52:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGFS4WX1Lcw0S1BQPrcF2FnFQDap9+hv7jxu+lC/fvC9ie+0urgntT4137Ms1i95ZZ8h4MT X-Received: by 2002:a05:6808:ab7:b0:3ad:f5b7:d691 with SMTP id r23-20020a0568080ab700b003adf5b7d691mr16085729oij.18.1698231141927; Wed, 25 Oct 2023 03:52:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698231141; cv=none; d=google.com; s=arc-20160816; b=RirT1MFYwRkoWbkGXzk070JNRhWsXpii9kk/jrl9wR5fJl2MBmcg8bjv5wwVg3v4iW h/6Vm6JFGxKtrpAyBYKrtRmUAu7byoKZwWTWt3SWZkGvKWk0RqBsQQK9z8EJDN8k9Wim pph5oIQ4pKCDyltMrTyZMsHHQrxOaIQjx5qw/V8DgLTGZWEjtUXz3C+HUJgO2dRpV3Ma jGyUK5SFCjg1lJMA2qDXWXFEmdBR5qnEfdqeRhDFQxSgLMY2od0M5cjSbe0jvJrDfhf7 GAwdE09KKptAFtcq7/zHIBcxOkCNe1Kq7iaagoBbWHnBbuwDVKe3qPf4LMbh3jtxUDjC Tfww== 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=GjqLB3n/3wM9GLzr63LISYPuPKRe45txi1u/PioJ9As=; fh=nK/B2gIzvYPsKU0sJgdKEVdz5eoE00hHt727sEimwsQ=; b=sPDJz55Gl0O4NNwasSlskGdapkScq0sDMEGZUGRQU1XN19yvdow6KmduEUxm2jd3iP 0oGfDsf1CJn5vVt01CsbqimBA3nEf8RTHmTmjlhPZXXhmbirmqnIgKX4j3KwGFLtojER wkmV4GJLbW89APqfYMprFOHod5QDBa7qCtXueO7qYyuC5in3qyY+i2Fos/YfGcEelCoB /XYutnx1tMNihlmcT0xVnIxiqwnKjDwhUzkt5XytmLcHg91ZOlGc+ollD4Ngp55Rkta/ obh871lj12cMgb/oBwzTkzFcNLqTdHfcqQY4bgHcB0l+THOdoL/6sikGNnvoupRzcMKF jz7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=fzzKsHIs; 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 p123-20020a252981000000b00d9cc1ed345bsi10275933ybp.162.2023.10.25.03.52.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 03:52:21 -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=fzzKsHIs; 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 3248380BB216; Wed, 25 Oct 2023 03:52:19 -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 S234481AbjJYKvx (ORCPT + 26 others); Wed, 25 Oct 2023 06:51:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229583AbjJYKvo (ORCPT ); Wed, 25 Oct 2023 06:51:44 -0400 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36C25AC for ; Wed, 25 Oct 2023 03:51:41 -0700 (PDT) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 95331240106 for ; Wed, 25 Oct 2023 12:51:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1698231098; bh=jTnT/chsOtzfuw6NmZuyV4Fm9a93YfuqFYlLWZRZY3Q=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version: Content-Transfer-Encoding:From; b=fzzKsHIsQKX/JSmLFfIJeoRn8YWtpU7rmdb4t43E50CthymzErREjllwxUr7GDapJ L1O5yv8kPfS1KCMDdfvOLNeCmiYnabQ69zM3uHpF2MAxMPWO4/KGmBMcV08n1z6c1H E5CytkHMvHIXBBiq8eu5zExYkJZsciwAczgZsCfe6ccS2yxeJE4iLJ+JtxqeDvWJYB LLGOJPQxXHl7IIbY5bR+/PuwpQ/W2CMfm29BnkgfnPgJ0H6Raib5xTAxommQpy7H2u yY6bTq1sCK2iGyUf57eP9v0XYKBdXUqj3qdJsUEBwLLvfBWejwR+29PKdyGb6/N902 9jfmsaRsqLZfA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4SFm2J70n8z9rxH; Wed, 25 Oct 2023 12:51:36 +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 1/3] nvme-auth: auth success1 msg always includes resp Date: Wed, 25 Oct 2023 10:51:23 +0000 Message-Id: <20231025105125.134443-2-shiftee@posteo.net> In-Reply-To: <20231025105125.134443-1-shiftee@posteo.net> References: <20231025105125.134443-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]); Wed, 25 Oct 2023 03:52:19 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780724418082085129 X-GMAIL-MSGID: 1780724418082085129 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 Wed Oct 25 10:51:24 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: 158027 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp2509434vqx; Wed, 25 Oct 2023 03:52:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9pYZmluluBDl6dH1XSOm+njJPEtJeIOcPhFQiKnSPKpu8SzUKOIeOZta+wcsdusLjViTM X-Received: by 2002:a05:6102:512a:b0:45a:9bb2:d486 with SMTP id bm42-20020a056102512a00b0045a9bb2d486mr5954718vsb.15.1698231124866; Wed, 25 Oct 2023 03:52:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698231124; cv=none; d=google.com; s=arc-20160816; b=u6q+IWj0rg2gY14/O86/ReIZevw7+EMFra92W4fNJ4aU36dcIsCjiDzjykIYh1akTx n8xxPcJFssD63SYFgNl0o4YIsACqSUOUb51kMffpQOejCAA0SHyEYwWvOPzHiGvRMgxV bSHWWh2cF65AK67w/TO5eqqxYB9AWb84zpKI4FRcP4sMTBdOtuekWt5JiVejnMIccvzG /8pSCzapUtFD1xyl1BezY/FVFmfl2RfXUFEZ7CT5k7JfCcPyqJECE8EiDl8bm4gnUZDZ hxhGC38FSWhFH4RFIPyWwVALYtYpcEyD5iWsA0TOiE98z/etm2EL4APJnPD/UuCnnEmE AefA== 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 23.128.96.32 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. [23.128.96.32]) by mx.google.com with ESMTPS id i8-20020a256d08000000b00d9cf811eb97si8907582ybc.327.2023.10.25.03.52.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 03:52:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; 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 23.128.96.32 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 61AE980947C1; Wed, 25 Oct 2023 03:52:02 -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 S234209AbjJYKvp (ORCPT + 26 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 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]); Wed, 25 Oct 2023 03:52:02 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780724400026690167 X-GMAIL-MSGID: 1780724400026690167 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 Reviewed-by: Hannes Reinecke --- 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 Wed Oct 25 10:51:25 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: 158028 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp2509486vqx; Wed, 25 Oct 2023 03:52:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1wSnZ8y2zdPg+l73cnLAEj04k/06Ke4NF8GmqubZnw/FG2tMjoGYbf6SqtMeb6z3xXqoU X-Received: by 2002:a25:d190:0:b0:d9a:b471:1868 with SMTP id i138-20020a25d190000000b00d9ab4711868mr13262223ybg.12.1698231131757; Wed, 25 Oct 2023 03:52:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698231131; cv=none; d=google.com; s=arc-20160816; b=ccgr3lUhEoGhbN+5luynRck09NTJ0onnsAvtQwa/vN8rfLqBwT1XnLMu5Yet2Moyzr Eo3VeGqw+KwbBdDzez8ClHfyG+KYNeMQHOFrNvhQKgT3I0ROuf+wzPBWYj+WjmjhOfn8 6BU4/vnbzpbZCNGYYJ3ekitbwJtSroaeC9xXWiHNB3d92RdKybDz1u9W0TmEqPGZv3dm O8TB7YNIlHjguUm0IAm2//VQqE840jbE8tKEjeMhqBP9l/34H1sjIfUk5Qs3amYcMEt/ V4Cw4Uzq7QRu1LhRYit9Y+bplNWRgagPLxHXBZSWT4WoYxNG8PnnFULeOMZlE/Khk1gL 92wQ== 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=JJl2pNGus+zmZZ2QAVuG7fmdoEEDiypT/1RRzJ57qyw=; fh=nK/B2gIzvYPsKU0sJgdKEVdz5eoE00hHt727sEimwsQ=; b=g7KEDSJI+UNB3eASuy1VSegsvFfveTu10BryNE6Fyyvq/AuFpdZuo1mEmkWOZjCEc9 8O2Zzl4/BHeQphQXNuACxCAwugQ4Q8woUVxqQlEfmn/hKTl+F1tqN2cR8cSEK6BC933F bL7marPk9d2aIGzjkkvxcpH9V7Hog7E2H+0ooGz9zS9PWP7T1ukRFFe65Mq2VW9Js95J l5uOmHxg41CoOB3U+Q2nNlFBCn/WleUkKF7qhLAieItsh9noL8Nx85Itl1UBjyJaMOvD X+HKbaq0DxudLX8vtL/ytgoixQLDS7keN7oBPaSXZO7hFUNvBy3XVjfpNXZ3dc0ocNl+ 2XMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=G8WLzTYn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id s40-20020a25aa2b000000b00d9ac5356738si11273818ybi.184.2023.10.25.03.52.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 03:52:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=G8WLzTYn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 830E680FCBC5; Wed, 25 Oct 2023 03:52:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234804AbjJYKv5 (ORCPT + 26 others); Wed, 25 Oct 2023 06:51:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233187AbjJYKvo (ORCPT ); Wed, 25 Oct 2023 06:51:44 -0400 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3644EC1 for ; Wed, 25 Oct 2023 03:51:42 -0700 (PDT) Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id D0E65240028 for ; Wed, 25 Oct 2023 12:51:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1698231100; bh=YFBxTR0zvXLVBvSBdoAtunK27N4nE0w7KBv3zsHx+dg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version: Content-Transfer-Encoding:From; b=G8WLzTYnOQwb7L+Iv+qxQD7cF8gI3zQa/zQtvHCVopa5UOWp9r25c4qNwV1PCbo6t xLPFuZbjtcV+DZYqzuoigK6kvE1K3DF1aijVZw1lTMMKj1ws4eCl47jJo0wBaCiiyG XG2tgjwqvWJAEi2Aakg/8T2gYwmycF/AXHn9mVOM+8VQANW1zUWNG6WTGegs8JaWl5 ZwpM8jY69Uyy8BJFSmF51482P7BrruWNJPx9HY1RFqEshKuwrCRnAtSCt1c3kWEDDr GRrbhRcKeeAXyso/8YSJlhraX2gHHivkvZxhXOrb3eTzKWferG+Am/ZcchZz4dMbPb IsZ5TbDbFYsEA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4SFm2M3kRBz9rxL; Wed, 25 Oct 2023 12:51:39 +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 3/3] nvme-auth: always set valid seq_num in dhchap reply Date: Wed, 25 Oct 2023 10:51:25 +0000 Message-Id: <20231025105125.134443-4-shiftee@posteo.net> In-Reply-To: <20231025105125.134443-1-shiftee@posteo.net> References: <20231025105125.134443-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 fry.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 (fry.vger.email [0.0.0.0]); Wed, 25 Oct 2023 03:52:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780724407413988691 X-GMAIL-MSGID: 1780724407413988691 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 Reviewed-by: Hannes Reinecke --- v1: used incorrect prefix nvme-tcp v2: added spec extract to commit message v3: read the seq-num in nvme-target code drivers/nvme/host/auth.c | 3 +-- drivers/nvme/target/fabrics-cmd-auth.c | 2 +- 2 files changed, 2 insertions(+), 3 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", diff --git a/drivers/nvme/target/fabrics-cmd-auth.c b/drivers/nvme/target/fabrics-cmd-auth.c index 1d9854484e2e..eb7785be0ca7 100644 --- a/drivers/nvme/target/fabrics-cmd-auth.c +++ b/drivers/nvme/target/fabrics-cmd-auth.c @@ -163,11 +163,11 @@ static u16 nvmet_auth_reply(struct nvmet_req *req, void *d) pr_debug("%s: ctrl %d qid %d challenge %*ph\n", __func__, ctrl->cntlid, req->sq->qid, data->hl, req->sq->dhchap_c2); - req->sq->dhchap_s2 = le32_to_cpu(data->seqnum); } else { req->sq->authenticated = true; req->sq->dhchap_c2 = NULL; } + req->sq->dhchap_s2 = le32_to_cpu(data->seqnum); return 0; }