Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1718702ioo; Mon, 23 May 2022 01:23:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9M3trsxTZL/FihqHGAD4hs65rC0T2/vetlc9SUmyEYVRYFAH2I5oWs3FbNIHPRz99vc+S X-Received: by 2002:a17:902:d58c:b0:162:1101:c892 with SMTP id k12-20020a170902d58c00b001621101c892mr8197168plh.172.1653294221608; Mon, 23 May 2022 01:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653294221; cv=none; d=google.com; s=arc-20160816; b=ktZyx0I8gyu9SlBumrlU1MVWNoYMM+HdrjBJzDEmY8+fgf70Fcq6ZqONcX73H7c/jP 4YoF88hYNTBrolpSOsyuj/LeBRVeSsy4gA352TBLWJT/szOLogzqNQFkV2Y5nDDnCF+8 CvA8scUEvlsh52+i7fvtRm7gbA9qYyF/HEERDLhJfWrgL2o5/VWmaLPDhDTJpEeZkIZe VJtkqu2hKw0ZOTGKrQ8CnoTl5uvGJ9pu8vj7SFP0QrfPUQ4nQH0DcsbfD6EnSUyFxvbM KAWt/0VKO4RzbqIsylRpQX19i1d411uYooax5N0vexqwY1czAemvuum+QkoNmT1vjdIF U0jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=JLMWRQbvtYko+FdD+5V/cDbb1tg5HgSK7m/BIo8u5Fk=; b=uKvJPPVdutoS47k0Zg24EpptlPwr8xwPAbWVRQwU3nKWyoRSqv11zftjhUgphAJmt2 957Yar/hEiV4dhii0yZ8KNslph7PbwXpB2Sg27sO3GcBGWKkpmjrz1l+p80OHz5BCMR1 oRky+c12u/VDd9RD5rswtjR3QSEMwP0kTlLhMnsDydRVApVLS1dM/ingQKqx5doC/rMM cF7frXcH6oLho1FI2/UgiXKCFvWJaTsREX8YpL7xkCU99qezi7LkY80ehajkXkavnEtl LVZx8KFoSEgLsLTQdsGGPzSwafnGImZOANQMUqQeMuoJrgOSseKkWPD/BGenvDbd/qS4 VU4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=ryxniUq1; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j12-20020a170903024c00b0015d3a9ee940si10016532plh.149.2022.05.23.01.23.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 01:23:41 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=ryxniUq1; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 355F830F45; Mon, 23 May 2022 00:30:35 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229792AbiEWHaJ (ORCPT + 99 others); Mon, 23 May 2022 03:30:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230003AbiEWHZM (ORCPT ); Mon, 23 May 2022 03:25:12 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82F06E0D9 for ; Mon, 23 May 2022 00:20:17 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B8954219E9; Mon, 23 May 2022 06:03:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1653285786; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JLMWRQbvtYko+FdD+5V/cDbb1tg5HgSK7m/BIo8u5Fk=; b=ryxniUq193oWU6pMdhZted0WY6RQLycCB0iiLQezzp8jMNqsDY1XjxT12kwdZAKGfM8QLd ccltel4blW35LP0FuXYhN875erWmPe5YGh6H+IKTeHomKQtNt6ClD5WV4uHvmL/8e5XN4M ArrmpHoVMa0ki7aj0SpnU1AEwyotxPE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1653285786; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JLMWRQbvtYko+FdD+5V/cDbb1tg5HgSK7m/BIo8u5Fk=; b=h6pe1Ss7YyDo8PwYGaCSUfDoiJRrQFU7lh5mhnrljZ5VLTDjXk8vbCVjWn4lC+34txxNi5 EzRO9LbEOWCU7YBw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 525D113AA5; Mon, 23 May 2022 06:03:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id HEEdBpoji2J4dgAAMHmgww (envelope-from ); Mon, 23 May 2022 06:03:06 +0000 Message-ID: <903b586c-b539-c4e5-9233-7e24aa55f11b@suse.de> Date: Mon, 23 May 2022 08:03:05 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH 09/11] nvmet: Implement basic In-Band Authentication Content-Language: en-US To: Max Gurtovoy , Christoph Hellwig Cc: Sagi Grimberg , Keith Busch , linux-nvme@lists.infradead.org, linux-crypto@vger.kernel.org References: <20220518112234.24264-1-hare@suse.de> <20220518112234.24264-10-hare@suse.de> From: Hannes Reinecke In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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-crypto@vger.kernel.org On 5/22/22 13:44, Max Gurtovoy wrote: > Hi Hannes, > > On 5/18/2022 2:22 PM, Hannes Reinecke wrote: >> Implement NVMe-oF In-Band authentication according to NVMe TPAR 8006. >> This patch adds three additional configfs entries 'dhchap_key', >> 'dhchap_ctrl_key', and 'dhchap_hash' to the 'host' configfs directory. >> The 'dhchap_key' and 'dhchap_ctrl_key' entries need to be in the ASCII >> format as specified in NVMe Base Specification v2.0 section 8.13.5.8 >> 'Secret representation'. >> 'dhchap_hash' defaults to 'hmac(sha256)', and can be written to to >> switch to a different HMAC algorithm. >> >> Signed-off-by: Hannes Reinecke >> --- >>   drivers/nvme/target/Kconfig            |  12 + >>   drivers/nvme/target/Makefile           |   1 + >>   drivers/nvme/target/admin-cmd.c        |   2 + >>   drivers/nvme/target/auth.c             | 367 ++++++++++++++++++ >>   drivers/nvme/target/configfs.c         | 107 +++++- >>   drivers/nvme/target/core.c             |  11 + >>   drivers/nvme/target/fabrics-cmd-auth.c | 491 +++++++++++++++++++++++++ >>   drivers/nvme/target/fabrics-cmd.c      |  38 +- >>   drivers/nvme/target/nvmet.h            |  62 ++++ >>   9 files changed, 1088 insertions(+), 3 deletions(-) >>   create mode 100644 drivers/nvme/target/auth.c >>   create mode 100644 drivers/nvme/target/fabrics-cmd-auth.c >> >> diff --git a/drivers/nvme/target/Kconfig b/drivers/nvme/target/Kconfig >> index 973561c93888..e569319be679 100644 >> --- a/drivers/nvme/target/Kconfig >> +++ b/drivers/nvme/target/Kconfig >> @@ -83,3 +83,15 @@ config NVME_TARGET_TCP >>         devices over TCP. >>         If unsure, say N. >> + >> +config NVME_TARGET_AUTH >> +    bool "NVMe over Fabrics In-band Authentication support" >> +    depends on NVME_TARGET >> +    depends on NVME_AUTH >> +    select CRYPTO_HMAC >> +    select CRYPTO_SHA256 >> +    select CRYPTO_SHA512 >> +    help >> +      This enables support for NVMe over Fabrics In-band Authentication >> + >> +      If unsure, say N. >> diff --git a/drivers/nvme/target/Makefile b/drivers/nvme/target/Makefile >> index 9837e580fa7e..c66820102493 100644 >> --- a/drivers/nvme/target/Makefile >> +++ b/drivers/nvme/target/Makefile >> @@ -13,6 +13,7 @@ nvmet-y        += core.o configfs.o admin-cmd.o >> fabrics-cmd.o \ >>               discovery.o io-cmd-file.o io-cmd-bdev.o >>   nvmet-$(CONFIG_NVME_TARGET_PASSTHRU)    += passthru.o >>   nvmet-$(CONFIG_BLK_DEV_ZONED)        += zns.o >> +nvmet-$(CONFIG_NVME_TARGET_AUTH)    += fabrics-cmd-auth.o auth.o >>   nvme-loop-y    += loop.o >>   nvmet-rdma-y    += rdma.o >>   nvmet-fc-y    += fc.o >> diff --git a/drivers/nvme/target/admin-cmd.c >> b/drivers/nvme/target/admin-cmd.c >> index 31df40ac828f..fc8a957fad0a 100644 >> --- a/drivers/nvme/target/admin-cmd.c >> +++ b/drivers/nvme/target/admin-cmd.c >> @@ -1018,6 +1018,8 @@ u16 nvmet_parse_admin_cmd(struct nvmet_req *req) >>       if (nvme_is_fabrics(cmd)) >>           return nvmet_parse_fabrics_admin_cmd(req); >> +    if (unlikely(!nvmet_check_auth_status(req))) >> +        return NVME_SC_AUTH_REQUIRED | NVME_SC_DNR; >>       if (nvmet_is_disc_subsys(nvmet_req_subsys(req))) >>           return nvmet_parse_discovery_cmd(req); >> diff --git a/drivers/nvme/target/auth.c b/drivers/nvme/target/auth.c >> new file mode 100644 >> index 000000000000..003c0faad7ff >> --- /dev/null >> +++ b/drivers/nvme/target/auth.c >> @@ -0,0 +1,367 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +/* >> + * NVMe over Fabrics DH-HMAC-CHAP authentication. >> + * Copyright (c) 2020 Hannes Reinecke, SUSE Software Solutions. >> + * All rights reserved. >> + */ >> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include "nvmet.h" >> +#include "../host/auth.h" > > maybe we can put the common stuff to include/linux/nvme-auth.h instead > of doing ../host/auth.h ? > > Yes, we can do that. Will be fixing it for the next round. Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman