Skip to contentSkip to conversation

nvme-tcp: auth success1 msg always includes resp

PATCH Superseded Mark O'Donovan 3 participants 7 messages Aug 28, 2023 – Sep 12, 2023

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 nvme-tcp: auth success1 msg always includes resp

In cases where RVALID is false, the response is still transmitted, but is cleared to zero.

Relevant extract from the spec:
Response R2, if valid (i.e., if the RVALID field is set to 01h), cleared to 0h otherwise

---
 drivers/nvme/host/auth.c | 5 +----
 include/linux/nvme.h     | 2 +-
 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/nvme/host/auth.c +1 -4
index daf5d144a8ea..49f8c46bddf1 100644
@@ -339,10 +339,7 @@ static int nvme_auth_process_dhchap_success1(struct nvme_ctrl *ctrl,
 		struct nvme_dhchap_queue_context *chap)
 {
 	struct nvmf_auth_dhchap_success1_data *data = chap->buf;
-	size_t size = sizeof(*data);
-
-	if (chap->ctrl_key)
-		size += chap->hash_len;
+	size_t size = sizeof(*data) + chap->hash_len;
 
 	if (size > CHAP_BUF_SIZE) {
 		chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD;
include/linux/nvme.h +1 -1
index 26dd3f859d9d..8d8df9c15b74 100644
@@ -1722,7 +1722,7 @@ struct nvmf_auth_dhchap_success1_data {
 	__u8		rsvd2;
 	__u8		rvalid;
 	__u8		rsvd3[7];
-	/* 'hl' bytes of response value if 'rvalid' is set */
+	/* 'hl' bytes of response value */
 	__u8		rval[];
 };
 
Signature · 1 line
2.39.2
#1 lore raw

PATCH 2/2 nvme-tcp: always set valid seq_num in dhchap reply

Currently a seqnum of zero is sent during uni-directional authentication. The zero value is reserved for the secure channel feature which is not yet implemented.

---
 drivers/nvme/host/auth.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/nvme/host/auth.c +1 -2
index 49f8c46bddf1..bf32a43fe5df 100644
@@ -314,15 +314,14 @@ static int nvme_auth_set_dhchap_reply_data(struct nvme_ctrl *ctrl,
 	if (ctrl->ctrl_key) {
 		get_random_bytes(chap->c2, chap->hash_len);
 		data->cvalid = 1;
-		chap->s2 = nvme_auth_get_seqnum();
 		memcpy(data->rval + chap->hash_len, chap->c2,
 		       chap->hash_len);
 		dev_dbg(ctrl->device, "%s: qid %d ctrl challenge %*ph\n",
 			__func__, chap->qid, (int)chap->hash_len, chap->c2);
 	} else {
 		memset(chap->c2, 0, chap->hash_len);
-		chap->s2 = 0;
 	}
+	chap->s2 = nvme_auth_get_seqnum();
 	data->seqnum = cpu_to_le32(chap->s2);
 	if (chap->host_key_len) {
 		dev_dbg(ctrl->device, "%s: qid %d host public key %*ph\n",
Signature · 1 line
2.39.2
maintainer
#2 lore raw

Re: [PATCH 2/2] nvme-tcp: always set valid seq_num in dhchap reply

Quoted 3 lines · Mark O'Donovan

Currently a seqnum of zero is sent during uni-directional authentication. The zero value is reserved for the secure channel feature which is not yet implemented.

Hannes?

#4 lore raw
Quoted 6 lines · Sagi Grimberg

This is not nvme-tcp specific.
prefix should be "nvme-auth: ..."

I'm assuming that this passes blktests?

Nonetheless looks fine to me.

Yes, the nvme auth blktests all pass with this change. Sorry about the prefix. Will fix if doing another revision.

maintainer Reviewed-by on v1 1/2
#5 lore raw
In reply to Mark O'Donovan
Quoted 7 lines · Mark O'Donovan

In cases where RVALID is false, the response is still transmitted, but is cleared to zero.

Relevant extract from the spec:
Response R2, if valid (i.e., if the RVALID field is set to 01h), cleared to 0h otherwise

Quoted 6 lines
---
  drivers/nvme/host/auth.c | 5 +----
  include/linux/nvme.h     | 2 +-
  2 files changed, 2 insertions(+), 5 deletions(-)

Cheers,

Hannes