Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iscsi-target: Fix ERL=2 ASYNC_EVENT connection pointer bug

This patch fixes a long-standing bug in iscsit_build_conn_drop_async_message()
where during ERL=2 connection recovery, a bogus conn_p pointer could
end up being used to send the ISCSI_OP_ASYNC_EVENT + DROPPING_CONNECTION
notifying the initiator that cmd->logout_cid has failed.

The bug was manifesting itself as an OOPs in iscsit_allocate_cmd() with
a bogus conn_p pointer in iscsit_build_conn_drop_async_message().

Reported-by: Arshad Hussain <arshad.hussain@calsoftinc.com>
Reported-by: santosh kulkarni <santosh.kulkarni@calsoftinc.com>
Cc: <stable@vger.kernel.org> #3.1+
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>

+3 -1
+3 -1
drivers/target/iscsi/iscsi_target.c
··· 2491 2491 { 2492 2492 struct iscsi_cmd *cmd; 2493 2493 struct iscsi_conn *conn_p; 2494 + bool found = false; 2494 2495 2495 2496 /* 2496 2497 * Only send a Asynchronous Message on connections whos network ··· 2500 2499 list_for_each_entry(conn_p, &conn->sess->sess_conn_list, conn_list) { 2501 2500 if (conn_p->conn_state == TARG_CONN_STATE_LOGGED_IN) { 2502 2501 iscsit_inc_conn_usage_count(conn_p); 2502 + found = true; 2503 2503 break; 2504 2504 } 2505 2505 } 2506 2506 2507 - if (!conn_p) 2507 + if (!found) 2508 2508 return; 2509 2509 2510 2510 cmd = iscsit_allocate_cmd(conn_p, TASK_RUNNING);