Skip to content

Commit fc1e03e

Browse files
shifteekeithbusch
authored andcommitted
nvme-auth: add flag for bi-directional auth
Introduces an explicit variable for bi-directional auth. The currently used variable chap->s2 is incorrectly zeroed for uni-directional auth. That will be fixed in the next patch so this needs to change to avoid sending unexpected success2 messages Signed-off-by: Mark O'Donovan <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]>
1 parent 7527684 commit fc1e03e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/nvme/host/auth.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct nvme_dhchap_queue_context {
2929
int error;
3030
u32 s1;
3131
u32 s2;
32+
bool bi_directional;
3233
u16 transaction;
3334
u8 status;
3435
u8 dhgroup_id;
@@ -312,6 +313,7 @@ static int nvme_auth_set_dhchap_reply_data(struct nvme_ctrl *ctrl,
312313
data->dhvlen = cpu_to_le16(chap->host_key_len);
313314
memcpy(data->rval, chap->response, chap->hash_len);
314315
if (ctrl->ctrl_key) {
316+
chap->bi_directional = true;
315317
get_random_bytes(chap->c2, chap->hash_len);
316318
data->cvalid = 1;
317319
chap->s2 = nvme_auth_get_seqnum();
@@ -660,6 +662,7 @@ static void nvme_auth_reset_dhchap(struct nvme_dhchap_queue_context *chap)
660662
chap->error = 0;
661663
chap->s1 = 0;
662664
chap->s2 = 0;
665+
chap->bi_directional = false;
663666
chap->transaction = 0;
664667
memset(chap->c1, 0, sizeof(chap->c1));
665668
memset(chap->c2, 0, sizeof(chap->c2));
@@ -822,7 +825,7 @@ static void nvme_queue_auth_work(struct work_struct *work)
822825
goto fail2;
823826
}
824827

825-
if (chap->s2) {
828+
if (chap->bi_directional) {
826829
/* DH-HMAC-CHAP Step 5: send success2 */
827830
dev_dbg(ctrl->device, "%s: qid %d send success2\n",
828831
__func__, chap->qid);

0 commit comments

Comments
 (0)