Skip to content

Commit 4ff83da

Browse files
author
Nicholas Bellinger
committed
target: Re-add check to reject control WRITEs with overflow data
During v4.3 when the overflow/underflow check was relaxed by commit c72c525: 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 to allow underflow/overflow for Windows compliance + FCP, a consequence was to allow control CDBs to process overflow data for iscsi-target with immediate data as well. As per Roland's original change, continue to allow underflow cases for control CDBs to make Windows compliance + FCP happy, but until overflow for control CDBs is supported tree-wide, explicitly reject all control WRITEs with overflow following pre v4.3.y logic. Reported-by: Bart Van Assche <bart.vanassche@sandisk.com> Cc: Roland Dreier <roland@purestorage.com> Cc: <stable@vger.kernel.org> # v4.3+ Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
1 parent 75dbf2d commit 4ff83da

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

‎drivers/target/target_core_transport.c‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,15 +1160,28 @@ target_cmd_size_check(struct se_cmd *cmd, unsigned int size)
11601160
if (cmd->unknown_data_length) {
11611161
cmd->data_length = size;
11621162
} else if (size != cmd->data_length) {
1163-
pr_warn("TARGET_CORE[%s]: Expected Transfer Length:"
1163+
pr_warn_ratelimited("TARGET_CORE[%s]: Expected Transfer Length:"
11641164
" %u does not match SCSI CDB Length: %u for SAM Opcode:"
11651165
" 0x%02x\n", cmd->se_tfo->get_fabric_name(),
11661166
cmd->data_length, size, cmd->t_task_cdb[0]);
11671167

1168-
if (cmd->data_direction == DMA_TO_DEVICE &&
1169-
cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) {
1170-
pr_err("Rejecting underflow/overflow WRITE data\n");
1171-
return TCM_INVALID_CDB_FIELD;
1168+
if (cmd->data_direction == DMA_TO_DEVICE) {
1169+
if (cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) {
1170+
pr_err_ratelimited("Rejecting underflow/overflow"
1171+
" for WRITE data CDB\n");
1172+
return TCM_INVALID_CDB_FIELD;
1173+
}
1174+
/*
1175+
* Some fabric drivers like iscsi-target still expect to
1176+
* always reject overflow writes. Reject this case until
1177+
* full fabric driver level support for overflow writes
1178+
* is introduced tree-wide.
1179+
*/
1180+
if (size > cmd->data_length) {
1181+
pr_err_ratelimited("Rejecting overflow for"
1182+
" WRITE control CDB\n");
1183+
return TCM_INVALID_CDB_FIELD;
1184+
}
11721185
}
11731186
/*
11741187
* Reject READ_* or WRITE_* with overflow/underflow for

0 commit comments

Comments
 (0)