Skip to content
Snippets Groups Projects
  1. Dec 19, 2018
  2. Dec 08, 2018
  3. Nov 26, 2018
  4. Nov 10, 2018
  5. Nov 07, 2018
  6. Aug 02, 2018
    • Kees Cook's avatar
      scsi: Check sense buffer size at build time · 704f8392
      Kees Cook authored
      
      To avoid introducing problems like those fixed in commit f7068114
      ("sr: pass down correctly sized SCSI sense buffer"), this creates a macro
      wrapper for scsi_execute() that verifies the size of the sense buffer
      similar to what was done for command string sizes in commit 3756f640
      ("exec: avoid gcc-8 warning for get_task_comm").
      
      Another solution could be to add a length argument to scsi_execute(),
      but this function already takes a lot of arguments and Jens was not fond
      of that approach.
      
      Additionally, this moves the SCSI_SENSE_BUFFERSIZE definition into
      scsi_device.h, and removes a redundant include for scsi_device.h from
      scsi_cmnd.h.
      
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      704f8392
  7. Jul 30, 2018
  8. Jun 26, 2018
    • Ming Lei's avatar
      scsi: read host_busy via scsi_host_busy() · c84b023a
      Ming Lei authored
      
      No functional change.
      
      Just introduce scsi_host_busy() and replace the direct read of
      scsi_host->host_busy with this new API.
      
      Cc: Omar Sandoval <osandov@fb.com>,
      Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
      Cc: James Bottomley <james.bottomley@hansenpartnership.com>,
      Cc: Christoph Hellwig <hch@lst.de>,
      Cc: Don Brace <don.brace@microsemi.com>
      Cc: Kashyap Desai <kashyap.desai@broadcom.com>
      Cc: Mike Snitzer <snitzer@redhat.com>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Laurence Oberman <loberman@redhat.com>
      Cc: Bart Van Assche <bart.vanassche@wdc.com>
      
      Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
      Reviewed-by: default avatarBart Van Assche <bart.vanassche@wdc.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      c84b023a
  9. Jun 20, 2018
    • Jason Yan's avatar
      scsi: libsas: dynamically allocate and free ata host · 2fa4a326
      Jason Yan authored
      
      Commit 2623c7a5 ("libata: add refcounting to ata_host") v4.17+ introduced
      refcounting to ata_host and will increase or decrease the refcount when
      adding or deleting transport ATA port.
      
      Now the ata host for libsas is embedded in domain_device, and the ->kref
      member is not initialized. Afer we add ata transport class, ata_host_get()
      will be called when adding transport ATA port and a warning will be
      triggered as below:
      
      refcount_t: increment on 0; use-after-free.
      WARNING: CPU: 2 PID: 103 at
      lib/refcount.c:153 refcount_inc+0x40/0x48 ......  Call trace:
       refcount_inc+0x40/0x48
       ata_host_get+0x10/0x18
       ata_tport_add+0x40/0x120
       ata_sas_tport_add+0xc/0x14
       sas_ata_init+0x7c/0xc8
       sas_discover_domain+0x380/0x53c
       process_one_work+0x12c/0x288
       worker_thread+0x58/0x3f0
       kthread+0xfc/0x128
       ret_from_fork+0x10/0x18
      
      And also when removing transport ATA port ata_host_put() will be called and
      another similar warning will be triggered. If the refcount decreased to
      zero, the ata host will be freed. But this ata host is only part of
      domain_device, it cannot be freed directly.
      
      So we have to change this embedded static ata host to a dynamically
      allocated ata host and initialize the ->kref member. To use ata_host_get()
      and ata_host_put() in libsas, we need to move the declaration of these
      functions to the public libata.h and export them.
      
      Fixes: b6240a4d ("scsi: libsas: add transport class for ATA devices")
      Signed-off-by: default avatarJason Yan <yanaijie@huawei.com>
      CC: John Garry <john.garry@huawei.com>
      CC: Taras Kondratiuk <takondra@cisco.com>
      CC: Tejun Heo <tj@kernel.org>
      Acked-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      2fa4a326
  10. May 29, 2018
  11. May 14, 2018
  12. Apr 20, 2018
  13. Apr 19, 2018
  14. Mar 20, 2018
  15. Mar 16, 2018
  16. Mar 15, 2018
  17. Mar 13, 2018
  18. Mar 02, 2018
  19. Feb 15, 2018
  20. Jan 23, 2018
  21. Jan 11, 2018
    • Jason Yan's avatar
      scsi: libsas: direct call probe and destruct · 0558f33c
      Jason Yan authored
      
      In commit 87c8331f ("[SCSI] libsas: prevent domain rediscovery
      competing with ata error handling") introduced disco mutex to prevent
      rediscovery competing with ata error handling and put the whole
      revalidation in the mutex. But the rphy add/remove needs to wait for the
      error handling which also grabs the disco mutex. This may leads to dead
      lock.So the probe and destruct event were introduce to do the rphy
      add/remove asynchronously and out of the lock.
      
      The asynchronously processed workers makes the whole discovery process
      not atomic, the other events may interrupt the process. For example,
      if a loss of signal event inserted before the probe event, the
      sas_deform_port() is called and the port will be deleted.
      
      And sas_port_delete() may run before the destruct event, but the
      port-x:x is the top parent of end device or expander. This leads to
      a kernel WARNING such as:
      
      [   82.042979] sysfs group 'power' not found for kobject 'phy-1:0:22'
      [   82.042983] ------------[ cut here ]------------
      [   82.042986] WARNING: CPU: 54 PID: 1714 at fs/sysfs/group.c:237
      sysfs_remove_group+0x94/0xa0
      [   82.043059] Call trace:
      [   82.043082] [<ffff0000082e7624>] sysfs_remove_group+0x94/0xa0
      [   82.043085] [<ffff00000864e320>] dpm_sysfs_remove+0x60/0x70
      [   82.043086] [<ffff00000863ee10>] device_del+0x138/0x308
      [   82.043089] [<ffff00000869a2d0>] sas_phy_delete+0x38/0x60
      [   82.043091] [<ffff00000869a86c>] do_sas_phy_delete+0x6c/0x80
      [   82.043093] [<ffff00000863dc20>] device_for_each_child+0x58/0xa0
      [   82.043095] [<ffff000008696f80>] sas_remove_children+0x40/0x50
      [   82.043100] [<ffff00000869d1bc>] sas_destruct_devices+0x64/0xa0
      [   82.043102] [<ffff0000080e93bc>] process_one_work+0x1fc/0x4b0
      [   82.043104] [<ffff0000080e96c0>] worker_thread+0x50/0x490
      [   82.043105] [<ffff0000080f0364>] kthread+0xfc/0x128
      [   82.043107] [<ffff0000080836c0>] ret_from_fork+0x10/0x50
      
      Make probe and destruct a direct call in the disco and revalidate function,
      but put them outside the lock. The whole discovery or revalidate won't
      be interrupted by other events. And the DISCE_PROBE and DISCE_DESTRUCT
      event are deleted as a result of the direct call.
      
      Introduce a new list to destruct the sas_port and put the port delete after
      the destruct. This makes sure the right order of destroying the sysfs
      kobject and fix the warning above.
      
      In sas_ex_revalidate_domain() have a loop to find all broadcasted
      device, and sometimes we have a chance to find the same expander twice.
      Because the sas_port will be deleted at the end of the whole revalidate
      process, sas_port with the same name cannot be added before this.
      Otherwise the sysfs will complain of creating duplicate filename. Since
      the LLDD will send broadcast for every device change, we can only
      process one expander's revalidation.
      
      [mkp: kbuild test robot warning]
      
      Signed-off-by: default avatarJason Yan <yanaijie@huawei.com>
      CC: John Garry <john.garry@huawei.com>
      CC: Johannes Thumshirn <jthumshirn@suse.de>
      CC: Ewan Milne <emilne@redhat.com>
      CC: Christoph Hellwig <hch@lst.de>
      CC: Tomas Henzl <thenzl@redhat.com>
      CC: Dan Williams <dan.j.williams@intel.com>
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      0558f33c
  22. Jan 09, 2018
  23. Jan 04, 2018
  24. Dec 08, 2017
  25. Nov 22, 2017
  26. Nov 16, 2017
Loading