From: Hannes Reinecke <hare@suse.de>
To: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>, Keith Busch <kbusch@kernel.org>,
linux-nvme@lists.infradead.org, Hannes Reinecke <hare@suse.de>
Subject: [PATCH 2/2] nvme-auth: set the DNR bit if authentication failed
Date: Tue, 30 Aug 2022 14:49:25 +0200 [thread overview]
Message-ID: <20220830124925.40711-3-hare@suse.de> (raw)
In-Reply-To: <20220830124925.40711-1-hare@suse.de>
If authentication failed we should be setting the 'DNR' bit, as
each retry will yield exactly the same result; we rather should
change the parameters to 'nvme connect' to fixup the situation.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/nvme/host/auth.c | 20 ++++++++++----------
drivers/nvme/host/fabrics.c | 4 ++--
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c
index 4ca3f7d042f1..ad0decc5523f 100644
--- a/drivers/nvme/host/auth.c
+++ b/drivers/nvme/host/auth.c
@@ -158,7 +158,7 @@ static int nvme_auth_process_dhchap_challenge(struct nvme_ctrl *ctrl,
"qid %d: invalid HASH ID %d\n",
chap->qid, data->hashid);
chap->status = NVME_AUTH_DHCHAP_FAILURE_HASH_UNUSABLE;
- return NVME_SC_INVALID_FIELD;
+ return NVME_SC_DNR | NVME_SC_INVALID_FIELD;
}
if (chap->hash_id == data->hashid && chap->shash_tfm &&
@@ -194,7 +194,7 @@ static int nvme_auth_process_dhchap_challenge(struct nvme_ctrl *ctrl,
crypto_free_shash(chap->shash_tfm);
chap->shash_tfm = NULL;
chap->status = NVME_AUTH_DHCHAP_FAILURE_HASH_UNUSABLE;
- return NVME_SC_AUTH_REQUIRED;
+ return NVME_SC_DNR | NVME_SC_AUTH_REQUIRED;
}
/* Reset host response if the hash had been changed */
@@ -216,7 +216,7 @@ static int nvme_auth_process_dhchap_challenge(struct nvme_ctrl *ctrl,
chap->qid, data->dhgid);
chap->status = NVME_AUTH_DHCHAP_FAILURE_DHGROUP_UNUSABLE;
/* Leave previous dh_tfm intact */
- return NVME_SC_AUTH_REQUIRED;
+ return NVME_SC_DNR | NVME_SC_AUTH_REQUIRED;
}
/* Clear host and controller key to avoid accidental reuse */
@@ -247,7 +247,7 @@ static int nvme_auth_process_dhchap_challenge(struct nvme_ctrl *ctrl,
"qid %d: empty DH value\n",
chap->qid);
chap->status = NVME_AUTH_DHCHAP_FAILURE_DHGROUP_UNUSABLE;
- return NVME_SC_INVALID_FIELD;
+ return NVME_SC_DNR | NVME_SC_INVALID_FIELD;
}
chap->dh_tfm = crypto_alloc_kpp(kpp_name, 0, 0);
@@ -268,7 +268,7 @@ static int nvme_auth_process_dhchap_challenge(struct nvme_ctrl *ctrl,
"qid %d: invalid DH value for NULL DH\n",
chap->qid);
chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD;
- return NVME_SC_INVALID_FIELD;
+ return NVME_SC_DNR | NVME_SC_INVALID_FIELD;
}
chap->dhgroup_id = data->dhgid;
@@ -357,7 +357,7 @@ static int nvme_auth_process_dhchap_success1(struct nvme_ctrl *ctrl,
"qid %d: invalid hash length %u\n",
chap->qid, data->hl);
chap->status = NVME_AUTH_DHCHAP_FAILURE_HASH_UNUSABLE;
- return NVME_SC_INVALID_FIELD;
+ return NVME_SC_DNR | NVME_SC_INVALID_FIELD;
}
/* Just print out information for the admin queue */
@@ -381,7 +381,7 @@ static int nvme_auth_process_dhchap_success1(struct nvme_ctrl *ctrl,
"qid %d: controller authentication failed\n",
chap->qid);
chap->status = NVME_AUTH_DHCHAP_FAILURE_FAILED;
- return NVME_SC_AUTH_REQUIRED;
+ return NVME_SC_DNR | NVME_SC_AUTH_REQUIRED;
}
/* Just print out information for the admin queue */
@@ -733,7 +733,7 @@ static void __nvme_auth_work(struct work_struct *work)
NVME_AUTH_DHCHAP_MESSAGE_CHALLENGE);
if (ret) {
chap->status = ret;
- chap->error = NVME_SC_AUTH_REQUIRED;
+ chap->error = NVME_SC_DNR | NVME_SC_AUTH_REQUIRED;
return;
}
@@ -797,7 +797,7 @@ static void __nvme_auth_work(struct work_struct *work)
NVME_AUTH_DHCHAP_MESSAGE_SUCCESS1);
if (ret) {
chap->status = ret;
- chap->error = NVME_SC_AUTH_REQUIRED;
+ chap->error = NVME_SC_DNR | NVME_SC_AUTH_REQUIRED;
return;
}
@@ -815,7 +815,7 @@ static void __nvme_auth_work(struct work_struct *work)
ret = nvme_auth_process_dhchap_success1(ctrl, chap);
if (ret) {
/* Controller authentication failed */
- chap->error = NVME_SC_AUTH_REQUIRED;
+ chap->error = ret;
goto fail2;
}
diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index 83b505358859..633e5fe8e832 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -416,7 +416,7 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl)
if (ret) {
dev_warn(ctrl->device,
"qid 0: authentication setup failed\n");
- ret = NVME_SC_AUTH_REQUIRED;
+ ret = NVME_SC_DNR | NVME_SC_AUTH_REQUIRED;
goto out_free_data;
}
ret = nvme_auth_wait(ctrl, 0);
@@ -492,7 +492,7 @@ int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid)
if (ret) {
dev_warn(ctrl->device,
"qid %d: authentication setup failed\n", qid);
- ret = NVME_SC_AUTH_REQUIRED;
+ ret = NVME_SC_DNR | NVME_SC_AUTH_REQUIRED;
} else {
ret = nvme_auth_wait(ctrl, qid);
if (ret)
--
2.35.3
next prev parent reply other threads:[~2022-08-30 12:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-30 12:49 [PATCHv2 0/2] nvme: honor DNR status for authentication Hannes Reinecke
2022-08-30 12:49 ` [PATCH 1/2] nvme-auth: retry command if DNR bit is not set Hannes Reinecke
2022-09-05 12:05 ` Sagi Grimberg
2022-09-06 14:16 ` Hannes Reinecke
2022-09-07 6:44 ` Christoph Hellwig
2022-08-30 12:49 ` Hannes Reinecke [this message]
2022-09-05 11:52 ` [PATCH 2/2] nvme-auth: set the DNR bit if authentication failed Sagi Grimberg
2022-09-07 6:46 ` Christoph Hellwig
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=20220830124925.40711-3-hare@suse.de \
--to=hare@suse.de \
--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