提交 d8144955 编写于 作者: F Fubo Chen 提交者: Nicholas Bellinger

target: Check LUN numbers in transport_get_lun_for_[cmd,tmr]

This patch checks the passed 'unpacked_lun' against TRANSPORT_MAX_LUNS_PER_TPG
before reading from struct se_node_acl->device_list[].
Signed-off-by: NFubo Chen <fubo.chen@gmail.com>
Signed-off-by: NNicholas A. Bellinger <nab@linux-iscsi.org>
上级 02f8c6ae
...@@ -65,6 +65,12 @@ int transport_get_lun_for_cmd( ...@@ -65,6 +65,12 @@ int transport_get_lun_for_cmd(
unsigned long flags; unsigned long flags;
int read_only = 0; int read_only = 0;
if (unpacked_lun >= TRANSPORT_MAX_LUNS_PER_TPG) {
se_cmd->scsi_sense_reason = TCM_NON_EXISTENT_LUN;
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
return -1;
}
spin_lock_irq(&SE_NODE_ACL(se_sess)->device_list_lock); spin_lock_irq(&SE_NODE_ACL(se_sess)->device_list_lock);
deve = se_cmd->se_deve = deve = se_cmd->se_deve =
&SE_NODE_ACL(se_sess)->device_list[unpacked_lun]; &SE_NODE_ACL(se_sess)->device_list[unpacked_lun];
...@@ -187,6 +193,12 @@ int transport_get_lun_for_tmr( ...@@ -187,6 +193,12 @@ int transport_get_lun_for_tmr(
struct se_session *se_sess = SE_SESS(se_cmd); struct se_session *se_sess = SE_SESS(se_cmd);
struct se_tmr_req *se_tmr = se_cmd->se_tmr_req; struct se_tmr_req *se_tmr = se_cmd->se_tmr_req;
if (unpacked_lun >= TRANSPORT_MAX_LUNS_PER_TPG) {
se_cmd->scsi_sense_reason = TCM_NON_EXISTENT_LUN;
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
return -1;
}
spin_lock_irq(&SE_NODE_ACL(se_sess)->device_list_lock); spin_lock_irq(&SE_NODE_ACL(se_sess)->device_list_lock);
deve = se_cmd->se_deve = deve = se_cmd->se_deve =
&SE_NODE_ACL(se_sess)->device_list[unpacked_lun]; &SE_NODE_ACL(se_sess)->device_list[unpacked_lun];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册