Skip to content

Commit 4063c20

Browse files
Bart Van Asschegregkh
authored andcommitted
target/iscsi: Fix iSCSI task reassignment handling
commit 59b6986dbfcdab96a971f9663221849de79a7556 upstream. Allocate a task management request structure for all task management requests, including task reassignment. This change avoids that the se_tmr->response assignment dereferences an uninitialized se_tmr pointer. Reported-by: Moshe David <mdavid@infinidat.com> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Moshe David <mdavid@infinidat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7ecc076 commit 4063c20

2 files changed

Lines changed: 8 additions & 12 deletions

File tree

drivers/target/iscsi/iscsi_target.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,7 +1759,7 @@ iscsit_handle_task_mgt_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
17591759
struct iscsi_tm *hdr;
17601760
int out_of_order_cmdsn = 0, ret;
17611761
bool sess_ref = false;
1762-
u8 function;
1762+
u8 function, tcm_function = TMR_UNKNOWN;
17631763

17641764
hdr = (struct iscsi_tm *) buf;
17651765
hdr->flags &= ~ISCSI_FLAG_CMD_FINAL;
@@ -1805,10 +1805,6 @@ iscsit_handle_task_mgt_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
18051805
* LIO-Target $FABRIC_MOD
18061806
*/
18071807
if (function != ISCSI_TM_FUNC_TASK_REASSIGN) {
1808-
1809-
u8 tcm_function;
1810-
int ret;
1811-
18121808
transport_init_se_cmd(&cmd->se_cmd, &iscsi_ops,
18131809
conn->sess->se_sess, 0, DMA_NONE,
18141810
TCM_SIMPLE_TAG, cmd->sense_buffer + 2);
@@ -1844,15 +1840,14 @@ iscsit_handle_task_mgt_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
18441840
return iscsit_add_reject_cmd(cmd,
18451841
ISCSI_REASON_BOOKMARK_NO_RESOURCES, buf);
18461842
}
1847-
1848-
ret = core_tmr_alloc_req(&cmd->se_cmd, cmd->tmr_req,
1849-
tcm_function, GFP_KERNEL);
1850-
if (ret < 0)
1851-
return iscsit_add_reject_cmd(cmd,
1843+
}
1844+
ret = core_tmr_alloc_req(&cmd->se_cmd, cmd->tmr_req, tcm_function,
1845+
GFP_KERNEL);
1846+
if (ret < 0)
1847+
return iscsit_add_reject_cmd(cmd,
18521848
ISCSI_REASON_BOOKMARK_NO_RESOURCES, buf);
18531849

1854-
cmd->tmr_req->se_tmr_req = cmd->se_cmd.se_tmr_req;
1855-
}
1850+
cmd->tmr_req->se_tmr_req = cmd->se_cmd.se_tmr_req;
18561851

18571852
cmd->iscsi_opcode = ISCSI_OP_SCSI_TMFUNC;
18581853
cmd->i_state = ISTATE_SEND_TASKMGTRSP;

include/target/target_core_base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ enum tcm_tmreq_table {
199199
TMR_LUN_RESET = 5,
200200
TMR_TARGET_WARM_RESET = 6,
201201
TMR_TARGET_COLD_RESET = 7,
202+
TMR_UNKNOWN = 0xff,
202203
};
203204

204205
/* fabric independent task management response values */

0 commit comments

Comments
 (0)