Re: [PATCH] iscsi-target: Reject immediate data underflow larger than SCSI transfer length

From: Bart Van Assche
Date: Thu Jun 08 2017 - 11:43:46 EST


On Thu, 2017-06-08 at 04:21 +0000, Nicholas A. Bellinger wrote:
> + /*
> + * Check for underflow case where both EDTL and immediate data payload
> + * exceeds what is presented by CDB's TRANSFER LENGTH, and what has
> + * already been set in target_cmd_size_check() as se_cmd->data_length.
> + *
> + * For this special case, fail the command and dump the immediate data
> + * payload.
> + */
> + if (cmd->first_burst_len > cmd->se_cmd.data_length) {
> + cmd->sense_reason = TCM_INVALID_CDB_FIELD;
> + goto after_immediate_data;
> + }

A quote from the iSCSI RFC (https://tools.ietf.org/html/rfc5048):

If SPDTL < EDTL for a task, iSCSI Underflow MUST be signaled in the
   SCSI Response PDU as specified in [RFC3720].  The Residual Count MUST
   be set to the numerical value of (EDTL - SPDTL).

Sorry but I don't think that sending TCM_INVALID_CDB_FIELD back to the
initiator is compliant with the iSCSI RFC. Please note that a fix that is
compliant with the iSCSI RFC is present in the following patch series: [PATCH
00/33] SCSI target driver patches for kernel v4.13, 23 May 2017
(https://www.spinics.net/lists/target-devel/msg15370.html).

Bart.