]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nvme-auth: Include SC_C in RVAL controller hash
authorAlistair Francis <alistair.francis@wdc.com>
Fri, 17 Apr 2026 00:50:48 +0000 (10:50 +1000)
committerKeith Busch <kbusch@kernel.org>
Wed, 22 Apr 2026 17:07:30 +0000 (10:07 -0700)
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: e88a7595b57f2 ("nvme-tcp: request secure channel concatenation")
Reviewed-by: Chris Leech <cleech@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/host/auth.c
drivers/nvme/target/auth.c

index bbedbe181c8a6361484a5bb875895d5f7e3adf75..63f543e80998566eade2b53a6412b53fccde45bc 100644 (file)
@@ -535,11 +535,12 @@ static int nvme_auth_dhchap_setup_ctrl_response(struct nvme_ctrl *ctrl,
        put_unaligned_le16(chap->transaction, buf);
        nvme_auth_hmac_update(&hmac, buf, 2);
 
-       memset(buf, 0, 4);
+       *buf = chap->sc_c;
        nvme_auth_hmac_update(&hmac, buf, 1);
        nvme_auth_hmac_update(&hmac, "Controller", 10);
        nvme_auth_hmac_update(&hmac, ctrl->opts->subsysnqn,
                              strlen(ctrl->opts->subsysnqn));
+       memset(buf, 0, 4);
        nvme_auth_hmac_update(&hmac, buf, 1);
        nvme_auth_hmac_update(&hmac, ctrl->opts->host->nqn,
                              strlen(ctrl->opts->host->nqn));
index 723b6d5604c1a08193eef402d8abc1e063f92c7c..c35c427ca2ac1bb007e5802a4b176c879a268e04 100644 (file)
@@ -399,11 +399,12 @@ int nvmet_auth_ctrl_hash(struct nvmet_req *req, u8 *response,
        put_unaligned_le16(req->sq->dhchap_tid, buf);
        nvme_auth_hmac_update(&hmac, buf, 2);
 
-       memset(buf, 0, 4);
+       *buf = req->sq->sc_c;
        nvme_auth_hmac_update(&hmac, buf, 1);
        nvme_auth_hmac_update(&hmac, "Controller", 10);
        nvme_auth_hmac_update(&hmac, ctrl->subsys->subsysnqn,
                              strlen(ctrl->subsys->subsysnqn));
+       memset(buf, 0, 4);
        nvme_auth_hmac_update(&hmac, buf, 1);
        nvme_auth_hmac_update(&hmac, ctrl->hostnqn, strlen(ctrl->hostnqn));
        nvme_auth_hmac_final(&hmac, response);