public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: 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 2/2] nvme: Do not re-authenticate queues with no prior authentication
Date: Fri, 24 Jan 2025 12:47:38 +0100	[thread overview]
Message-ID: <20250124114738.115882-3-hare@kernel.org> (raw)
In-Reply-To: <20250124114738.115882-1-hare@kernel.org>

From: Hannes Reinecke <hare@kernel.org>

When sending 'connect' the queues can figure out from the return code
whether authentication is required or not. 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 | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c
index 000c0a4197ba..1a304eb78809 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;
@@ -927,12 +928,14 @@ static void nvme_queue_auth_work(struct work_struct *work)
 	}
 	if (!ret) {
 		chap->error = 0;
+		chap->authenticated = true;
 		if (ctrl->opts->concat &&
 		    (ret = nvme_auth_secure_concat(ctrl, chap))) {
 			dev_warn(ctrl->device,
 				 "%s: qid %d failed to enable secure concatenation\n",
 				 __func__, chap->qid);
 			chap->error = ret;
+			chap->authenticated = false;
 		}
 		return;
 	}
@@ -1021,6 +1024,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,
@@ -1074,6 +1085,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



  parent reply	other threads:[~2025-01-24 11:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-24 11:47 [PATCHv2 0/2] nvme: restrict authentication to the admin queue hare
2025-01-24 11:47 ` [PATCH 1/2] nvmet: Implement 'admin_only' authentication hare
2025-01-24 13:49   ` Sagi Grimberg
2025-01-24 13:51     ` Hannes Reinecke
2025-01-28  8:11       ` Sagi Grimberg
2025-01-28  8:48         ` Hannes Reinecke
2025-01-24 11:47 ` hare [this message]
2025-01-28  8:06   ` [PATCH 2/2] nvme: Do not re-authenticate queues with no prior authentication Sagi Grimberg
     [not found] ` <BY5PR04MB6849C5BBCCD96273CF2F2A52BCC42@BY5PR04MB6849.namprd04.prod.outlook.com>
     [not found]   ` <BY5PR04MB6849700BB53BBE24BBE640D4BCD32@BY5PR04MB6849.namprd04.prod.outlook.com>
2025-03-14  7:59     ` [PATCHv2 0/2] nvme: restrict authentication to the admin queue Hannes Reinecke
  -- strict thread matches above, loose matches on Subject: below --
2025-04-22  9:15 [PATCHv3 " Hannes Reinecke
2025-04-22  9:15 ` [PATCH 2/2] nvme: Do not re-authenticate queues with no prior authentication 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=20250124114738.115882-3-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox