• Roland Dreier's avatar
    target: Fix up handling of short INQUIRY buffers · d95b8246
    Roland Dreier authored
    If the initiator sends us an INQUIRY command with an allocation length
    that's shorter than what we want to return, we're simply supposed to
    truncate our response and return what the initiator gave us space for,
    without signaling any error.  Current target code has various tests that
    don't fill out the full response if the buffer is too short and
    sometimes return errors incorrectly.
    
    Fix this up by allocating a bounce buffer for INQUIRY responses if we
    need to, ie if we have cmd->data_length too small as well as
    SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC set in cmd->se_cmd_flags -- for most
    fabrics, we always allocate at least a full page, but for tcm_loop we
    may have a small buffer coming directly from the SCSI stack.
    
    This lets us delete a lot of cmd->data_length checking, and also makes
    our INQUIRY handling correct per SPC in a lot more cases.
    Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
    d95b8246
target_core_cdb.c 33 KB