Skip to content

Commit 4ae55a7

Browse files
mwilckkeithbusch
authored andcommitted
nvme-auth: use chap->s2 to indicate bidirectional authentication
Commit 546dea1 ("nvme-auth: check chap ctrl_key once constructed") replaced the condition "if (ctrl->ctrl_key)" (indicating bidirectional auth) by "if (chap->ctrl_key)", because ctrl->ctrl_key is a resource shared with sysfs. But chap->ctrl_key is set in nvme_auth_process_dhchap_challenge() depending on the DHVLEN in the DH-HMAC-CHAP Challenge message received from the controller, and will thus be non-NULL for every DH-HMAC-CHAP exchange, even if unidirectional auth was requested. This will lead to a protocol violation by sending a Success2 message in the unidirectional case (per NVMe base spec 2.0, the authentication transaction ends after the Success1 message for unidirectional auth). Use chap->s2 instead, which is non-zero if and only if the host requested bi-directional authentication from the controller. Fixes: 546dea1 ("nvme-auth: check chap ctrl_key once constructed") Signed-off-by: Martin Wilck <mwilck@suse.com> Reviewed-by: Daniel Wagner <dwagner@suse.de> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent d920abd commit 4ae55a7

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/nvme/host/auth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ static int nvme_auth_process_dhchap_success1(struct nvme_ctrl *ctrl,
341341
struct nvmf_auth_dhchap_success1_data *data = chap->buf;
342342
size_t size = sizeof(*data);
343343

344-
if (chap->ctrl_key)
344+
if (chap->s2)
345345
size += chap->hash_len;
346346

347347
if (size > CHAP_BUF_SIZE) {
@@ -825,7 +825,7 @@ static void nvme_queue_auth_work(struct work_struct *work)
825825
goto fail2;
826826
}
827827

828-
if (chap->ctrl_key) {
828+
if (chap->s2) {
829829
/* DH-HMAC-CHAP Step 5: send success2 */
830830
dev_dbg(ctrl->device, "%s: qid %d send success2\n",
831831
__func__, chap->qid);

0 commit comments

Comments
 (0)