All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] nvme-tcp: auth success1 msg always includes resp
@ 2023-08-28 21:20 Mark O'Donovan
  2023-08-28 21:20 ` [PATCH 2/2] nvme-tcp: always set valid seq_num in dhchap reply Mark O'Donovan
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Mark O'Donovan @ 2023-08-28 21:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-nvme, sagi, hch, axboe, kbusch, hare, 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

Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
---
 drivers/nvme/host/auth.c | 5 +----
 include/linux/nvme.h     | 2 +-
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c
index daf5d144a8ea..49f8c46bddf1 100644
--- a/drivers/nvme/host/auth.c
+++ b/drivers/nvme/host/auth.c
@@ -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;
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 26dd3f859d9d..8d8df9c15b74 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -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[];
 };
 
-- 
2.39.2



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] nvme-tcp: always set valid seq_num in dhchap reply
  2023-08-28 21:20 [PATCH 1/2] nvme-tcp: auth success1 msg always includes resp Mark O'Donovan
@ 2023-08-28 21:20 ` Mark O'Donovan
  2023-08-29 11:48   ` Sagi Grimberg
  2023-08-29 11:47 ` [PATCH 1/2] nvme-tcp: auth success1 msg always includes resp Sagi Grimberg
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Mark O'Donovan @ 2023-08-28 21:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-nvme, sagi, hch, axboe, kbusch, hare, 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.

Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
---
 drivers/nvme/host/auth.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c
index 49f8c46bddf1..bf32a43fe5df 100644
--- a/drivers/nvme/host/auth.c
+++ b/drivers/nvme/host/auth.c
@@ -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",
-- 
2.39.2



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] nvme-tcp: auth success1 msg always includes resp
  2023-08-28 21:20 [PATCH 1/2] nvme-tcp: auth success1 msg always includes resp Mark O'Donovan
  2023-08-28 21:20 ` [PATCH 2/2] nvme-tcp: always set valid seq_num in dhchap reply Mark O'Donovan
@ 2023-08-29 11:47 ` Sagi Grimberg
  2023-08-29 23:37   ` Mark O'Donovan
  2023-09-06 10:59 ` Hannes Reinecke
  2023-09-12 11:39 ` Sagi Grimberg
  3 siblings, 1 reply; 7+ messages in thread
From: Sagi Grimberg @ 2023-08-29 11:47 UTC (permalink / raw)
  To: Mark O'Donovan, linux-kernel; +Cc: linux-nvme, hch, axboe, kbusch, hare

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

I'm assuming that this passes blktests?

Nonetheless looks fine to me.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] nvme-tcp: always set valid seq_num in dhchap reply
  2023-08-28 21:20 ` [PATCH 2/2] nvme-tcp: always set valid seq_num in dhchap reply Mark O'Donovan
@ 2023-08-29 11:48   ` Sagi Grimberg
  0 siblings, 0 replies; 7+ messages in thread
From: Sagi Grimberg @ 2023-08-29 11:48 UTC (permalink / raw)
  To: Mark O'Donovan, linux-kernel; +Cc: linux-nvme, hch, axboe, kbusch, hare



On 8/29/23 00:20, Mark O'Donovan wrote:
> 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?


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] nvme-tcp: auth success1 msg always includes resp
  2023-08-29 11:47 ` [PATCH 1/2] nvme-tcp: auth success1 msg always includes resp Sagi Grimberg
@ 2023-08-29 23:37   ` Mark O'Donovan
  0 siblings, 0 replies; 7+ messages in thread
From: Mark O'Donovan @ 2023-08-29 23:37 UTC (permalink / raw)
  To: Sagi Grimberg, linux-kernel; +Cc: linux-nvme, hch, axboe, kbusch, hare

On 29/08/2023 12:47, Sagi Grimberg wrote:
> 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.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] nvme-tcp: auth success1 msg always includes resp
  2023-08-28 21:20 [PATCH 1/2] nvme-tcp: auth success1 msg always includes resp Mark O'Donovan
  2023-08-28 21:20 ` [PATCH 2/2] nvme-tcp: always set valid seq_num in dhchap reply Mark O'Donovan
  2023-08-29 11:47 ` [PATCH 1/2] nvme-tcp: auth success1 msg always includes resp Sagi Grimberg
@ 2023-09-06 10:59 ` Hannes Reinecke
  2023-09-12 11:39 ` Sagi Grimberg
  3 siblings, 0 replies; 7+ messages in thread
From: Hannes Reinecke @ 2023-09-06 10:59 UTC (permalink / raw)
  To: Mark O'Donovan, linux-kernel; +Cc: linux-nvme, sagi, hch, axboe, kbusch

On 8/28/23 23:20, Mark O'Donovan wrote:
> 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
> 
> Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
> ---
>   drivers/nvme/host/auth.c | 5 +----
>   include/linux/nvme.h     | 2 +-
>   2 files changed, 2 insertions(+), 5 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] nvme-tcp: auth success1 msg always includes resp
  2023-08-28 21:20 [PATCH 1/2] nvme-tcp: auth success1 msg always includes resp Mark O'Donovan
                   ` (2 preceding siblings ...)
  2023-09-06 10:59 ` Hannes Reinecke
@ 2023-09-12 11:39 ` Sagi Grimberg
  3 siblings, 0 replies; 7+ messages in thread
From: Sagi Grimberg @ 2023-09-12 11:39 UTC (permalink / raw)
  To: Mark O'Donovan, linux-kernel; +Cc: linux-nvme, hch, axboe, kbusch, hare

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-09-12 11:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-28 21:20 [PATCH 1/2] nvme-tcp: auth success1 msg always includes resp Mark O'Donovan
2023-08-28 21:20 ` [PATCH 2/2] nvme-tcp: always set valid seq_num in dhchap reply Mark O'Donovan
2023-08-29 11:48   ` Sagi Grimberg
2023-08-29 11:47 ` [PATCH 1/2] nvme-tcp: auth success1 msg always includes resp Sagi Grimberg
2023-08-29 23:37   ` Mark O'Donovan
2023-09-06 10:59 ` Hannes Reinecke
2023-09-12 11:39 ` Sagi Grimberg

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.