Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f068fbc8 authored by Nicholas Bellinger's avatar Nicholas Bellinger
Browse files

iscsi-target: Avoid early conn_logout_comp for iser connections



This patch fixes a iser specific logout bug where early complete()
of conn->conn_logout_comp in iscsit_close_connection() was causing
isert_wait4logout() to complete too soon, triggering a use after
free NULL pointer dereference of iscsi_conn memory.

The complete() was originally added for traditional iscsi-target
when a ISCSI_LOGOUT_OP failed in iscsi_target_rx_opcode(), but given
iser-target does not wait in logout failure, this special case needs
to be avoided.

Reported-by: default avatarSagi Grimberg <sagig@mellanox.com>
Cc: Sagi Grimberg <sagig@mellanox.com>
Cc: Slava Shwartsman <valyushash@gmail.com>
Cc: <stable@vger.kernel.org> # v3.10+
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 2a03ee8c
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -4256,10 +4256,16 @@ int iscsit_close_connection(
	pr_debug("Closing iSCSI connection CID %hu on SID:"
		" %u\n", conn->cid, sess->sid);
	/*
	 * Always up conn_logout_comp just in case the RX Thread is sleeping
	 * and the logout response never got sent because the connection
	 * failed.
	 * Always up conn_logout_comp for the traditional TCP case just in case
	 * the RX Thread in iscsi_target_rx_opcode() is sleeping and the logout
	 * response never got sent because the connection failed.
	 *
	 * However for iser-target, isert_wait4logout() is using conn_logout_comp
	 * to signal logout response TX interrupt completion.  Go ahead and skip
	 * this for iser since isert_rx_opcode() does not wait on logout failure,
	 * and to avoid iscsi_conn pointer dereference in iser-target code.
	 */
	if (conn->conn_transport->transport_type == ISCSI_TCP)
		complete(&conn->conn_logout_comp);

	iscsi_release_thread_set(conn);