All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>,
	linux-nvme@lists.infradead.org, Hannes Reinecke <hare@kernel.org>
Subject: [PATCH 1/2] nvme: Do not re-authenticate queues with no prior authentication
Date: Wed, 17 Jul 2024 13:03:37 +0200	[thread overview]
Message-ID: <20240717110338.27332-2-hare@kernel.org> (raw)
In-Reply-To: <20240717110338.27332-1-hare@kernel.org>

When sending 'connect' the queues can figure out whether authentication
is required. But reauthentication doesn't disconnect the queues, so this
check is not available. Rather we need to check whether the queue had
been authenticated initially to figure out if we need to reauthenticate.

Signed-off-by: Hannes Reinecke <hare@kernel.org>
---
 drivers/nvme/host/auth.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c
index 23ff3df27e80..66828742586c 100644
--- a/drivers/nvme/host/auth.c
+++ b/drivers/nvme/host/auth.c
@@ -31,6 +31,7 @@ struct nvme_dhchap_queue_context {
 	u32 s1;
 	u32 s2;
 	bool bi_directional;
+	bool authenticated;
 	u16 transaction;
 	u8 status;
 	u8 dhgroup_id;
@@ -915,6 +916,7 @@ static void nvme_queue_auth_work(struct work_struct *work)
 		goto fail2;
 	if (chap->qid || !ctrl->opts->concat) {
 		chap->error = 0;
+		chap->authenticated = true;
 		return;
 	}
 	ret = nvme_auth_secure_concat(ctrl, chap);
@@ -923,8 +925,10 @@ static void nvme_queue_auth_work(struct work_struct *work)
 			 "%s: qid %d failed to enable secure concatenation\n",
 			 __func__, chap->qid);
 		chap->error = ret;
-	} else
+	} else {
 		chap->error = 0;
+		chap->authenticated = true;
+	}
 	return;
 
 fail2:
@@ -940,6 +944,8 @@ static void nvme_queue_auth_work(struct work_struct *work)
 	 */
 	if (ret && !chap->error)
 		chap->error = ret;
+	if (chap->error)
+		chap->authenticated = false;
 }
 
 int nvme_auth_negotiate(struct nvme_ctrl *ctrl, int qid)
@@ -1011,6 +1017,14 @@ static void nvme_ctrl_auth_work(struct work_struct *work)
 		return;
 
 	for (q = 1; q < ctrl->queue_count; q++) {
+		/*
+		 * Skip re-authentication if the queue had
+		 * not been authenticated initially.
+		 */
+		if (!ctrl->dhchap_ctxs[q].authenticated) {
+			ctrl->dhchap_ctxs[q].error = 0;
+			continue;
+		}
 		ret = nvme_auth_negotiate(ctrl, q);
 		if (ret) {
 			dev_warn(ctrl->device,
@@ -1064,6 +1078,7 @@ int nvme_auth_init_ctrl(struct nvme_ctrl *ctrl)
 		chap = &ctrl->dhchap_ctxs[i];
 		chap->qid = i;
 		chap->ctrl = ctrl;
+		chap->authenticated = false;
 		INIT_WORK(&chap->auth_work, nvme_queue_auth_work);
 	}
 
-- 
2.35.3



  reply	other threads:[~2024-07-17 11:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-17 11:03 [PATCH 0/2] nvme: restrict authentication to the admin queue Hannes Reinecke
2024-07-17 11:03 ` Hannes Reinecke [this message]
2024-07-17 11:03 ` [PATCH 2/2] nvmet: Implement 'admin_only' authentication Hannes Reinecke
2024-07-17 22:40   ` Sagi Grimberg
2024-07-18  7:38     ` Hannes Reinecke
2024-07-21 11:32       ` Sagi Grimberg
2024-08-20 14:06 ` [PATCH 0/2] nvme: restrict authentication to the admin queue Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240717110338.27332-2-hare@kernel.org \
    --to=hare@kernel.org \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.