Skip to content

Commit f068fbc

Browse files
author
Nicholas Bellinger
committed
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: Sagi 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: Nicholas Bellinger <nab@linux-iscsi.org>
1 parent 2a03ee8 commit f068fbc

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

‎drivers/target/iscsi/iscsi_target.c‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4256,11 +4256,17 @@ int iscsit_close_connection(
42564256
pr_debug("Closing iSCSI connection CID %hu on SID:"
42574257
" %u\n", conn->cid, sess->sid);
42584258
/*
4259-
* Always up conn_logout_comp just in case the RX Thread is sleeping
4260-
* and the logout response never got sent because the connection
4261-
* failed.
4259+
* Always up conn_logout_comp for the traditional TCP case just in case
4260+
* the RX Thread in iscsi_target_rx_opcode() is sleeping and the logout
4261+
* response never got sent because the connection failed.
4262+
*
4263+
* However for iser-target, isert_wait4logout() is using conn_logout_comp
4264+
* to signal logout response TX interrupt completion. Go ahead and skip
4265+
* this for iser since isert_rx_opcode() does not wait on logout failure,
4266+
* and to avoid iscsi_conn pointer dereference in iser-target code.
42624267
*/
4263-
complete(&conn->conn_logout_comp);
4268+
if (conn->conn_transport->transport_type == ISCSI_TCP)
4269+
complete(&conn->conn_logout_comp);
42644270

42654271
iscsi_release_thread_set(conn);
42664272

0 commit comments

Comments
 (0)