Commit 91ec1d35 authored by Nicholas Bellinger's avatar Nicholas Bellinger

target: Add workaround for zero-length control CDB handling

This patch adds a work-around for handling zero allocation length
control CDBs (type SCF_SCSI_CONTROL_SG_IO_CDB) that was causing an
OOPs with the following raw calls:

   # sg_raw -v /dev/sdd 3 0 0 0 0 0
   # sg_raw -v /dev/sdd 0x1a 0 1 0 0 0

This patch will follow existing zero-length handling for data I/O
and silently return with GOOD status.  This addresses the zero length
issue, but the proper long-term resolution for handling arbitary
allocation lengths will be to refactor out data-phase handling in
individual CDB emulation logic within target_core_cdb.c
Reported-by: default avatarRoland Dreier <roland@purestorage.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 9fbc8909
...@@ -3759,6 +3759,11 @@ transport_allocate_control_task(struct se_cmd *cmd) ...@@ -3759,6 +3759,11 @@ transport_allocate_control_task(struct se_cmd *cmd)
struct se_task *task; struct se_task *task;
unsigned long flags; unsigned long flags;
/* Workaround for handling zero-length control CDBs */
if ((cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB) &&
!cmd->data_length)
return 0;
task = transport_generic_get_task(cmd, cmd->data_direction); task = transport_generic_get_task(cmd, cmd->data_direction);
if (!task) if (!task)
return -ENOMEM; return -ENOMEM;
...@@ -3830,6 +3835,14 @@ int transport_generic_new_cmd(struct se_cmd *cmd) ...@@ -3830,6 +3835,14 @@ int transport_generic_new_cmd(struct se_cmd *cmd)
else if (!task_cdbs && (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB)) { else if (!task_cdbs && (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB)) {
cmd->t_state = TRANSPORT_COMPLETE; cmd->t_state = TRANSPORT_COMPLETE;
atomic_set(&cmd->t_transport_active, 1); atomic_set(&cmd->t_transport_active, 1);
if (cmd->t_task_cdb[0] == REQUEST_SENSE) {
u8 ua_asc = 0, ua_ascq = 0;
core_scsi3_ua_clear_for_request_sense(cmd,
&ua_asc, &ua_ascq);
}
INIT_WORK(&cmd->work, target_complete_ok_work); INIT_WORK(&cmd->work, target_complete_ok_work);
queue_work(target_completion_wq, &cmd->work); queue_work(target_completion_wq, &cmd->work);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment