diff options
author | Fubo Chen <fubo.chen@gmail.com> | 2011-02-13 18:13:42 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-07-22 05:37:42 -0400 |
commit | d814495599354924eb4de84727680564d685ce9e (patch) | |
tree | f03248dfcd68bf297697ab7e110070033aad4dc0 /drivers | |
parent | 02f8c6aee8df3cdc935e9bdd4f2d020306035dbe (diff) |
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: Fubo Chen <fubo.chen@gmail.com>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/target/target_core_device.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index ba698ea62bb2..f5516a1a32e8 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c | |||
@@ -65,6 +65,12 @@ int transport_get_lun_for_cmd( | |||
65 | unsigned long flags; | 65 | unsigned long flags; |
66 | int read_only = 0; | 66 | int read_only = 0; |
67 | 67 | ||
68 | if (unpacked_lun >= TRANSPORT_MAX_LUNS_PER_TPG) { | ||
69 | se_cmd->scsi_sense_reason = TCM_NON_EXISTENT_LUN; | ||
70 | se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; | ||
71 | return -1; | ||
72 | } | ||
73 | |||
68 | spin_lock_irq(&SE_NODE_ACL(se_sess)->device_list_lock); | 74 | spin_lock_irq(&SE_NODE_ACL(se_sess)->device_list_lock); |
69 | deve = se_cmd->se_deve = | 75 | deve = se_cmd->se_deve = |
70 | &SE_NODE_ACL(se_sess)->device_list[unpacked_lun]; | 76 | &SE_NODE_ACL(se_sess)->device_list[unpacked_lun]; |
@@ -187,6 +193,12 @@ int transport_get_lun_for_tmr( | |||
187 | struct se_session *se_sess = SE_SESS(se_cmd); | 193 | struct se_session *se_sess = SE_SESS(se_cmd); |
188 | struct se_tmr_req *se_tmr = se_cmd->se_tmr_req; | 194 | struct se_tmr_req *se_tmr = se_cmd->se_tmr_req; |
189 | 195 | ||
196 | if (unpacked_lun >= TRANSPORT_MAX_LUNS_PER_TPG) { | ||
197 | se_cmd->scsi_sense_reason = TCM_NON_EXISTENT_LUN; | ||
198 | se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; | ||
199 | return -1; | ||
200 | } | ||
201 | |||
190 | spin_lock_irq(&SE_NODE_ACL(se_sess)->device_list_lock); | 202 | spin_lock_irq(&SE_NODE_ACL(se_sess)->device_list_lock); |
191 | deve = se_cmd->se_deve = | 203 | deve = se_cmd->se_deve = |
192 | &SE_NODE_ACL(se_sess)->device_list[unpacked_lun]; | 204 | &SE_NODE_ACL(se_sess)->device_list[unpacked_lun]; |