1. 04 1月, 2022 4 次提交
  2. 17 12月, 2021 1 次提交
  3. 09 12月, 2021 1 次提交
  4. 06 12月, 2021 1 次提交
  5. 02 12月, 2021 1 次提交
  6. 29 11月, 2021 3 次提交
    • B
      sata_fsl: fix warning in remove_proc_entry when rmmod sata_fsl · 6f48394c
      Baokun Li 提交于
      Trying to remove the fsl-sata module in the PPC64 GNU/Linux
      leads to the following warning:
       ------------[ cut here ]------------
       remove_proc_entry: removing non-empty directory 'irq/69',
         leaking at least 'fsl-sata[ff0221000.sata]'
       WARNING: CPU: 3 PID: 1048 at fs/proc/generic.c:722
         .remove_proc_entry+0x20c/0x220
       IRQMASK: 0
       NIP [c00000000033826c] .remove_proc_entry+0x20c/0x220
       LR [c000000000338268] .remove_proc_entry+0x208/0x220
       Call Trace:
        .remove_proc_entry+0x208/0x220 (unreliable)
        .unregister_irq_proc+0x104/0x140
        .free_desc+0x44/0xb0
        .irq_free_descs+0x9c/0xf0
        .irq_dispose_mapping+0x64/0xa0
        .sata_fsl_remove+0x58/0xa0 [sata_fsl]
        .platform_drv_remove+0x40/0x90
        .device_release_driver_internal+0x160/0x2c0
        .driver_detach+0x64/0xd0
        .bus_remove_driver+0x70/0xf0
        .driver_unregister+0x38/0x80
        .platform_driver_unregister+0x14/0x30
        .fsl_sata_driver_exit+0x18/0xa20 [sata_fsl]
       ---[ end trace 0ea876d4076908f5 ]---
      
      The driver creates the mapping by calling irq_of_parse_and_map(),
      so it also has to dispose the mapping. But the easy way out is to
      simply use platform_get_irq() instead of irq_of_parse_map(). Also
      we should adapt return value checking and propagate error values.
      
      In this case the mapping is not managed by the device but by
      the of core, so the device has not to dispose the mapping.
      
      Fixes: faf0b2e5 ("drivers/ata: add support to Freescale 3.0Gbps SATA Controller")
      Cc: stable@vger.kernel.org
      Reported-by: NHulk Robot <hulkci@huawei.com>
      Signed-off-by: NBaokun Li <libaokun1@huawei.com>
      Reviewed-by: NSergei Shtylyov <sergei.shtylyov@gmail.com>
      Signed-off-by: NDamien Le Moal <damien.lemoal@opensource.wdc.com>
      6f48394c
    • B
      sata_fsl: fix UAF in sata_fsl_port_stop when rmmod sata_fsl · 6c8ad7e8
      Baokun Li 提交于
      When the `rmmod sata_fsl.ko` command is executed in the PPC64 GNU/Linux,
      a bug is reported:
       ==================================================================
       BUG: Unable to handle kernel data access on read at 0x80000800805b502c
       Oops: Kernel access of bad area, sig: 11 [#1]
       NIP [c0000000000388a4] .ioread32+0x4/0x20
       LR [80000000000c6034] .sata_fsl_port_stop+0x44/0xe0 [sata_fsl]
       Call Trace:
        .free_irq+0x1c/0x4e0 (unreliable)
        .ata_host_stop+0x74/0xd0 [libata]
        .release_nodes+0x330/0x3f0
        .device_release_driver_internal+0x178/0x2c0
        .driver_detach+0x64/0xd0
        .bus_remove_driver+0x70/0xf0
        .driver_unregister+0x38/0x80
        .platform_driver_unregister+0x14/0x30
        .fsl_sata_driver_exit+0x18/0xa20 [sata_fsl]
        .__se_sys_delete_module+0x1ec/0x2d0
        .system_call_exception+0xfc/0x1f0
        system_call_common+0xf8/0x200
       ==================================================================
      
      The triggering of the BUG is shown in the following stack:
      
      driver_detach
        device_release_driver_internal
          __device_release_driver
            drv->remove(dev) --> platform_drv_remove/platform_remove
              drv->remove(dev) --> sata_fsl_remove
                iounmap(host_priv->hcr_base);			<---- unmap
                kfree(host_priv);                             <---- free
            devres_release_all
              release_nodes
                dr->node.release(dev, dr->data) --> ata_host_stop
                  ap->ops->port_stop(ap) --> sata_fsl_port_stop
                      ioread32(hcr_base + HCONTROL)           <---- UAF
                  host->ops->host_stop(host)
      
      The iounmap(host_priv->hcr_base) and kfree(host_priv) functions should
      not be executed in drv->remove. These functions should be executed in
      host_stop after port_stop. Therefore, we move these functions to the
      new function sata_fsl_host_stop and bind the new function to host_stop.
      
      Fixes: faf0b2e5 ("drivers/ata: add support to Freescale 3.0Gbps SATA Controller")
      Cc: stable@vger.kernel.org
      Reported-by: NHulk Robot <hulkci@huawei.com>
      Signed-off-by: NBaokun Li <libaokun1@huawei.com>
      Reviewed-by: NSergei Shtylyov <sergei.shtylyov@gmail.com>
      Signed-off-by: NDamien Le Moal <damien.lemoal@opensource.wdc.com>
      6c8ad7e8
    • F
      pata_falcon: Avoid type warnings from sparse · 5fad5077
      Finn Thain 提交于
      The zero day bot reported some sparse complaints in pata_falcon.c. E.g.
      
      drivers/ata/pata_falcon.c:58:41: warning: cast removes address space '__iomem' of expression
      drivers/ata/pata_falcon.c:58:41: warning: incorrect type in argument 1 (different address spaces)
      drivers/ata/pata_falcon.c:58:41:    expected unsigned short volatile [noderef] [usertype] __iomem *port
      drivers/ata/pata_falcon.c:58:41:    got unsigned short [usertype] *
      
      The same thing shows up in 8 places, all told. Avoid this by removing
      unnecessary type casts.
      
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Michael Schmitz <schmitzmic@gmail.com>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Reported-by: Nkernel test robot <lkp@intel.com>
      Suggested-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: NFinn Thain <fthain@linux-m68k.org>
      Reviewed-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: NDamien Le Moal <damien.lemoal@opensource.wdc.com>
      5fad5077
  7. 18 11月, 2021 4 次提交
  8. 17 11月, 2021 1 次提交
  9. 12 11月, 2021 2 次提交
  10. 11 11月, 2021 2 次提交
    • X
      ata: sata_highbank: Remove unnecessary print function dev_err() · 51839e25
      Xu Wang 提交于
      The print function dev_err() is redundant because
      platform_get_irq() already prints an error.
      Signed-off-by: NXu Wang <vulab@iscas.ac.cn>
      Signed-off-by: NDamien Le Moal <damien.lemoal@opensource.wdc.com>
      51839e25
    • D
      libata: fix read log timeout value · 68dbbe7d
      Damien Le Moal 提交于
      Some ATA drives are very slow to respond to READ_LOG_EXT and
      READ_LOG_DMA_EXT commands issued from ata_dev_configure() when the
      device is revalidated right after resuming a system or inserting the
      ATA adapter driver (e.g. ahci). The default 5s timeout
      (ATA_EH_CMD_DFL_TIMEOUT) used for these commands is too short, causing
      errors during the device configuration. Ex:
      
      ...
      ata9: SATA max UDMA/133 abar m524288@0x9d200000 port 0x9d200400 irq 209
      ata9: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
      ata9.00: ATA-9: XXX  XXXXXXXXXXXXXXX, XXXXXXXX, max UDMA/133
      ata9.00: qc timeout (cmd 0x2f)
      ata9.00: Read log page 0x00 failed, Emask 0x4
      ata9.00: Read log page 0x00 failed, Emask 0x40
      ata9.00: NCQ Send/Recv Log not supported
      ata9.00: Read log page 0x08 failed, Emask 0x40
      ata9.00: 27344764928 sectors, multi 16: LBA48 NCQ (depth 32), AA
      ata9.00: Read log page 0x00 failed, Emask 0x40
      ata9.00: ATA Identify Device Log not supported
      ata9.00: failed to set xfermode (err_mask=0x40)
      ata9: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
      ata9.00: configured for UDMA/133
      ...
      
      The timeout error causes a soft reset of the drive link, followed in
      most cases by a successful revalidation as that give enough time to the
      drive to become fully ready to quickly process the read log commands.
      However, in some cases, this also fails resulting in the device being
      dropped.
      
      Fix this by using adding the ata_eh_revalidate_timeouts entries for the
      READ_LOG_EXT and READ_LOG_DMA_EXT commands. This defines a timeout
      increased to 15s, retriable one time.
      Reported-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Tested-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Cc: stable@vger.kernel.org
      Signed-off-by: NDamien Le Moal <damien.lemoal@opensource.wdc.com>
      68dbbe7d
  11. 27 10月, 2021 1 次提交
  12. 25 10月, 2021 1 次提交
  13. 17 10月, 2021 2 次提交
  14. 14 10月, 2021 1 次提交
    • W
      ata: ahci_platform: fix null-ptr-deref in ahci_platform_enable_regulators() · 776c7501
      Wang Hai 提交于
      I got a null-ptr-deref report:
      
      KASAN: null-ptr-deref in range [0x0000000000000090-0x0000000000000097]
      ...
      RIP: 0010:regulator_enable+0x84/0x260
      ...
      Call Trace:
       ahci_platform_enable_regulators+0xae/0x320
       ahci_platform_enable_resources+0x1a/0x120
       ahci_probe+0x4f/0x1b9
       platform_probe+0x10b/0x280
      ...
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      If devm_regulator_get() in ahci_platform_get_resources() fails,
      hpriv->phy_regulator will point to NULL, when enabling or disabling it,
      null-ptr-deref will occur.
      
      ahci_probe()
      	ahci_platform_get_resources()
      		devm_regulator_get(, "phy") // failed, let phy_regulator = NULL
      	ahci_platform_enable_resources()
      		ahci_platform_enable_regulators()
      			regulator_enable(hpriv->phy_regulator) // null-ptr-deref
      
      commit 962399bb ("ata: libahci_platform: Fix regulator_get_optional()
      misuse") replaces devm_regulator_get_optional() with devm_regulator_get(),
      but PHY regulator omits to delete "hpriv->phy_regulator = NULL;" like AHCI.
      Delete it like AHCI regulator to fix this bug.
      
      Fixes: commit 962399bb ("ata: libahci_platform: Fix regulator_get_optional() misuse")
      Reported-by: NHulk Robot <hulkci@huawei.com>
      Signed-off-by: NWang Hai <wanghai38@huawei.com>
      Reviewed-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      776c7501
  15. 12 10月, 2021 8 次提交
  16. 21 9月, 2021 1 次提交
  17. 03 9月, 2021 2 次提交
  18. 18 8月, 2021 4 次提交
    • D
      libata: Introduce ncq_prio_supported sysfs sttribute · 5f91b8f5
      Damien Le Moal 提交于
      Currently, the only way a user can determine if a SATA device supports
      NCQ priority is to try to enable the use of this feature using the
      ncq_prio_enable sysfs device attribute. If enabling the feature fails,
      it is because the device does not support NCQ priority. Otherwise, the
      feature is enabled and success indicates that the device supports NCQ
      priority.
      
      Improve this odd interface by introducing the read-only
      ncq_prio_supported sysfs device attribute to indicate if a SATA device
      supports NCQ priority. The value of this attribute reflects the status
      of device flag ATA_DFLAG_NCQ_PRIO, which is set only for devices
      supporting NCQ priority.
      
      Add this new sysfs attribute to the device attributes group of libahci
      and libata-sata.
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Link: https://lore.kernel.org/r/20210816014456.2191776-10-damien.lemoal@wdc.comSigned-off-by: NJens Axboe <axboe@kernel.dk>
      5f91b8f5
    • D
      libata: print feature list on device scan · d633b8a7
      Damien Le Moal 提交于
      Print a list of features supported by a drive when it is configured in
      ata_dev_configure() using the new function ata_dev_print_features().
      The features printed are not already advertized and are: trusted
      send-recev support, device attention support, device sleep support,
      NCQ send-recv support and NCQ priority support.
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Reviewed-by: NHannes Reinecke <hare@suse.de>
      Link: https://lore.kernel.org/r/20210816014456.2191776-9-damien.lemoal@wdc.comSigned-off-by: NJens Axboe <axboe@kernel.dk>
      d633b8a7
    • D
      libata: fix ata_read_log_page() warning · fc5c8aa7
      Damien Le Moal 提交于
      Support for the READ LOG PAGE DMA EXT command is indicated by words 119
      and 120 of a device identify data. This is tested in
      ata_read_log_page() with ata_id_has_read_log_dma_ext() and the
      READ LOG PAGE DMA command used if the device reports supports for it.
      
      However, some devices lie about this support and using the DMA version
      of the command fails, generating the warning message "READ LOG DMA EXT
      failed, trying PIO". Since READ LOG PAGE DMA EXT is an optional command,
      this warning is not at all important but may be scary for the user.
      Change ata_read_log_page() to suppres this warning and to print an
      error message if both DMA and PIO attempts failed.
      
      With this change, there is no need to print again an error message when
      ata_read_log_page() returns an error. So simplify the users of this
      function.
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Reviewed-by: NHannes Reinecke <hare@suse.de>
      Link: https://lore.kernel.org/r/20210816014456.2191776-8-damien.lemoal@wdc.comSigned-off-by: NJens Axboe <axboe@kernel.dk>
      fc5c8aa7
    • D
      libata: cleanup NCQ priority handling · 2360fa18
      Damien Le Moal 提交于
      The ata device flag ATA_DFLAG_NCQ_PRIO indicates if a device supports
      the NCQ Priority feature while the ATA_DFLAG_NCQ_PRIO_ENABLE device
      flag indicates if the feature is enabled. Enabling NCQ priority use is
      controlled by the user through the device sysfs attribute
      ncq_prio_enable. As a result, the ATA_DFLAG_NCQ_PRIO flag should not be
      cleared when ATA_DFLAG_NCQ_PRIO_ENABLE is not set as the device still
      supports the feature even after the user disables it. This leads to the
      following cleanups:
      - In ata_build_rw_tf(), set a command high priority bit based on the
        ATA_DFLAG_NCQ_PRIO_ENABLE flag, not on the ATA_DFLAG_NCQ flag. That
        is, set a command high priority only if the user enabled NCQ priority
        use.
      - In ata_dev_config_ncq_prio(), ATA_DFLAG_NCQ_PRIO should not be cleared
        if ATA_DFLAG_NCQ_PRIO_ENABLE is not set. If the device does not
        support NCQ priority, both ATA_DFLAG_NCQ_PRIO and
        ATA_DFLAG_NCQ_PRIO_ENABLE must be cleared.
      
      With the above ata_dev_config_ncq_prio() change, ATA_DFLAG_NCQ_PRIO flag
      is set on device scan and revalidation. There is no need to trigger a
      device revalidation in ata_ncq_prio_enable_store() when the user enables
      the use of NCQ priority. Remove the revalidation code from that funciton
      to simplify it. Also change the return value from -EIO to -EINVAL when a
      user tries to enable NCQ priority for a device that does not support
      this feature.  While at it, also simplify ata_ncq_prio_enable_show().
      
      Overall, there is no functional change introduced by this patch.
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Reviewed-by: NHannes Reinecke <hare@suse.de>
      Link: https://lore.kernel.org/r/20210816014456.2191776-7-damien.lemoal@wdc.comSigned-off-by: NJens Axboe <axboe@kernel.dk>
      2360fa18