Lines Matching refs:chap
110 struct nvme_dhchap_queue_context *chap) in nvme_auth_set_dhchap_negotiate_data() argument
112 struct nvmf_auth_dhchap_negotiate_data *data = chap->buf; in nvme_auth_set_dhchap_negotiate_data()
115 if (chap->buf_size < size) { in nvme_auth_set_dhchap_negotiate_data()
116 chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD; in nvme_auth_set_dhchap_negotiate_data()
119 memset((u8 *)chap->buf, 0, size); in nvme_auth_set_dhchap_negotiate_data()
122 data->t_id = cpu_to_le16(chap->transaction); in nvme_auth_set_dhchap_negotiate_data()
142 struct nvme_dhchap_queue_context *chap) in nvme_auth_process_dhchap_challenge() argument
144 struct nvmf_auth_dhchap_challenge_data *data = chap->buf; in nvme_auth_process_dhchap_challenge()
150 if (chap->buf_size < size) { in nvme_auth_process_dhchap_challenge()
151 chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD; in nvme_auth_process_dhchap_challenge()
159 chap->qid, data->hashid); in nvme_auth_process_dhchap_challenge()
160 chap->status = NVME_AUTH_DHCHAP_FAILURE_HASH_UNUSABLE; in nvme_auth_process_dhchap_challenge()
164 if (chap->hash_id == data->hashid && chap->shash_tfm && in nvme_auth_process_dhchap_challenge()
165 !strcmp(crypto_shash_alg_name(chap->shash_tfm), hmac_name) && in nvme_auth_process_dhchap_challenge()
166 crypto_shash_digestsize(chap->shash_tfm) == data->hl) { in nvme_auth_process_dhchap_challenge()
169 chap->qid, hmac_name); in nvme_auth_process_dhchap_challenge()
174 if (chap->shash_tfm) { in nvme_auth_process_dhchap_challenge()
175 crypto_free_shash(chap->shash_tfm); in nvme_auth_process_dhchap_challenge()
176 chap->hash_id = 0; in nvme_auth_process_dhchap_challenge()
177 chap->hash_len = 0; in nvme_auth_process_dhchap_challenge()
179 chap->shash_tfm = crypto_alloc_shash(hmac_name, 0, in nvme_auth_process_dhchap_challenge()
181 if (IS_ERR(chap->shash_tfm)) { in nvme_auth_process_dhchap_challenge()
184 chap->qid, hmac_name, PTR_ERR(chap->shash_tfm)); in nvme_auth_process_dhchap_challenge()
185 chap->shash_tfm = NULL; in nvme_auth_process_dhchap_challenge()
186 chap->status = NVME_AUTH_DHCHAP_FAILURE_FAILED; in nvme_auth_process_dhchap_challenge()
190 if (crypto_shash_digestsize(chap->shash_tfm) != data->hl) { in nvme_auth_process_dhchap_challenge()
193 chap->qid, data->hl); in nvme_auth_process_dhchap_challenge()
194 crypto_free_shash(chap->shash_tfm); in nvme_auth_process_dhchap_challenge()
195 chap->shash_tfm = NULL; in nvme_auth_process_dhchap_challenge()
196 chap->status = NVME_AUTH_DHCHAP_FAILURE_HASH_UNUSABLE; in nvme_auth_process_dhchap_challenge()
201 if (chap->hash_id != data->hashid) { in nvme_auth_process_dhchap_challenge()
202 kfree(chap->host_response); in nvme_auth_process_dhchap_challenge()
203 chap->host_response = NULL; in nvme_auth_process_dhchap_challenge()
206 chap->hash_id = data->hashid; in nvme_auth_process_dhchap_challenge()
207 chap->hash_len = data->hl; in nvme_auth_process_dhchap_challenge()
209 chap->qid, hmac_name); in nvme_auth_process_dhchap_challenge()
216 chap->qid, data->dhgid); in nvme_auth_process_dhchap_challenge()
217 chap->status = NVME_AUTH_DHCHAP_FAILURE_DHGROUP_UNUSABLE; in nvme_auth_process_dhchap_challenge()
223 kfree_sensitive(chap->host_key); in nvme_auth_process_dhchap_challenge()
224 chap->host_key = NULL; in nvme_auth_process_dhchap_challenge()
225 chap->host_key_len = 0; in nvme_auth_process_dhchap_challenge()
226 kfree_sensitive(chap->ctrl_key); in nvme_auth_process_dhchap_challenge()
227 chap->ctrl_key = NULL; in nvme_auth_process_dhchap_challenge()
228 chap->ctrl_key_len = 0; in nvme_auth_process_dhchap_challenge()
230 if (chap->dhgroup_id == data->dhgid && in nvme_auth_process_dhchap_challenge()
231 (data->dhgid == NVME_AUTH_DHGROUP_NULL || chap->dh_tfm)) { in nvme_auth_process_dhchap_challenge()
234 chap->qid, gid_name); in nvme_auth_process_dhchap_challenge()
239 if (chap->dh_tfm) { in nvme_auth_process_dhchap_challenge()
240 crypto_free_kpp(chap->dh_tfm); in nvme_auth_process_dhchap_challenge()
241 chap->dh_tfm = NULL; in nvme_auth_process_dhchap_challenge()
248 chap->qid); in nvme_auth_process_dhchap_challenge()
249 chap->status = NVME_AUTH_DHCHAP_FAILURE_DHGROUP_UNUSABLE; in nvme_auth_process_dhchap_challenge()
253 chap->dh_tfm = crypto_alloc_kpp(kpp_name, 0, 0); in nvme_auth_process_dhchap_challenge()
254 if (IS_ERR(chap->dh_tfm)) { in nvme_auth_process_dhchap_challenge()
255 int ret = PTR_ERR(chap->dh_tfm); in nvme_auth_process_dhchap_challenge()
259 chap->qid, ret, gid_name); in nvme_auth_process_dhchap_challenge()
260 chap->status = NVME_AUTH_DHCHAP_FAILURE_DHGROUP_UNUSABLE; in nvme_auth_process_dhchap_challenge()
261 chap->dh_tfm = NULL; in nvme_auth_process_dhchap_challenge()
265 chap->qid, gid_name); in nvme_auth_process_dhchap_challenge()
269 chap->qid); in nvme_auth_process_dhchap_challenge()
270 chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD; in nvme_auth_process_dhchap_challenge()
273 chap->dhgroup_id = data->dhgid; in nvme_auth_process_dhchap_challenge()
276 chap->s1 = le32_to_cpu(data->seqnum); in nvme_auth_process_dhchap_challenge()
277 memcpy(chap->c1, data->cval, chap->hash_len); in nvme_auth_process_dhchap_challenge()
279 chap->ctrl_key = kmalloc(dhvlen, GFP_KERNEL); in nvme_auth_process_dhchap_challenge()
280 if (!chap->ctrl_key) { in nvme_auth_process_dhchap_challenge()
281 chap->status = NVME_AUTH_DHCHAP_FAILURE_FAILED; in nvme_auth_process_dhchap_challenge()
284 chap->ctrl_key_len = dhvlen; in nvme_auth_process_dhchap_challenge()
285 memcpy(chap->ctrl_key, data->cval + chap->hash_len, in nvme_auth_process_dhchap_challenge()
288 (int)chap->ctrl_key_len, chap->ctrl_key); in nvme_auth_process_dhchap_challenge()
295 struct nvme_dhchap_queue_context *chap) in nvme_auth_set_dhchap_reply_data() argument
297 struct nvmf_auth_dhchap_reply_data *data = chap->buf; in nvme_auth_set_dhchap_reply_data()
300 size += 2 * chap->hash_len; in nvme_auth_set_dhchap_reply_data()
302 if (chap->host_key_len) in nvme_auth_set_dhchap_reply_data()
303 size += chap->host_key_len; in nvme_auth_set_dhchap_reply_data()
305 if (chap->buf_size < size) { in nvme_auth_set_dhchap_reply_data()
306 chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD; in nvme_auth_set_dhchap_reply_data()
310 memset(chap->buf, 0, size); in nvme_auth_set_dhchap_reply_data()
313 data->t_id = cpu_to_le16(chap->transaction); in nvme_auth_set_dhchap_reply_data()
314 data->hl = chap->hash_len; in nvme_auth_set_dhchap_reply_data()
315 data->dhvlen = cpu_to_le16(chap->host_key_len); in nvme_auth_set_dhchap_reply_data()
316 memcpy(data->rval, chap->response, chap->hash_len); in nvme_auth_set_dhchap_reply_data()
318 get_random_bytes(chap->c2, chap->hash_len); in nvme_auth_set_dhchap_reply_data()
320 chap->s2 = nvme_auth_get_seqnum(); in nvme_auth_set_dhchap_reply_data()
321 memcpy(data->rval + chap->hash_len, chap->c2, in nvme_auth_set_dhchap_reply_data()
322 chap->hash_len); in nvme_auth_set_dhchap_reply_data()
324 __func__, chap->qid, (int)chap->hash_len, chap->c2); in nvme_auth_set_dhchap_reply_data()
326 memset(chap->c2, 0, chap->hash_len); in nvme_auth_set_dhchap_reply_data()
327 chap->s2 = 0; in nvme_auth_set_dhchap_reply_data()
329 data->seqnum = cpu_to_le32(chap->s2); in nvme_auth_set_dhchap_reply_data()
330 if (chap->host_key_len) { in nvme_auth_set_dhchap_reply_data()
332 __func__, chap->qid, in nvme_auth_set_dhchap_reply_data()
333 chap->host_key_len, chap->host_key); in nvme_auth_set_dhchap_reply_data()
334 memcpy(data->rval + 2 * chap->hash_len, chap->host_key, in nvme_auth_set_dhchap_reply_data()
335 chap->host_key_len); in nvme_auth_set_dhchap_reply_data()
342 struct nvme_dhchap_queue_context *chap) in nvme_auth_process_dhchap_success1() argument
344 struct nvmf_auth_dhchap_success1_data *data = chap->buf; in nvme_auth_process_dhchap_success1()
348 size += chap->hash_len; in nvme_auth_process_dhchap_success1()
350 if (chap->buf_size < size) { in nvme_auth_process_dhchap_success1()
351 chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD; in nvme_auth_process_dhchap_success1()
355 if (data->hl != chap->hash_len) { in nvme_auth_process_dhchap_success1()
358 chap->qid, data->hl); in nvme_auth_process_dhchap_success1()
359 chap->status = NVME_AUTH_DHCHAP_FAILURE_HASH_UNUSABLE; in nvme_auth_process_dhchap_success1()
364 if (chap->qid == 0) in nvme_auth_process_dhchap_success1()
367 nvme_auth_hmac_name(chap->hash_id), in nvme_auth_process_dhchap_success1()
368 nvme_auth_dhgroup_name(chap->dhgroup_id)); in nvme_auth_process_dhchap_success1()
374 if (memcmp(chap->response, data->rval, data->hl)) { in nvme_auth_process_dhchap_success1()
376 __func__, chap->qid, (int)chap->hash_len, data->rval); in nvme_auth_process_dhchap_success1()
378 __func__, chap->qid, (int)chap->hash_len, in nvme_auth_process_dhchap_success1()
379 chap->response); in nvme_auth_process_dhchap_success1()
382 chap->qid); in nvme_auth_process_dhchap_success1()
383 chap->status = NVME_AUTH_DHCHAP_FAILURE_FAILED; in nvme_auth_process_dhchap_success1()
388 if (chap->qid == 0) in nvme_auth_process_dhchap_success1()
395 struct nvme_dhchap_queue_context *chap) in nvme_auth_set_dhchap_success2_data() argument
397 struct nvmf_auth_dhchap_success2_data *data = chap->buf; in nvme_auth_set_dhchap_success2_data()
400 memset(chap->buf, 0, size); in nvme_auth_set_dhchap_success2_data()
403 data->t_id = cpu_to_le16(chap->transaction); in nvme_auth_set_dhchap_success2_data()
409 struct nvme_dhchap_queue_context *chap) in nvme_auth_set_dhchap_failure2_data() argument
411 struct nvmf_auth_dhchap_failure_data *data = chap->buf; in nvme_auth_set_dhchap_failure2_data()
414 memset(chap->buf, 0, size); in nvme_auth_set_dhchap_failure2_data()
417 data->t_id = cpu_to_le16(chap->transaction); in nvme_auth_set_dhchap_failure2_data()
419 data->rescode_exp = chap->status; in nvme_auth_set_dhchap_failure2_data()
425 struct nvme_dhchap_queue_context *chap) in nvme_auth_dhchap_setup_host_response() argument
427 SHASH_DESC_ON_STACK(shash, chap->shash_tfm); in nvme_auth_dhchap_setup_host_response()
428 u8 buf[4], *challenge = chap->c1; in nvme_auth_dhchap_setup_host_response()
432 __func__, chap->qid, chap->s1, chap->transaction); in nvme_auth_dhchap_setup_host_response()
434 if (!chap->host_response) { in nvme_auth_dhchap_setup_host_response()
435 chap->host_response = nvme_auth_transform_key(ctrl->host_key, in nvme_auth_dhchap_setup_host_response()
437 if (IS_ERR(chap->host_response)) { in nvme_auth_dhchap_setup_host_response()
438 ret = PTR_ERR(chap->host_response); in nvme_auth_dhchap_setup_host_response()
439 chap->host_response = NULL; in nvme_auth_dhchap_setup_host_response()
444 __func__, chap->qid); in nvme_auth_dhchap_setup_host_response()
447 ret = crypto_shash_setkey(chap->shash_tfm, in nvme_auth_dhchap_setup_host_response()
448 chap->host_response, ctrl->host_key->len); in nvme_auth_dhchap_setup_host_response()
451 chap->qid, ret); in nvme_auth_dhchap_setup_host_response()
455 if (chap->dh_tfm) { in nvme_auth_dhchap_setup_host_response()
456 challenge = kmalloc(chap->hash_len, GFP_KERNEL); in nvme_auth_dhchap_setup_host_response()
461 ret = nvme_auth_augmented_challenge(chap->hash_id, in nvme_auth_dhchap_setup_host_response()
462 chap->sess_key, in nvme_auth_dhchap_setup_host_response()
463 chap->sess_key_len, in nvme_auth_dhchap_setup_host_response()
464 chap->c1, challenge, in nvme_auth_dhchap_setup_host_response()
465 chap->hash_len); in nvme_auth_dhchap_setup_host_response()
470 shash->tfm = chap->shash_tfm; in nvme_auth_dhchap_setup_host_response()
474 ret = crypto_shash_update(shash, challenge, chap->hash_len); in nvme_auth_dhchap_setup_host_response()
477 put_unaligned_le32(chap->s1, buf); in nvme_auth_dhchap_setup_host_response()
481 put_unaligned_le16(chap->transaction, buf); in nvme_auth_dhchap_setup_host_response()
503 ret = crypto_shash_final(shash, chap->response); in nvme_auth_dhchap_setup_host_response()
505 if (challenge != chap->c1) in nvme_auth_dhchap_setup_host_response()
511 struct nvme_dhchap_queue_context *chap) in nvme_auth_dhchap_setup_ctrl_response() argument
513 SHASH_DESC_ON_STACK(shash, chap->shash_tfm); in nvme_auth_dhchap_setup_ctrl_response()
515 u8 buf[4], *challenge = chap->c2; in nvme_auth_dhchap_setup_ctrl_response()
524 ret = crypto_shash_setkey(chap->shash_tfm, in nvme_auth_dhchap_setup_ctrl_response()
528 chap->qid, ret); in nvme_auth_dhchap_setup_ctrl_response()
532 if (chap->dh_tfm) { in nvme_auth_dhchap_setup_ctrl_response()
533 challenge = kmalloc(chap->hash_len, GFP_KERNEL); in nvme_auth_dhchap_setup_ctrl_response()
538 ret = nvme_auth_augmented_challenge(chap->hash_id, in nvme_auth_dhchap_setup_ctrl_response()
539 chap->sess_key, in nvme_auth_dhchap_setup_ctrl_response()
540 chap->sess_key_len, in nvme_auth_dhchap_setup_ctrl_response()
541 chap->c2, challenge, in nvme_auth_dhchap_setup_ctrl_response()
542 chap->hash_len); in nvme_auth_dhchap_setup_ctrl_response()
547 __func__, chap->qid, chap->s2, chap->transaction); in nvme_auth_dhchap_setup_ctrl_response()
549 __func__, chap->qid, (int)chap->hash_len, challenge); in nvme_auth_dhchap_setup_ctrl_response()
551 __func__, chap->qid, ctrl->opts->subsysnqn); in nvme_auth_dhchap_setup_ctrl_response()
553 __func__, chap->qid, ctrl->opts->host->nqn); in nvme_auth_dhchap_setup_ctrl_response()
554 shash->tfm = chap->shash_tfm; in nvme_auth_dhchap_setup_ctrl_response()
558 ret = crypto_shash_update(shash, challenge, chap->hash_len); in nvme_auth_dhchap_setup_ctrl_response()
561 put_unaligned_le32(chap->s2, buf); in nvme_auth_dhchap_setup_ctrl_response()
565 put_unaligned_le16(chap->transaction, buf); in nvme_auth_dhchap_setup_ctrl_response()
587 ret = crypto_shash_final(shash, chap->response); in nvme_auth_dhchap_setup_ctrl_response()
589 if (challenge != chap->c2) in nvme_auth_dhchap_setup_ctrl_response()
596 struct nvme_dhchap_queue_context *chap) in nvme_auth_dhchap_exponential() argument
600 if (chap->host_key && chap->host_key_len) { in nvme_auth_dhchap_exponential()
602 "qid %d: reusing host key\n", chap->qid); in nvme_auth_dhchap_exponential()
605 ret = nvme_auth_gen_privkey(chap->dh_tfm, chap->dhgroup_id); in nvme_auth_dhchap_exponential()
607 chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD; in nvme_auth_dhchap_exponential()
611 chap->host_key_len = crypto_kpp_maxsize(chap->dh_tfm); in nvme_auth_dhchap_exponential()
613 chap->host_key = kzalloc(chap->host_key_len, GFP_KERNEL); in nvme_auth_dhchap_exponential()
614 if (!chap->host_key) { in nvme_auth_dhchap_exponential()
615 chap->host_key_len = 0; in nvme_auth_dhchap_exponential()
616 chap->status = NVME_AUTH_DHCHAP_FAILURE_FAILED; in nvme_auth_dhchap_exponential()
619 ret = nvme_auth_gen_pubkey(chap->dh_tfm, in nvme_auth_dhchap_exponential()
620 chap->host_key, chap->host_key_len); in nvme_auth_dhchap_exponential()
624 kfree(chap->host_key); in nvme_auth_dhchap_exponential()
625 chap->host_key = NULL; in nvme_auth_dhchap_exponential()
626 chap->host_key_len = 0; in nvme_auth_dhchap_exponential()
627 chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD; in nvme_auth_dhchap_exponential()
632 chap->sess_key_len = chap->host_key_len; in nvme_auth_dhchap_exponential()
633 chap->sess_key = kmalloc(chap->sess_key_len, GFP_KERNEL); in nvme_auth_dhchap_exponential()
634 if (!chap->sess_key) { in nvme_auth_dhchap_exponential()
635 chap->sess_key_len = 0; in nvme_auth_dhchap_exponential()
636 chap->status = NVME_AUTH_DHCHAP_FAILURE_FAILED; in nvme_auth_dhchap_exponential()
640 ret = nvme_auth_gen_shared_secret(chap->dh_tfm, in nvme_auth_dhchap_exponential()
641 chap->ctrl_key, chap->ctrl_key_len, in nvme_auth_dhchap_exponential()
642 chap->sess_key, chap->sess_key_len); in nvme_auth_dhchap_exponential()
646 kfree_sensitive(chap->sess_key); in nvme_auth_dhchap_exponential()
647 chap->sess_key = NULL; in nvme_auth_dhchap_exponential()
648 chap->sess_key_len = 0; in nvme_auth_dhchap_exponential()
649 chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD; in nvme_auth_dhchap_exponential()
653 (int)chap->sess_key_len, chap->sess_key); in nvme_auth_dhchap_exponential()
657 static void __nvme_auth_reset(struct nvme_dhchap_queue_context *chap) in __nvme_auth_reset() argument
659 kfree_sensitive(chap->host_response); in __nvme_auth_reset()
660 chap->host_response = NULL; in __nvme_auth_reset()
661 kfree_sensitive(chap->host_key); in __nvme_auth_reset()
662 chap->host_key = NULL; in __nvme_auth_reset()
663 chap->host_key_len = 0; in __nvme_auth_reset()
664 kfree_sensitive(chap->ctrl_key); in __nvme_auth_reset()
665 chap->ctrl_key = NULL; in __nvme_auth_reset()
666 chap->ctrl_key_len = 0; in __nvme_auth_reset()
667 kfree_sensitive(chap->sess_key); in __nvme_auth_reset()
668 chap->sess_key = NULL; in __nvme_auth_reset()
669 chap->sess_key_len = 0; in __nvme_auth_reset()
670 chap->status = 0; in __nvme_auth_reset()
671 chap->error = 0; in __nvme_auth_reset()
672 chap->s1 = 0; in __nvme_auth_reset()
673 chap->s2 = 0; in __nvme_auth_reset()
674 chap->transaction = 0; in __nvme_auth_reset()
675 memset(chap->c1, 0, sizeof(chap->c1)); in __nvme_auth_reset()
676 memset(chap->c2, 0, sizeof(chap->c2)); in __nvme_auth_reset()
679 static void __nvme_auth_free(struct nvme_dhchap_queue_context *chap) in __nvme_auth_free() argument
681 __nvme_auth_reset(chap); in __nvme_auth_free()
682 if (chap->shash_tfm) in __nvme_auth_free()
683 crypto_free_shash(chap->shash_tfm); in __nvme_auth_free()
684 if (chap->dh_tfm) in __nvme_auth_free()
685 crypto_free_kpp(chap->dh_tfm); in __nvme_auth_free()
686 kfree_sensitive(chap->ctrl_key); in __nvme_auth_free()
687 kfree_sensitive(chap->host_key); in __nvme_auth_free()
688 kfree_sensitive(chap->sess_key); in __nvme_auth_free()
689 kfree_sensitive(chap->host_response); in __nvme_auth_free()
690 kfree(chap->buf); in __nvme_auth_free()
691 kfree(chap); in __nvme_auth_free()
696 struct nvme_dhchap_queue_context *chap = in __nvme_auth_work() local
698 struct nvme_ctrl *ctrl = chap->ctrl; in __nvme_auth_work()
702 chap->transaction = ctrl->transaction++; in __nvme_auth_work()
706 __func__, chap->qid); in __nvme_auth_work()
707 ret = nvme_auth_set_dhchap_negotiate_data(ctrl, chap); in __nvme_auth_work()
709 chap->error = ret; in __nvme_auth_work()
713 ret = nvme_auth_submit(ctrl, chap->qid, chap->buf, tl, true); in __nvme_auth_work()
715 chap->error = ret; in __nvme_auth_work()
721 __func__, chap->qid); in __nvme_auth_work()
723 memset(chap->buf, 0, chap->buf_size); in __nvme_auth_work()
724 ret = nvme_auth_submit(ctrl, chap->qid, chap->buf, chap->buf_size, false); in __nvme_auth_work()
728 chap->qid, ret < 0 ? "error" : "nvme status", ret); in __nvme_auth_work()
729 chap->error = ret; in __nvme_auth_work()
732 ret = nvme_auth_receive_validate(ctrl, chap->qid, chap->buf, chap->transaction, in __nvme_auth_work()
735 chap->status = ret; in __nvme_auth_work()
736 chap->error = NVME_SC_AUTH_REQUIRED; in __nvme_auth_work()
740 ret = nvme_auth_process_dhchap_challenge(ctrl, chap); in __nvme_auth_work()
743 chap->error = ret; in __nvme_auth_work()
747 if (chap->ctrl_key_len) { in __nvme_auth_work()
750 __func__, chap->qid); in __nvme_auth_work()
751 ret = nvme_auth_dhchap_exponential(ctrl, chap); in __nvme_auth_work()
753 chap->error = ret; in __nvme_auth_work()
759 __func__, chap->qid); in __nvme_auth_work()
760 ret = nvme_auth_dhchap_setup_host_response(ctrl, chap); in __nvme_auth_work()
762 chap->error = ret; in __nvme_auth_work()
768 __func__, chap->qid); in __nvme_auth_work()
769 ret = nvme_auth_set_dhchap_reply_data(ctrl, chap); in __nvme_auth_work()
771 chap->error = ret; in __nvme_auth_work()
776 ret = nvme_auth_submit(ctrl, chap->qid, chap->buf, tl, true); in __nvme_auth_work()
778 chap->error = ret; in __nvme_auth_work()
784 __func__, chap->qid); in __nvme_auth_work()
786 memset(chap->buf, 0, chap->buf_size); in __nvme_auth_work()
787 ret = nvme_auth_submit(ctrl, chap->qid, chap->buf, chap->buf_size, false); in __nvme_auth_work()
791 chap->qid, ret < 0 ? "error" : "nvme status", ret); in __nvme_auth_work()
792 chap->error = ret; in __nvme_auth_work()
795 ret = nvme_auth_receive_validate(ctrl, chap->qid, in __nvme_auth_work()
796 chap->buf, chap->transaction, in __nvme_auth_work()
799 chap->status = ret; in __nvme_auth_work()
800 chap->error = NVME_SC_AUTH_REQUIRED; in __nvme_auth_work()
807 __func__, chap->qid); in __nvme_auth_work()
808 ret = nvme_auth_dhchap_setup_ctrl_response(ctrl, chap); in __nvme_auth_work()
810 chap->error = ret; in __nvme_auth_work()
815 ret = nvme_auth_process_dhchap_success1(ctrl, chap); in __nvme_auth_work()
818 chap->error = NVME_SC_AUTH_REQUIRED; in __nvme_auth_work()
825 __func__, chap->qid); in __nvme_auth_work()
826 tl = nvme_auth_set_dhchap_success2_data(ctrl, chap); in __nvme_auth_work()
827 ret = nvme_auth_submit(ctrl, chap->qid, chap->buf, tl, true); in __nvme_auth_work()
829 chap->error = ret; in __nvme_auth_work()
832 chap->error = 0; in __nvme_auth_work()
838 __func__, chap->qid, chap->status); in __nvme_auth_work()
839 tl = nvme_auth_set_dhchap_failure2_data(ctrl, chap); in __nvme_auth_work()
840 ret = nvme_auth_submit(ctrl, chap->qid, chap->buf, tl, true); in __nvme_auth_work()
845 if (ret && !chap->error) in __nvme_auth_work()
846 chap->error = ret; in __nvme_auth_work()
851 struct nvme_dhchap_queue_context *chap; in nvme_auth_negotiate() local
865 list_for_each_entry(chap, &ctrl->dhchap_auth_list, entry) { in nvme_auth_negotiate()
866 WARN_ON(!chap->buf); in nvme_auth_negotiate()
867 if (chap->qid == qid) { in nvme_auth_negotiate()
870 flush_work(&chap->auth_work); in nvme_auth_negotiate()
871 __nvme_auth_reset(chap); in nvme_auth_negotiate()
872 queue_work(nvme_wq, &chap->auth_work); in nvme_auth_negotiate()
876 chap = kzalloc(sizeof(*chap), GFP_KERNEL); in nvme_auth_negotiate()
877 if (!chap) { in nvme_auth_negotiate()
881 chap->qid = (qid == NVME_QID_ANY) ? 0 : qid; in nvme_auth_negotiate()
882 chap->ctrl = ctrl; in nvme_auth_negotiate()
888 chap->buf_size = 4096; in nvme_auth_negotiate()
889 chap->buf = kzalloc(chap->buf_size, GFP_KERNEL); in nvme_auth_negotiate()
890 if (!chap->buf) { in nvme_auth_negotiate()
892 kfree(chap); in nvme_auth_negotiate()
896 INIT_WORK(&chap->auth_work, __nvme_auth_work); in nvme_auth_negotiate()
897 list_add(&chap->entry, &ctrl->dhchap_auth_list); in nvme_auth_negotiate()
899 queue_work(nvme_wq, &chap->auth_work); in nvme_auth_negotiate()
906 struct nvme_dhchap_queue_context *chap; in nvme_auth_wait() local
910 list_for_each_entry(chap, &ctrl->dhchap_auth_list, entry) { in nvme_auth_wait()
911 if (chap->qid != qid) in nvme_auth_wait()
914 flush_work(&chap->auth_work); in nvme_auth_wait()
915 ret = chap->error; in nvme_auth_wait()
925 struct nvme_dhchap_queue_context *chap; in nvme_auth_reset() local
928 list_for_each_entry(chap, &ctrl->dhchap_auth_list, entry) { in nvme_auth_reset()
930 flush_work(&chap->auth_work); in nvme_auth_reset()
931 __nvme_auth_reset(chap); in nvme_auth_reset()
987 struct nvme_dhchap_queue_context *chap = NULL, *tmp; in nvme_auth_stop() local
991 list_for_each_entry_safe(chap, tmp, &ctrl->dhchap_auth_list, entry) in nvme_auth_stop()
992 cancel_work_sync(&chap->auth_work); in nvme_auth_stop()
999 struct nvme_dhchap_queue_context *chap = NULL, *tmp; in nvme_auth_free() local
1002 list_for_each_entry_safe(chap, tmp, &ctrl->dhchap_auth_list, entry) { in nvme_auth_free()
1003 list_del_init(&chap->entry); in nvme_auth_free()
1004 flush_work(&chap->auth_work); in nvme_auth_free()
1005 __nvme_auth_free(chap); in nvme_auth_free()