1. 15 5月, 2013 1 次提交
  2. 04 5月, 2013 1 次提交
  3. 25 4月, 2013 2 次提交
  4. 29 3月, 2013 1 次提交
    • N
      target: Fix RESERVATION_CONFLICT status regression for iscsi-target special case · f85eda8d
      Nicholas Bellinger 提交于
      This patch fixes a regression introduced in v3.8-rc1 code where a failed
      target_check_reservation() check in target_setup_cmd_from_cdb() was causing
      an incorrect SAM_STAT_GOOD status to be returned during a WRITE operation
      performed by an unregistered / unreserved iscsi initiator port.
      
      This regression is only effecting iscsi-target due to a special case check
      for TCM_RESERVATION_CONFLICT within iscsi_target_erl1.c:iscsit_execute_cmd(),
      and was still correctly disallowing WRITE commands from backend submission
      for unregistered / unreserved initiator ports, while returning the incorrect
      SAM_STAT_GOOD status due to the missing SAM_STAT_RESERVATION_CONFLICT
      assignment.
      
      This regression was first introduced with:
      
      commit de103c93
      Author: Christoph Hellwig <hch@lst.de>
      Date:   Tue Nov 6 12:24:09 2012 -0800
      
          target: pass sense_reason as a return value
      
      Go ahead and re-add the missing SAM_STAT_RESERVATION_CONFLICT assignment
      during a target_check_reservation() failure, so that iscsi-target code
      sends the correct SCSI status.
      
      All other fabrics using target_submit_cmd_*() with a RESERVATION_CONFLICT
      call to transport_generic_request_failure() are not effected by this bug.
      Reported-by: NJeff Leung <jleung@curriegrad2004.ca>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      f85eda8d
  5. 14 2月, 2013 2 次提交
    • R
      target: Fix error checking for UNMAP commands · bb992e72
      Roland Dreier 提交于
      SBC-3 (revision 35) says:
      
          The PARAMETER LIST LENGTH field specifies the length in bytes of the
          UNMAP parameter list that is available to be transferred from the
          Data-Out Buffer. If the parameter list length is greater than zero
          and less than 0008h (i.e., eight), then the device server shall
          terminate the command with CHECK CONDITION status with the sense key
          set to ILLEGAL REQUEST and the additional sense code set to
          PARAMETER LIST LENGTH ERROR. A PARAMETER LIST LENGTH set to zero
          specifies that no data shall be sent.
      
      so our sense code for too-short descriptors was wrong, and we were
      incorrectly failing commands that didn't transfer any descriptors.
      
      While we're at it, also handle the UNMAP check:
      
          If the ANCHOR bit is set to one, and the ANC_SUP bit in the Logical
          Block Provisioning VPD page (see 6.6.4) is set to zero, then the
          device server shall terminate the command with CHECK CONDITION
          status with the sense key set to ILLEGAL REQUEST and the additional
          sense code set to INVALID FIELD IN CDB.
      
      (chris boot: Fix wrong cut+paste comment in transport_send_check_condition_and_sense)
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      bb992e72
    • D
      target: change sprintf to snprintf in transport_dump_vpd_ident · 703d641d
      Dan Carpenter 提交于
      "buf" is 128 characters and "vpd->device_identifier" is 256.  It makes
      the static checkers complain.
      
      Also bump VPD_TMP_BUF_SIZE to match INQUIRY_VPD_DEVICE_IDENTIFIER_LEN.
      Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      703d641d
  6. 11 1月, 2013 4 次提交
    • R
      target: Release se_cmd when LUN lookup fails for TMR · 5a3b6fc0
      Roland Dreier 提交于
      When transport_lookup_tmr_lun() fails and we return a task management
      response from target_complete_tmr_failure(), we need to call
      transport_cmd_check_stop_to_fabric() to release the last ref to the
      cmd after calling se_tfo->queue_tm_rsp(), or else we will never remove
      the failed TMR from the session command list (and we'll end up waiting
      forever when trying to tear down the session).
      
      (nab: Fix minor compile breakage)
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      5a3b6fc0
    • R
      target: Fix use-after-free in LUN RESET handling · 72b59d6e
      Roland Dreier 提交于
      If a backend IO takes a really long then an initiator might abort a
      command, and then when it gives up on the abort, send a LUN reset too,
      all before we process any of the original command or the abort.  (The
      abort will wait for the backend IO to complete too)
      
      When the backend IO final completes (or fails), the abort handling
      will proceed and queue up a "return aborted status" operation.  Then,
      while that's still pending, the LUN reset might find the original
      command still on the LUN's list of commands and try to return aborted
      status again, which leads to a use-after free when the first
      se_tfo->queue_status call frees the command and then the second
      se_tfo->queue_status call runs.
      
      Fix this by removing a command from the LUN state_list when we first
      are about to queue aborted status; we shouldn't do anything
      LUN-related after we've started returning status, so this seems like
      the correct thing to do.
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      72b59d6e
    • R
      target: Fix missing CMD_T_ACTIVE bit regression for pending WRITEs · e627c615
      Roland Dreier 提交于
      This patch fixes a regression bug introduced during v3.6.x code with
      the following commit to drop transport_add_cmd_to_queue(), which
      originally re-set CMD_T_ACTIVE during pending WRITE I/O submission:
      
      commit af877292
      Author: Christoph Hellwig <hch@infradead.org>
      Date:   Sun Jul 8 15:58:49 2012 -0400
      
          target: replace the processing thread with a TMR work queue
      
      The following sequence happens for write commands (or any other
      commands with a data out phase):
      
       - The transport calls target_submit_cmd(), which sets CMD_T_ACTIVE in
         cmd->transport_state and sets cmd->t_state to TRANSPORT_NEW_CMD.
       - Things go on transport_generic_new_cmd(), which notices that the
         command needs to transfer data, so it sets cmd->t_state to
         TRANSPORT_WRITE_PENDING and calls transport_cmd_check_stop().
       - transport_cmd_check_stop() clears CMD_T_ACTIVE in cmd->transport_state
         and returns in the normal case.
       - Then we continue on to call ->se_tfo->write_pending().
       - The data comes back from the initiator, and the transport calls
         target_execute_cmd(), which sets cmd->t_state to TRANSPORT_PROCESSING
         and calls into the backend to actually write the data.
      
      At this point, the backend might take a long time to complete the
      command, since it has to do real IO.  If an abort request comes in for
      this command at this point, it will not wait for the command to finish
      since CMD_T_ACTIVE is not set.  Then when the command does finally
      finish, we blow up with use-after-free.
      
      Avoid this by setting CMD_T_ACTIVE in target_execute_cmd() so that
      transport_wait_for_tasks() waits for the command to finish executing.
      This matches the behavior from before commit 1389533e ("target:
      remove transport_generic_handle_data"), when data was signaled via
      transport_generic_handle_data(), which set CMD_T_ACTIVE because it
      called transport_add_cmd_to_queue().
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      Reported-by: NMartin Svec <martin.svec@zoner.cz>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: stable@vger.kernel.org
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      e627c615
    • H
      target: Introduce TCM_NO_SENSE · ba829137
      Hannes Reinecke 提交于
      Introduce TCM_NO_SENSE, mapping to sense code
      'Not ready, no additional sense information'.
      Signed-off-by: NHannes Reinecke <hare@suse.de>
      Cc: Nicholas Bellinger <nab@risingtidesystems.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      ba829137
  7. 09 1月, 2013 1 次提交
  8. 28 11月, 2012 3 次提交
  9. 18 11月, 2012 1 次提交
  10. 08 11月, 2012 1 次提交
    • N
      target: Fix possible TFO->write_pending() sense_reason_t silent WRITE corruption · b69c1fcf
      Nicholas Bellinger 提交于
      This patch fixes a possible case in transport_generic_new_cmd() where a
      failure from TFO->write_pending() from a fabric module return something
      other than -EAGAIN or -ENOMEM would cause a failed WRITE to silently
      succeed.
      
      Go ahead and return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE for this
      special case instead of only just making noise with WARN_ON().
      
      (v2: Fix incorrect exception return for all cases)
      
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Roland Dreier <roland@purestorage.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      b69c1fcf
  11. 07 11月, 2012 6 次提交
  12. 27 10月, 2012 1 次提交
    • N
      target: Fix double-free of se_cmd in target_complete_tmr_failure · e13d5fef
      Nicholas Bellinger 提交于
      Fabric drivers currently expect to internally release se_cmd in the event
      of a TMR failure during target_submit_tmr(), which means the immediate call
      to transport_generic_free_cmd() after TFO->queue_tm_rsp() from within
      target_complete_tmr_failure() workqueue context is wrong.
      
      This is done as some fabrics expect TMR operations to be acknowledged
      before releasing the descriptor, so the assumption that core is releasing
      se_cmd associated TMR memory is incorrect.  This fixes a OOPs where
      transport_generic_free_cmd() was being called more than once.
      
      This bug was originally observed with tcm_qla2xxx fabric ports.
      
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Roland Dreier <roland@purestorage.com>
      Cc: Andy Grover <agrover@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      e13d5fef
  13. 03 10月, 2012 2 次提交
  14. 18 9月, 2012 5 次提交
  15. 08 9月, 2012 3 次提交
  16. 06 9月, 2012 3 次提交
  17. 24 8月, 2012 1 次提交
    • N
      target: Fix ->data_length re-assignment bug with SCSI overflow · 4c054ba6
      Nicholas Bellinger 提交于
      This patch fixes a long-standing bug with SCSI overflow handling
      where se_cmd->data_length was incorrectly being re-assigned to
      the larger CDB extracted allocation length, resulting in a number
      of fabric level errors that would end up causing a session reset
      in most cases.  So instead now:
      
       - Only re-assign se_cmd->data_length durining UNDERFLOW (to use the
         smaller value)
       - Use existing se_cmd->data_length for OVERFLOW (to use the smaller
         value)
      
      This fix has been tested with the following CDB to generate an
      SCSI overflow:
      
        sg_raw -r512 /dev/sdc 28 0 0 0 0 0 0 0 9 0
      
      Tested using iscsi-target, tcm_qla2xxx, loopback and tcm_vhost fabric
      ports.  Here is a bit more detail on each case:
      
       - iscsi-target: Bug with open-iscsi with overflow, sg_raw returns
                       -3584 bytes of data.
       - tcm_qla2xxx: Working as expected, returnins 512 bytes of data
       - loopback: sg_raw returns CHECK_CONDITION, from overflow rejection
                   in transport_generic_map_mem_to_cmd()
       - tcm_vhost: Same as loopback
      Reported-by: NRoland Dreier <roland@purestorage.com>
      Cc: Roland Dreier <roland@purestorage.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Boaz Harrosh <bharrosh@panasas.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      4c054ba6
  18. 22 8月, 2012 1 次提交
  19. 18 8月, 2012 1 次提交
    • N
      target: Fix regression bug with handling of zero-length data CDBs · 74f4cf29
      Nicholas Bellinger 提交于
      This patch fixes a regression bug with the handling of zero-length
      data CDBs within transport_generic_new_cmd() code.  The bug was introduced
      with the following commit as part of the single task conversion work:
      
        commit 4101f0a8
        Author: Christoph Hellwig <hch@infradead.org>
        Date:   Tue Apr 24 00:25:03 2012 -0400
      
            target: always allocate a single task
      
      where the zero-length check for SCF_SCSI_DATA_SG_IO_CDB was incorrectly
      changed to SCF_SCSI_CONTROL_SG_IO_CDB because of the seperate comment
      in transport_generic_new_cmd() wrt to control CDBs zero-length handling
      introduced in:
      
        commit 91ec1d35
        Author: Nicholas Bellinger <nab@linux-iscsi.org>
        Date:   Fri Jan 13 12:01:34 2012 -0800
      
            target: Add workaround for zero-length control CDB handling
      
      So go ahead and change transport_generic_new_cmd() to handle control+data
      zero-length CDBs in the same manner for this special case.
      
      Tested with iscsi-target + loopback fabric port LUNs on 3.6-rc0 code.
      
      This patch will also need to be picked up for 3.5-stable.
      
      (hch: Add proper comment in transport_generic_new_cmd)
      
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Roland Dreier <roland@purestorage.com>
      Cc: Andy Grover <agrover@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      74f4cf29