Skip to content

Commit 6f66d04

Browse files
shifteekeithbusch
authored andcommitted
nvme-auth: always set valid seq_num in dhchap reply
Currently a seqnum of zero is sent during uni-directional authentication. The zero value is reserved for the secure channel feature which is not yet implemented. Relevant extract from the spec: The value 0h is used to indicate that bidirectional authentication is not performed, but a challenge value C2 is carried in order to generate a pre-shared key (PSK) for subsequent establishment of a secure channel Signed-off-by: Mark O'Donovan <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]>
1 parent fc1e03e commit 6f66d04

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

drivers/nvme/host/auth.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,14 @@ static int nvme_auth_set_dhchap_reply_data(struct nvme_ctrl *ctrl,
316316
chap->bi_directional = true;
317317
get_random_bytes(chap->c2, chap->hash_len);
318318
data->cvalid = 1;
319-
chap->s2 = nvme_auth_get_seqnum();
320319
memcpy(data->rval + chap->hash_len, chap->c2,
321320
chap->hash_len);
322321
dev_dbg(ctrl->device, "%s: qid %d ctrl challenge %*ph\n",
323322
__func__, chap->qid, (int)chap->hash_len, chap->c2);
324323
} else {
325324
memset(chap->c2, 0, chap->hash_len);
326-
chap->s2 = 0;
327325
}
326+
chap->s2 = nvme_auth_get_seqnum();
328327
data->seqnum = cpu_to_le32(chap->s2);
329328
if (chap->host_key_len) {
330329
dev_dbg(ctrl->device, "%s: qid %d host public key %*ph\n",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ static u16 nvmet_auth_reply(struct nvmet_req *req, void *d)
163163
pr_debug("%s: ctrl %d qid %d challenge %*ph\n",
164164
__func__, ctrl->cntlid, req->sq->qid, data->hl,
165165
req->sq->dhchap_c2);
166-
req->sq->dhchap_s2 = le32_to_cpu(data->seqnum);
167166
} else {
168167
req->sq->authenticated = true;
169168
req->sq->dhchap_c2 = NULL;
170169
}
170+
req->sq->dhchap_s2 = le32_to_cpu(data->seqnum);
171171

172172
return 0;
173173
}

0 commit comments

Comments
 (0)