Skip to content

Commit af8524b

Browse files
Nicholas Bellingersashalevin
authored andcommitted
iscsi-target: Avoid early conn_logout_comp for iser connections
[ Upstream commit f068fbc ] 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> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
1 parent b54521a commit af8524b

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
@@ -4220,11 +4220,17 @@ int iscsit_close_connection(
42204220
pr_debug("Closing iSCSI connection CID %hu on SID:"
42214221
" %u\n", conn->cid, sess->sid);
42224222
/*
4223-
* Always up conn_logout_comp just in case the RX Thread is sleeping
4224-
* and the logout response never got sent because the connection
4225-
* failed.
4223+
* Always up conn_logout_comp for the traditional TCP case just in case
4224+
* the RX Thread in iscsi_target_rx_opcode() is sleeping and the logout
4225+
* response never got sent because the connection failed.
4226+
*
4227+
* However for iser-target, isert_wait4logout() is using conn_logout_comp
4228+
* to signal logout response TX interrupt completion. Go ahead and skip
4229+
* this for iser since isert_rx_opcode() does not wait on logout failure,
4230+
* and to avoid iscsi_conn pointer dereference in iser-target code.
42264231
*/
4227-
complete(&conn->conn_logout_comp);
4232+
if (conn->conn_transport->transport_type == ISCSI_TCP)
4233+
complete(&conn->conn_logout_comp);
42284234

42294235
iscsi_release_thread_set(conn);
42304236

0 commit comments

Comments
 (0)