]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
nvmet-auth: update sc_c in target host hash calculation
authorAlistair Francis <alistair.francis@wdc.com>
Thu, 6 Nov 2025 23:17:11 +0000 (09:17 +1000)
committerKeith Busch <kbusch@kernel.org>
Mon, 17 Nov 2025 16:05:58 +0000 (08:05 -0800)
Commit 7e091add9c43 "nvme-auth: update sc_c in host response" added
the sc_c variable to the dhchap queue context structure which is
appropriately set during negotiate and then used in the host response.

This breaks secure concat connections with a Linux target as the target
code wasn't updated at the same time. This patch fixes this by adding a
new sc_c variable to the host hash calculations.

Fixes: 7e091add9c43 ("nvme-auth: update sc_c in host response")
Tested-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Tested-by: Yi Zhang <yi.zhang@redhat.com>
Reviewed-by: Martin George <marting@netapp.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
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/target/auth.c
drivers/nvme/target/fabrics-cmd-auth.c
drivers/nvme/target/nvmet.h

index ceba21684e82c51b08c62c76c02d8ee1dfd7847f..300d5e032f6d43a0ab258f27edeeae3a0b68994d 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], sc_c = ctrl->concat ? 1 : 0;
+       u8 buf[4];
        int ret;
 
        hash_name = nvme_auth_hmac_name(ctrl->shash_id);
@@ -367,7 +367,7 @@ int nvmet_auth_host_hash(struct nvmet_req *req, u8 *response,
        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);
        if (ret)
                goto out;
index bf01ec414c55f785dfa398a83589ea2d13d7f2bf..5946681cb0e322d4d1e4b1c24d78f9a759767bd5 100644 (file)
@@ -43,6 +43,7 @@ static u8 nvmet_auth_negotiate(struct nvmet_req *req, void *d)
                 data->auth_protocol[0].dhchap.halen,
                 data->auth_protocol[0].dhchap.dhlen);
        req->sq->dhchap_tid = le16_to_cpu(data->t_id);
+       req->sq->sc_c = data->sc_c;
        if (data->sc_c != NVME_AUTH_SECP_NOSC) {
                if (!IS_ENABLED(CONFIG_NVME_TARGET_TCP_TLS))
                        return NVME_AUTH_DHCHAP_FAILURE_CONCAT_MISMATCH;
index 51df72f5e89b72a271ea54124a946fdce94fbc89..f3b09f4099f086972512668d01c3f4682632caea 100644 (file)
@@ -159,6 +159,7 @@ struct nvmet_sq {
        bool                    authenticated;
        struct delayed_work     auth_expired_work;
        u16                     dhchap_tid;
+       u8                      sc_c;
        u8                      dhchap_status;
        u8                      dhchap_step;
        u8                      *dhchap_c1;