Commit 74bf930e authored by Jacek Kalwas's avatar Jacek Kalwas Committed by Tomasz Zawadzki
Browse files

nvme/auth: add in_auth_poll guard



nvme_fabric_qpair_authenticate_poll is not always called from within
nvme_tcp_ctrlr_connect_qpair_poll, see nvme_tcp_qpair_authenticate ->
nvme_fabric_qpair_authenticate_async -> nvme_fabric_qpair_authenticate_poll.

Given that, recursion can occur in ctrlr_disconnect_qpair or
qpair_process_completions, which invoke nvme_tcp_ctrlr_connect_qpair_poll.

Change-Id: I3112d0fb6cd44596c5b82547b9e7ac4a9d066439
Signed-off-by: default avatarJacek Kalwas <jacek.kalwas@nutanix.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/26797


Reviewed-by: default avatarKonrad Sztyber <ksztyber@nvidia.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
parent e6659485
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1086,6 +1086,12 @@ nvme_fabric_qpair_authenticate_poll(struct spdk_nvme_qpair *qpair)
	enum nvme_qpair_auth_state prev_state;
	int rc;

	if (auth->flags.in_auth_poll) {
		return -EAGAIN;
	}

	auth->flags.in_auth_poll = true;

	do {
		prev_state = auth->state;

@@ -1101,6 +1107,7 @@ nvme_fabric_qpair_authenticate_poll(struct spdk_nvme_qpair *qpair)
			nvme_auth_set_state(qpair, NVME_QPAIR_AUTH_STATE_AWAIT_NEGOTIATE);
			/* Intentionally return here to prevent the state machine entering the DONE
			 * state on the initial kick from nvme_fabric_qpair_authenticate_async. */
			auth->flags.in_auth_poll = false;
			return -EAGAIN;
		case NVME_QPAIR_AUTH_STATE_AWAIT_NEGOTIATE:
			rc = nvme_wait_for_completion_poll(qpair, status);
@@ -1207,13 +1214,16 @@ nvme_fabric_qpair_authenticate_poll(struct spdk_nvme_qpair *qpair)
				auth->cb_fn(auth->cb_ctx, auth->status);
				auth->cb_fn = NULL;
			}
			auth->flags.in_auth_poll = false;
			return auth->status;
		default:
			assert(0 && "invalid state");
			auth->flags.in_auth_poll = false;
			return -EINVAL;
		}
	} while (auth->state != prev_state);

	auth->flags.in_auth_poll = false;
	return -EAGAIN;
}

+3 −1
Original line number Diff line number Diff line
@@ -446,7 +446,9 @@ struct nvme_auth {
			uint32_t        atr : 1;
			/* Authentication and secure channel required (authreq.ascr) */
			uint32_t        ascr : 1;
			uint32_t        reserved : 30;
			/* In authenticate poll context flag */
			uint8_t		in_auth_poll : 1;
			uint32_t        reserved : 29;
		};
		uint32_t                raw;
	} flags;