Skip to content

Commit fe8003d

Browse files
Nicholas Bellingergregkh
authored andcommitted
iscsi-target: Reject immediate data underflow larger than SCSI transfer length
commit abb85a9b512e8ca7ad04a5a8a6db9664fe644974 upstream. When iscsi WRITE underflow occurs there are two different scenarios that can happen. Normally in practice, when an EDTL vs. SCSI CDB TRANSFER LENGTH underflow is detected, the iscsi immediate data payload is the smaller SCSI CDB TRANSFER LENGTH. That is, when a host fabric LLD is using a fixed size EDTL for a specific control CDB, the SCSI CDB TRANSFER LENGTH and actual SCSI payload ends up being smaller than EDTL. In iscsi, this means the received iscsi immediate data payload matches the smaller SCSI CDB TRANSFER LENGTH, because there is no more SCSI payload to accept beyond SCSI CDB TRANSFER LENGTH. However, it's possible for a malicous host to send a WRITE underflow where EDTL is larger than SCSI CDB TRANSFER LENGTH, but incoming iscsi immediate data actually matches EDTL. In the wild, we've never had a iscsi host environment actually try to do this. For this special case, it's wrong to truncate part of the control CDB payload and continue to process the command during underflow when immediate data payload received was larger than SCSI CDB TRANSFER LENGTH, so go ahead and reject and drop the bogus payload as a defensive action. Note this potential bug was originally relaxed by the following for allowing WRITE underflow in MSFT FCP host environments: commit c72c525 Author: Roland Dreier <roland@purestorage.com> Date: Wed Jul 22 15:08:18 2015 -0700 target: allow underflow/overflow for PR OUT etc. commands Cc: Roland Dreier <roland@purestorage.com> Cc: Mike Christie <mchristi@redhat.com> Cc: Hannes Reinecke <hare@suse.de> Cc: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d374be7 commit fe8003d

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

drivers/target/iscsi/iscsi_target.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,18 @@ iscsit_get_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr,
11121112
*/
11131113
if (dump_payload)
11141114
goto after_immediate_data;
1115+
/*
1116+
* Check for underflow case where both EDTL and immediate data payload
1117+
* exceeds what is presented by CDB's TRANSFER LENGTH, and what has
1118+
* already been set in target_cmd_size_check() as se_cmd->data_length.
1119+
*
1120+
* For this special case, fail the command and dump the immediate data
1121+
* payload.
1122+
*/
1123+
if (cmd->first_burst_len > cmd->se_cmd.data_length) {
1124+
cmd->sense_reason = TCM_INVALID_CDB_FIELD;
1125+
goto after_immediate_data;
1126+
}
11151127

11161128
immed_ret = iscsit_handle_immediate_data(cmd, hdr,
11171129
cmd->first_burst_len);

0 commit comments

Comments
 (0)