Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp383550iob; Wed, 18 May 2022 04:26:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzF9NJpCoDABeSf3KMCb1K9iDLcYnwdoZVymLYYn0dvQMO31MgjIUK7/jUdk11UV6o5SG8 X-Received: by 2002:a05:6a00:a1e:b0:50d:bb0c:2e27 with SMTP id p30-20020a056a000a1e00b0050dbb0c2e27mr27275540pfh.49.1652873200344; Wed, 18 May 2022 04:26:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652873200; cv=none; d=google.com; s=arc-20160816; b=aO0Re5sGtJAEg9kCx3KG2yHE+gLDLQvxZz2O/QEuNw/kkHUr0KlbFYcC2hNX9raqtr vAxlpd9t+V5qbpUqJkC3+LYlbgFUPjUSFotJIeJmpmgEImtwWbdZ+d2ogAQ0Ir/Twe/G eJJSs6do9suu1OnkSILn2zYCw7T1Kjg2G/F95oOqNkZuq9QhRjAATo1GhWerktW7wugs NWyfV0lDAcA/TZsq2euXqp2aZ4LXHopJVrYkloSc7Htr1wq1Dj7ojzgjUJuGTpepyHUN yaRAo/8jmCGZ3d0tH2PBn2I08sbLyTYFJIJJGRDkGrfa8onEONf3Vc4PQYSGg7VCSJ6v T8pA== 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:dkim-signature; bh=PWW8KtETebgaTkzOWq5LzP/4FDLtdsx7XewVO5qKMns=; b=mLons4BMQZRYtZoHMGBncSvG8N50XI+kreV08LgS2jRxmp7cLzRLcM2suyXkfkmOqh 8NOF8k5V+j6y7ukGgapRGQbGtBXAdwDJMXE4bSUcYrIErGsaVL3wHAj6pFdv5Jisx5No o4WLaI1NDBIUMMd4zQ81YqKTAStlszVmfTa2Onsh/BgycR/ugnbyKrGvUMCcG9RRTRD4 KIn/6ihsR/7pN9LjwKFgvatbmyBrZMgngs/ayKnxnSHi1VyFZgxpp6GnBkbr/KV9xfT9 3O8zFhVjHfyR2bMXHcIdTgbbV5yb0SH4Fl8ytiYf7qGVzqJIbOW3YA2mpV7gO/GOHl/q OMUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=JxW32sgb; dkim=neutral (no key) header.i=@suse.de header.b=aIsjNMBH; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f9-20020a170902860900b0015abefdc1f1si2205304plo.285.2022.05.18.04.26.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 04:26:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=JxW32sgb; dkim=neutral (no key) header.i=@suse.de header.b=aIsjNMBH; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:18 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 7B48E15F6F5; Wed, 18 May 2022 04:23:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235557AbiERLXD (ORCPT + 99 others); Wed, 18 May 2022 07:23:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235413AbiERLW7 (ORCPT ); Wed, 18 May 2022 07:22:59 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26EAD15E617 for ; Wed, 18 May 2022 04:22:55 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 6719421BB0; Wed, 18 May 2022 11:22:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1652872973; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PWW8KtETebgaTkzOWq5LzP/4FDLtdsx7XewVO5qKMns=; b=JxW32sgb+WiWx3Je9MXW7jI04xoRtL4+c64n5ZvIfplXw7aR/D9P3zXiq+rGwhitoEcBP1 oCVitOuoVGzfqJ7LeCPa8BEn9kG+Vaw+FstS2LW9cVAr5SnS4NW8bJZNdgsE6nAICyAWtD do5FVICSLv1lOiGpCDCMWd0zKoAaFRY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1652872973; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PWW8KtETebgaTkzOWq5LzP/4FDLtdsx7XewVO5qKMns=; b=aIsjNMBHxnhPOCXHfpvlNsgwVUESLcroudcVFF57bSqlvMxr2bRkvBHgtA3msL/FwqX0eF 4Aw4I7TYvKnXdSDw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 5F0872C152; Wed, 18 May 2022 11:22:53 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id B46F9519451B; Wed, 18 May 2022 13:22:52 +0200 (CEST) From: Hannes Reinecke To: Christoph Hellwig Cc: Sagi Grimberg , Keith Busch , linux-nvme@lists.infradead.org, linux-crypto@vger.kernel.org, Hannes Reinecke Subject: [PATCH 11/11] nvmet-auth: expire authentication sessions Date: Wed, 18 May 2022 13:22:34 +0200 Message-Id: <20220518112234.24264-12-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220518112234.24264-1-hare@suse.de> References: <20220518112234.24264-1-hare@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Each authentication step is required to be completed within the KATO interval (or two minutes if not set). So add a workqueue function to reset the transaction ID and the expected next protocol step; this will automatically the next authentication command referring to the terminated authentication. Signed-off-by: Hannes Reinecke --- drivers/nvme/target/auth.c | 1 + drivers/nvme/target/fabrics-cmd-auth.c | 20 +++++++++++++++++++- drivers/nvme/target/nvmet.h | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/target/auth.c b/drivers/nvme/target/auth.c index 71e13d7eb511..183af0b24523 100644 --- a/drivers/nvme/target/auth.c +++ b/drivers/nvme/target/auth.c @@ -218,6 +218,7 @@ int nvmet_setup_auth(struct nvmet_ctrl *ctrl) void nvmet_auth_sq_free(struct nvmet_sq *sq) { + cancel_delayed_work(&sq->auth_expired_work); kfree(sq->dhchap_c1); sq->dhchap_c1 = NULL; kfree(sq->dhchap_c2); diff --git a/drivers/nvme/target/fabrics-cmd-auth.c b/drivers/nvme/target/fabrics-cmd-auth.c index 3156b052da4d..0d2571d03272 100644 --- a/drivers/nvme/target/fabrics-cmd-auth.c +++ b/drivers/nvme/target/fabrics-cmd-auth.c @@ -12,9 +12,22 @@ #include "nvmet.h" #include "../host/auth.h" +static void nvmet_auth_expired_work(struct work_struct *work) +{ + struct nvmet_sq *sq = container_of(to_delayed_work(work), + struct nvmet_sq, auth_expired_work); + + pr_debug("%s: ctrl %d qid %d transaction %u expired, resetting\n", + __func__, sq->ctrl->cntlid, sq->qid, sq->dhchap_tid); + sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_NEGOTIATE; + sq->dhchap_tid = -1; +} + void nvmet_init_auth(struct nvmet_ctrl *ctrl, struct nvmet_req *req) { /* Initialize in-band authentication */ + INIT_DELAYED_WORK(&req->sq->auth_expired_work, + nvmet_auth_expired_work); req->sq->authenticated = false; req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_NEGOTIATE; req->cqe->result.u32 |= 0x2 << 16; @@ -326,8 +339,13 @@ void nvmet_execute_auth_send(struct nvmet_req *req) req->cqe->result.u64 = 0; nvmet_req_complete(req, status); if (req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2 && - req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_FAILURE2) + req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_FAILURE2) { + unsigned long auth_expire_secs = ctrl->kato ? ctrl->kato : 120; + + mod_delayed_work(system_wq, &req->sq->auth_expired_work, + auth_expire_secs * HZ); return; + } /* Final states, clear up variables */ nvmet_auth_sq_free(req->sq); if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_FAILURE2) diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h index 8b239aec3ca2..829fb1d78ee1 100644 --- a/drivers/nvme/target/nvmet.h +++ b/drivers/nvme/target/nvmet.h @@ -109,6 +109,7 @@ struct nvmet_sq { u32 sqhd; bool sqhd_disabled; #ifdef CONFIG_NVME_TARGET_AUTH + struct delayed_work auth_expired_work; bool authenticated; u16 dhchap_tid; u16 dhchap_status; -- 2.29.2