lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKmqyKOuR4jyJyY3ypqMMbghBioG3u3xECJnsmM_sRtcOeeaug@mail.gmail.com>
Date: Thu, 6 Nov 2025 13:01:51 +1000
From: Alistair Francis <alistair23@...il.com>
To: Christoph Hellwig <hch@....de>
Cc: hare@...e.de, kbusch@...nel.org, axboe@...nel.dk, sagi@...mberg.me, 
	kch@...dia.com, linux-nvme@...ts.infradead.org, linux-kernel@...r.kernel.org, 
	Alistair Francis <alistair.francis@....com>
Subject: Re: [PATCH v2] nvmet-auth: update sc_c in target host hash calculation

On Wed, Nov 5, 2025 at 11:20 PM Christoph Hellwig <hch@....de> wrote:
>
> >  4 files changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c
> > index a01178caf15b..19980122d3d5 100644
> > --- a/drivers/nvme/host/auth.c
> > +++ b/drivers/nvme/host/auth.c
> > @@ -492,6 +492,7 @@ static int nvme_auth_dhchap_setup_host_response(struct nvme_ctrl *ctrl,
> >       ret = crypto_shash_update(shash, buf, 2);
> >       if (ret)
> >               goto out;
> > +     memset(buf, 0, sizeof(buf));
> >       *buf = chap->sc_c;
> >       ret = crypto_shash_update(shash, buf, 1);
>
> I'm really confused about both the existing code and this fixup.

Mostly just to keep the original style from the fixes commit from the host code.
7e091add9c43 ("nvme-auth: update sc_c in host response")

>
> Why isn't chap->sc_c directly passed to crypto_shash_update here?
> Why do we need to memset buf when only a single byte is passed to
> crypto_shash_update?
>
> >       ret = crypto_shash_update(shash, buf, 2);
> >       if (ret)
> >               goto out;
> > -     *buf = sc_c;
> > +     *buf = req->sq->sc_c;
> >       ret = crypto_shash_update(shash, buf, 1);
>
> Just pass it directly here?

We can directly pass it. The rest of the code is copying data into
`buf` so I went with that way as it matches the existing code. I feel
it also makes it clear that it's just a const input and we aren't
editing it in crypto_shash_update().

>
> >       if (ret)
> >               goto out;
> > @@ -378,6 +378,7 @@ int nvmet_auth_host_hash(struct nvmet_req *req, u8 *response,
> >       ret = crypto_shash_update(shash, ctrl->hostnqn, strlen(ctrl->hostnqn));
> >       if (ret)
> >               goto out;
> > +     memset(buf, 0, sizeof(buf));
> >       ret = crypto_shash_update(shash, buf, 1);
>
> just have a
>
>         sttic const u8 zero = 0;
>
> and use that here instead of the memset?

We don't actually need this memset at all, it's a mistake from my
rebase, I'll drop it.

Do you still want me to just directly pass req->sq->sc_c in?

Alistair

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