mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] nvme-auth: Include SC_C in RVAL controller hash
@ 2026-03-17  3:13 alistair23
  2026-03-18 16:40 ` Chris Leech
  0 siblings, 1 reply; 5+ messages in thread
From: alistair23 @ 2026-03-17  3:13 UTC (permalink / raw)
  To: hare, kbusch, axboe, hch, sagi, kch, linux-nvme, linux-kernel
  Cc: alistair23, Alistair Francis

From: Alistair Francis <alistair.francis@wdc.com>

Section 8.3.4.5.5 of the NVMe Base Specification 2.1 describes what is
included in the Response Value (RVAL) hash and SC_C should be included.
Currently we are hardcoding 0 instead of using the correct SC_C value.

Update the host and target code to use the SC_C when calculating the
RVAL instead of using 0.

Fixes: f50fff73d620 ("nvme: implement In-Band authentication")
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 drivers/nvme/host/auth.c   | 2 +-
 drivers/nvme/target/auth.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c
index 4e8e4ddd6c8d..4ea1a46bad94 100644
--- a/drivers/nvme/host/auth.c
+++ b/drivers/nvme/host/auth.c
@@ -581,7 +581,7 @@ static int nvme_auth_dhchap_setup_ctrl_response(struct nvme_ctrl *ctrl,
 	ret = crypto_shash_update(shash, buf, 2);
 	if (ret)
 		goto out;
-	memset(buf, 0, 4);
+	*buf = chap->sc_c;
 	ret = crypto_shash_update(shash, buf, 1);
 	if (ret)
 		goto out;
diff --git a/drivers/nvme/target/auth.c b/drivers/nvme/target/auth.c
index 839239fe877a..965690afd1bf 100644
--- a/drivers/nvme/target/auth.c
+++ b/drivers/nvme/target/auth.c
@@ -477,7 +477,7 @@ int nvmet_auth_ctrl_hash(struct nvmet_req *req, u8 *response,
 	ret = crypto_shash_update(shash, buf, 2);
 	if (ret)
 		goto out;
-	memset(buf, 0, 4);
+	*buf = req->sq->sc_c;
 	ret = crypto_shash_update(shash, buf, 1);
 	if (ret)
 		goto out;
-- 
2.53.0


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

* Re: [PATCH] nvme-auth: Include SC_C in RVAL controller hash
  2026-03-17  3:13 [PATCH] nvme-auth: Include SC_C in RVAL controller hash alistair23
@ 2026-03-18 16:40 ` Chris Leech
  2026-03-18 16:48   ` Hannes Reinecke
  2026-03-19  4:22   ` Alistair Francis
  0 siblings, 2 replies; 5+ messages in thread
From: Chris Leech @ 2026-03-18 16:40 UTC (permalink / raw)
  To: alistair23
  Cc: hare, kbusch, axboe, hch, sagi, kch, linux-nvme, linux-kernel,
	Alistair Francis

On Tue, Mar 17, 2026 at 01:13:30PM +1000, alistair23@gmail.com wrote:
> From: Alistair Francis <alistair.francis@wdc.com>
> 
> Section 8.3.4.5.5 of the NVMe Base Specification 2.1 describes what is
> included in the Response Value (RVAL) hash and SC_C should be included.
> Currently we are hardcoding 0 instead of using the correct SC_C value.
> 
> Update the host and target code to use the SC_C when calculating the
> RVAL instead of using 0.

Am I correct in reading this, the current kernel implementation is out
of spec when doing secure channel concatenation (SC_C != 0) with
bidirectional authentication (R1 takes SC_C into account, but not R2)?

- Chris


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

* Re: [PATCH] nvme-auth: Include SC_C in RVAL controller hash
  2026-03-18 16:40 ` Chris Leech
@ 2026-03-18 16:48   ` Hannes Reinecke
  2026-03-19  4:23     ` Alistair Francis
  2026-03-19  4:22   ` Alistair Francis
  1 sibling, 1 reply; 5+ messages in thread
From: Hannes Reinecke @ 2026-03-18 16:48 UTC (permalink / raw)
  To: Chris Leech, alistair23
  Cc: kbusch, axboe, hch, sagi, kch, linux-nvme, linux-kernel,
	Alistair Francis

