Skip to content

Commit

Permalink
target: Check LUN numbers in transport_get_lun_for_[cmd,tmr]
Browse files Browse the repository at this point in the history
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: Fubo Chen <fubo.chen@gmail.com>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
  • Loading branch information
Fubo Chen authored and Nicholas Bellinger committed Jul 22, 2011
1 parent 02f8c6a commit d814495
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/target/target_core_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ int transport_get_lun_for_cmd(
unsigned long flags;
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);
deve = se_cmd->se_deve =
&SE_NODE_ACL(se_sess)->device_list[unpacked_lun];
Expand Down Expand Up @@ -187,6 +193,12 @@ int transport_get_lun_for_tmr(
struct se_session *se_sess = SE_SESS(se_cmd);
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);
deve = se_cmd->se_deve =
&SE_NODE_ACL(se_sess)->device_list[unpacked_lun];
Expand Down

0 comments on commit d814495

Please sign in to comment.