1. 10 Oct, 2023 3 commits
    • Justin Stitt's avatar
      scsi: message: fusion: Replace deprecated strncpy() with strscpy_pad() · 4280a0a7
      Justin Stitt authored
      strncpy() is deprecated for use on NUL-terminated destination strings [1]
      and as such we should prefer more robust and less ambiguous string
      interfaces.
      
      Since all these structs are copied out to userspace let's keep them
      NUL-padded by using strscpy_pad() which guarantees NUL-termination of the
      destination buffer while also providing the NUL-padding behavior that
      strncpy() has.
      
      Let's also opt to use the more idiomatic strscpy() usage of: 'dest, src,
      sizeof(dest)' in cases where the compiler can determine the size of the
      destination buffer. Do this for all cases of strscpy...() in this file.
      
      To be abundantly sure we don't leak stack data out to user space let's also
      change a strscpy() to strscpy_pad(). This strscpy() was introduced in
      commit dbe37c71 ("scsi: message: fusion: Replace all non-returning
      strlcpy() with strscpy()")
      
      Note that since we are creating these structs with a copy_from_user() and
      modifying fields and then copying back out to the user it is probably OK
      not to explicitly NUL-pad everything as any data leak is probably just data
      from the user themselves. If this is too eager, let's opt for strscpy()
      which is still in the spirit of removing deprecated strncpy() usage
      treewide.
      
      Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
      Link: https://github.com/KSPP/linux/issues/90
      Cc: linux-hardening@vger.kernel.org
      Cc: Kees Cook <keescook@chromium.org>
      Signed-off-by: default avatarJustin Stitt <justinstitt@google.com>
      Link: https://lore.kernel.org/r/20230927-strncpy-drivers-message-fusion-mptctl-c-v1-1-bb2eddc1743c@google.comReviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      4280a0a7
    • Peter Wang's avatar
      scsi: ufs: core: WLUN send SSU timeout recovery · 971237b9
      Peter Wang authored
      When runtime PM send SSU times out, the SCSI core invokes
      eh_host_reset_handler, in this case ufshcd_eh_host_reset_handler(), which
      is then stuck waiting for flush_work(&hba->eh_work). However,
      ufshcd_err_handler hangs in wait RPM resume. Do link recovery only in this
      case. The following IO hang stack dump was observed:
      
      kworker/4:0     D
      <ffffffd7d31f6fb4> __switch_to+0x180/0x344
      <ffffffd7d31f779c> __schedule+0x5ec/0xa14
      <ffffffd7d31f7c3c> schedule+0x78/0xe0
      <ffffffd7d31fefbc> schedule_timeout+0xb0/0x15c
      <ffffffd7d31f8120> io_schedule_timeout+0x48/0x70
      <ffffffd7d31f8e40> do_wait_for_common+0x108/0x19c
      <ffffffd7d31f837c> wait_for_completion_io_timeout+0x50/0x78
      <ffffffd7d2876bc0> blk_execute_rq+0x1b8/0x218
      <ffffffd7d2b4297c> scsi_execute_cmd+0x148/0x238
      <ffffffd7d2da7358> ufshcd_set_dev_pwr_mode+0xe8/0x244
      <ffffffd7d2da7e40> __ufshcd_wl_resume+0x1e0/0x45c
      <ffffffd7d2da7b28> ufshcd_wl_runtime_resume+0x3c/0x174
      <ffffffd7d2b4f290> scsi_runtime_resume+0x7c/0xc8
      <ffffffd7d2ae1d48> __rpm_callback+0xa0/0x410
      <ffffffd7d2ae0128> rpm_resume+0x43c/0x67c
      <ffffffd7d2ae1e98> __rpm_callback+0x1f0/0x410
      <ffffffd7d2ae014c> rpm_resume+0x460/0x67c
      <ffffffd7d2ae1450> pm_runtime_work+0xa4/0xac
      <ffffffd7d22e39ac> process_one_work+0x208/0x598
      <ffffffd7d22e3fc0> worker_thread+0x228/0x438
      <ffffffd7d22eb038> kthread+0x104/0x1d4
      <ffffffd7d22171a0> ret_from_fork+0x10/0x20
      
      scsi_eh_0       D
      <ffffffd7d31f6fb4> __switch_to+0x180/0x344
      <ffffffd7d31f779c> __schedule+0x5ec/0xa14
      <ffffffd7d31f7c3c> schedule+0x78/0xe0
      <ffffffd7d31fef50> schedule_timeout+0x44/0x15c
      <ffffffd7d31f8e40> do_wait_for_common+0x108/0x19c
      <ffffffd7d31f8234> wait_for_completion+0x48/0x64
      <ffffffd7d22deb88> __flush_work+0x260/0x2d0
      <ffffffd7d22de918> flush_work+0x10/0x20
      <ffffffd7d2da4728> ufshcd_eh_host_reset_handler+0x88/0xcc
      <ffffffd7d2b41da4> scsi_try_host_reset+0x48/0xe0
      <ffffffd7d2b410fc> scsi_eh_ready_devs+0x934/0xa40
      <ffffffd7d2b41618> scsi_error_handler+0x168/0x374
      <ffffffd7d22eb038> kthread+0x104/0x1d4
      <ffffffd7d22171a0> ret_from_fork+0x10/0x20
      
      kworker/u16:5   D
      <ffffffd7d31f6fb4> __switch_to+0x180/0x344
      <ffffffd7d31f779c> __schedule+0x5ec/0xa14
      <ffffffd7d31f7c3c> schedule+0x78/0xe0
      <ffffffd7d2adfe00> rpm_resume+0x114/0x67c
      <ffffffd7d2adfca8> __pm_runtime_resume+0x70/0xb4
      <ffffffd7d2d9cf48> ufshcd_err_handler+0x1a0/0xe68
      <ffffffd7d22e39ac> process_one_work+0x208/0x598
      <ffffffd7d22e3fc0> worker_thread+0x228/0x438
      <ffffffd7d22eb038> kthread+0x104/0x1d4
      <ffffffd7d22171a0> ret_from_fork+0x10/0x20
      Signed-off-by: default avatarPeter Wang <peter.wang@mediatek.com>
      Link: https://lore.kernel.org/r/20230927033557.13801-1-peter.wang@mediatek.comReviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
      Reviewed-by: default avatarStanley Chu <stanley.chu@mediatek.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      971237b9
    • Martin K. Petersen's avatar
      Merge patch series "ibmvfc: fixes and generic prep work for NVMeoF support" · dc718994
      Martin K. Petersen authored
      Tyrel Datwyler <tyreld@linux.ibm.com> says:
      
      This series includes a couple minor fixes, generalization of some code
      that is not protocol specific, and a reworking of the way event pool
      buffers are accounted for by the driver. This is a precursor to a
      series to follow that introduces support for NVMeoF protocol with
      ibmvfc.
      
      Link: https://lore.kernel.org/r/20230921225435.3537728-1-tyreld@linux.ibm.comSigned-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      dc718994
  2. 27 Sep, 2023 8 commits
  3. 22 Sep, 2023 25 commits
  4. 14 Sep, 2023 4 commits