On 3/18/26 17:40, Chris Leech wrote:
> On Tue, Mar 17, 2026 at 01:13:30PM +1000, alistair23@gmail.com wrote:
>> From: Alistair Francis <alistair.francis@wdc.com>
>>
>> Section 8.3.4.5.5 of the NVMe Base Specification 2.1 describes what is
>> included in the Response Value (RVAL) hash and SC_C should be included.
>> Currently we are hardcoding 0 instead of using the correct SC_C value.
>>
>> Update the host and target code to use the SC_C when calculating the
>> RVAL instead of using 0.
> 
> Am I correct in reading this, the current kernel implementation is out
> of spec when doing secure channel concatenation (SC_C != 0) with
> bidirectional authentication (R1 takes SC_C into account, but not R2)?
> 
I certainly never tested secure concatenation with bi-directional 
authentication (seem to have fallen into the same trap as Martin
George). So the chance of regression is rather small.
When you fix it, pleas add a test-case for blktests, too, such
that we extend test coverage for this particular corner-case.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare@suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich

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

* Re: [PATCH] nvme-auth: Include SC_C in RVAL controller hash
  2026-03-18 16:40 ` Chris Leech
  2026-03-18 16:48   ` Hannes Reinecke
@ 2026-03-19  4:22   ` Alistair Francis
  1 sibling, 0 replies; 5+ messages in thread
From: Alistair Francis @ 2026-03-19  4:22 UTC (permalink / raw)
  To: Chris Leech
  Cc: hare, kbusch, axboe, hch, sagi, kch, linux-nvme, linux-kernel,
	Alistair Francis

On Thu, Mar 19, 2026 at 2:40 AM Chris Leech <cleech@redhat.com> wrote:
>
> On Tue, Mar 17, 2026 at 01:13:30PM +1000, alistair23@gmail.com wrote:
> > From: Alistair Francis <alistair.francis@wdc.com>
> >
> > Section 8.3.4.5.5 of the NVMe Base Specification 2.1 describes what is
> > included in the Response Value (RVAL) hash and SC_C should be included.
> > Currently we are hardcoding 0 instead of using the correct SC_C value.
> >
> > Update the host and target code to use the SC_C when calculating the
> > RVAL instead of using 0.
>
> Am I correct in reading this, the current kernel implementation is out
> of spec when doing secure channel concatenation (SC_C != 0) with
> bidirectional authentication (R1 takes SC_C into account, but not R2)?

Correct, SC_C isn't included in the RVAL. So if SC_C is 0 it works,
but if it's 1 it doesn't work

Alistair

>
> - Chris
>

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

* Re: [PATCH] nvme-auth: Include SC_C in RVAL controller hash
  2026-03-18 16:48   ` Hannes Reinecke
@ 2026-03-19  4:23     ` Alistair Francis
  0 siblings, 0 replies; 5+ messages in thread
From: Alistair Francis @ 2026-03-19  4:23 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Chris Leech, kbusch, axboe, hch, sagi, kch, linux-nvme,
	linux-kernel, Alistair Francis

On Thu, Mar 19, 2026 at 2:48 AM Hannes Reinecke <hare@suse.de> wrote:
>
> On 3/18/26 17:40, Chris Leech wrote:
> > On Tue, Mar 17, 2026 at 01:13:30PM +1000, alistair23@gmail.com wrote:
> >> From: Alistair Francis <alistair.francis@wdc.com>
> >>
> >> Section 8.3.4.5.5 of the NVMe Base Specification 2.1 describes what is
> >> included in the Response Value (RVAL) hash and SC_C should be included.
> >> Currently we are hardcoding 0 instead of using the correct SC_C value.
> >>
> >> Update the host and target code to use the SC_C when calculating the
> >> RVAL instead of using 0.
> >
> > Am I correct in reading this, the current kernel implementation is out
> > of spec when doing secure channel concatenation (SC_C != 0) with
> > bidirectional authentication (R1 takes SC_C into account, but not R2)?
> >
> I certainly never tested secure concatenation with bi-directional
> authentication (seem to have fallen into the same trap as Martin
> George). So the chance of regression is rather small.
> When you fix it, pleas add a test-case for blktests, too, such
> that we extend test coverage for this particular corner-case.

Ok, I'll add a blktest test-case

Alistair

>
> Cheers,
>
> Hannes
> --
> Dr. Hannes Reinecke                  Kernel Storage Architect
> hare@suse.de                                +49 911 74053 688
> SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
> HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich

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

end of thread, other threads:[~2026-03-19  4:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-17  3:13 [PATCH] nvme-auth: Include SC_C in RVAL controller hash alistair23
2026-03-18 16:40 ` Chris Leech
2026-03-18 16:48   ` Hannes Reinecke
2026-03-19  4:23     ` Alistair Francis
2026-03-19  4:22   ` Alistair Francis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®