1. 12 12月, 2017 1 次提交
    • B
      scsi: core: Fix a scsi_show_rq() NULL pointer dereference · 14e3062f
      Bart Van Assche 提交于
      Avoid that scsi_show_rq() triggers a NULL pointer dereference if called
      after sd_uninit_command(). Swap the NULL pointer assignment and the
      mempool_free() call in sd_uninit_command() to make it less likely that
      scsi_show_rq() triggers a use-after-free. Note: even with these changes
      scsi_show_rq() can trigger a use-after-free but that's a lesser evil
      than e.g. suppressing debug information for T10 PI Type 2 commands
      completely. This patch fixes the following oops:
      
      BUG: unable to handle kernel NULL pointer dereference at (null)
      IP: scsi_format_opcode_name+0x1a/0x1c0
      CPU: 1 PID: 1881 Comm: cat Not tainted 4.14.0-rc2.blk_mq_io_hang+ #516
      Call Trace:
       __scsi_format_command+0x27/0xc0
       scsi_show_rq+0x5c/0xc0
       __blk_mq_debugfs_rq_show+0x116/0x130
       blk_mq_debugfs_rq_show+0xe/0x10
       seq_read+0xfe/0x3b0
       full_proxy_read+0x54/0x90
       __vfs_read+0x37/0x160
       vfs_read+0x96/0x130
       SyS_read+0x55/0xc0
       entry_SYSCALL_64_fastpath+0x1a/0xa5
      
      [mkp: added Type 2]
      
      Fixes: 0eebd005 ("scsi: Implement blk_mq_ops.show_rq()")
      Reported-by: NMing Lei <ming.lei@redhat.com>
      Signed-off-by: NBart Van Assche <bart.vanassche@wdc.com>
      Cc: James E.J. Bottomley <jejb@linux.vnet.ibm.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Ming Lei <ming.lei@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.com>
      Cc: Johannes Thumshirn <jthumshirn@suse.de>
      Cc: stable@vger.kernel.org
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      14e3062f
  2. 17 10月, 2017 2 次提交
  3. 03 10月, 2017 2 次提交
  4. 26 9月, 2017 1 次提交
  5. 16 9月, 2017 1 次提交
  6. 26 8月, 2017 4 次提交
  7. 17 8月, 2017 1 次提交
  8. 29 6月, 2017 1 次提交
  9. 27 6月, 2017 1 次提交
  10. 13 6月, 2017 1 次提交
    • B
      scsi: Protect SCSI device state changes with a mutex · 0db6ca8a
      Bart Van Assche 提交于
      Serializing SCSI device state changes avoids that two state changes can
      occur concurrently, e.g. the state changes in scsi_target_block() and
      __scsi_remove_device(). This serialization is essential to make patch
      "Make __scsi_remove_device go straight from BLOCKED to DEL" work
      reliably.
      
      Enable this mechanism for all scsi_target_*block() callers but not for
      the scsi_internal_device_unblock() calls from the mpt3sas driver because
      that driver can call scsi_internal_device_unblock() from atomic context.
      Signed-off-by: NBart Van Assche <bart.vanassche@sandisk.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.com>
      Cc: Johannes Thumshirn <jthumshirn@suse.de>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      0db6ca8a
  11. 17 5月, 2017 1 次提交
  12. 12 5月, 2017 2 次提交
  13. 26 4月, 2017 2 次提交
  14. 25 4月, 2017 2 次提交
  15. 09 4月, 2017 6 次提交
  16. 08 4月, 2017 2 次提交
  17. 07 4月, 2017 2 次提交
  18. 09 3月, 2017 1 次提交
  19. 02 3月, 2017 1 次提交
    • D
      scsi: sd: Check for unaligned partial completion · c46f0917
      Damien Le Moal 提交于
      Commit <f2e767bb> ("mpt3sas: Force request partial completion
      alignment") was not considering the case of commands not operating on
      logical block size units (e.g. REQ_OP_ZONE_REPORT and its 64B aligned
      partial replies). In this case, forcing alignment of resid to the device
      logical block size can break the command result, e.g. in the case of
      REQ_OP_ZONE_REPORT, the exact number of zone reported by the device.
      
      Move the partial completion alignement check of mpt3sas to a generic
      implementation in sd_done(). The check is added within the default
      section of the initial req_op() switch case so that the report and reset
      zone commands are ignored. In addition, as sd_done() is not called for
      passthrough requests, resid corrections are not done as intended by the
      initial mpt3sas patch.
      
      Fixes: f2e767bb ("mpt3sas: Force request partial completion alignment")
      Cc: <stable@vger.kernel.org> # v4.10
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Acked-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NBart Van Assche <bart.vanassche@sandisk.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      c46f0917
  20. 24 2月, 2017 1 次提交
  21. 23 2月, 2017 3 次提交
  22. 02 2月, 2017 1 次提交
    • D
      scsi, block: fix duplicate bdi name registration crashes · 0dba1314
      Dan Williams 提交于
      Warnings of the following form occur because scsi reuses a devt number
      while the block layer still has it referenced as the name of the bdi
      [1]:
      
       WARNING: CPU: 1 PID: 93 at fs/sysfs/dir.c:31 sysfs_warn_dup+0x62/0x80
       sysfs: cannot create duplicate filename '/devices/virtual/bdi/8:192'
       [..]
       Call Trace:
        dump_stack+0x86/0xc3
        __warn+0xcb/0xf0
        warn_slowpath_fmt+0x5f/0x80
        ? kernfs_path_from_node+0x4f/0x60
        sysfs_warn_dup+0x62/0x80
        sysfs_create_dir_ns+0x77/0x90
        kobject_add_internal+0xb2/0x350
        kobject_add+0x75/0xd0
        device_add+0x15a/0x650
        device_create_groups_vargs+0xe0/0xf0
        device_create_vargs+0x1c/0x20
        bdi_register+0x90/0x240
        ? lockdep_init_map+0x57/0x200
        bdi_register_owner+0x36/0x60
        device_add_disk+0x1bb/0x4e0
        ? __pm_runtime_use_autosuspend+0x5c/0x70
        sd_probe_async+0x10d/0x1c0
        async_run_entry_fn+0x39/0x170
      
      This is a brute-force fix to pass the devt release information from
      sd_probe() to the locations where we register the bdi,
      device_add_disk(), and unregister the bdi, blk_cleanup_queue().
      
      Thanks to Omar for the quick reproducer script [2]. This patch survives
      where an unmodified kernel fails in a few seconds.
      
      [1]: https://marc.info/?l=linux-scsi&m=147116857810716&w=4
      [2]: http://marc.info/?l=linux-block&m=148554717109098&w=2
      
      Cc: James Bottomley <James.Bottomley@hansenpartnership.com>
      Cc: Bart Van Assche <bart.vanassche@sandisk.com>
      Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
      Cc: Jan Kara <jack@suse.cz>
      Reported-by: NOmar Sandoval <osandov@osandov.com>
      Tested-by: NOmar Sandoval <osandov@fb.com>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NBart Van Assche <bart.vanassche@sandisk.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      0dba1314
  23. 01 2月, 2017 1 次提交