Skip to content

Commit 159de7a

Browse files
alistair23keithbusch
authored andcommitted
nvmet-auth: update sc_c in target host hash calculation
Commit 7e091ad "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: 7e091ad ("nvme-auth: update sc_c in host response") Tested-by: Shin'ichiro Kawasaki <[email protected]> Tested-by: Yi Zhang <[email protected]> Reviewed-by: Martin George <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Alistair Francis <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 03b3bcd commit 159de7a

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

drivers/nvme/target/auth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ int nvmet_auth_host_hash(struct nvmet_req *req, u8 *response,
298298
const char *hash_name;
299299
u8 *challenge = req->sq->dhchap_c1;
300300
struct nvme_dhchap_key *transformed_key;
301-
u8 buf[4], sc_c = ctrl->concat ? 1 : 0;
301+
u8 buf[4];
302302
int ret;
303303

304304
hash_name = nvme_auth_hmac_name(ctrl->shash_id);
@@ -367,7 +367,7 @@ int nvmet_auth_host_hash(struct nvmet_req *req, u8 *response,
367367
ret = crypto_shash_update(shash, buf, 2);
368368
if (ret)
369369
goto out;
370-
*buf = sc_c;
370+
*buf = req->sq->sc_c;
371371
ret = crypto_shash_update(shash, buf, 1);
372372
if (ret)
373373
goto out;

drivers/nvme/target/fabrics-cmd-auth.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ static u8 nvmet_auth_negotiate(struct nvmet_req *req, void *d)
4343
data->auth_protocol[0].dhchap.halen,
4444
data->auth_protocol[0].dhchap.dhlen);
4545
req->sq->dhchap_tid = le16_to_cpu(data->t_id);
46+
req->sq->sc_c = data->sc_c;
4647
if (data->sc_c != NVME_AUTH_SECP_NOSC) {
4748
if (!IS_ENABLED(CONFIG_NVME_TARGET_TCP_TLS))
4849
return NVME_AUTH_DHCHAP_FAILURE_CONCAT_MISMATCH;

drivers/nvme/target/nvmet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ struct nvmet_sq {
159159
bool authenticated;
160160
struct delayed_work auth_expired_work;
161161
u16 dhchap_tid;
162+
u8 sc_c;
162163
u8 dhchap_status;
163164
u8 dhchap_step;
164165
u8 *dhchap_c1;

0 commit comments

Comments
 (0)