]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
nvmet-auth: update sc_c in host response
authorHannes Reinecke <hare@suse.de>
Wed, 22 Oct 2025 07:59:24 +0000 (09:59 +0200)
committerKeith Busch <kbusch@kernel.org>
Thu, 23 Oct 2025 00:28:18 +0000 (17:28 -0700)
The target code should set the sc_c bit in calculating the host response
based on the status of the 'concat' setting, otherwise we'll get an
authentication mismatch for hosts setting that bit correctly.

Fixes: 7e091add9c43 ("nvme-auth: update sc_c in host response")
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/target/auth.c

index b340380f38922abafc65f4a53fa7115f40f16bbc..ceba21684e82c51b08c62c76c02d8ee1dfd7847f 100644 (file)
@@ -298,7 +298,7 @@ int nvmet_auth_host_hash(struct nvmet_req *req, u8 *response,
        const char *hash_name;
        u8 *challenge = req->sq->dhchap_c1;
        struct nvme_dhchap_key *transformed_key;
-       u8 buf[4];
+       u8 buf[4], sc_c = ctrl->concat ? 1 : 0;
        int ret;
 
        hash_name = nvme_auth_hmac_name(ctrl->shash_id);
@@ -367,13 +367,14 @@ int nvmet_auth_host_hash(struct nvmet_req *req, u8 *response,
        ret = crypto_shash_update(shash, buf, 2);
        if (ret)
                goto out;
-       memset(buf, 0, 4);
+       *buf = sc_c;
        ret = crypto_shash_update(shash, buf, 1);
        if (ret)
                goto out;
        ret = crypto_shash_update(shash, "HostHost", 8);
        if (ret)
                goto out;
+       memset(buf, 0, 4);
        ret = crypto_shash_update(shash, ctrl->hostnqn, strlen(ctrl->hostnqn));
        if (ret)
                goto out;