1. 22 Jun, 2023 2 commits
    • Azeem Shaikh's avatar
      scsi: ncr53c8xx: Replace strlcpy() with strscpy() · d1e8a9fb
      Azeem Shaikh authored
      strlcpy() reads the entire source buffer first.  This read may exceed the
      destination size limit.  This is both inefficient and can lead to linear
      read overflows if a source string is not NUL-terminated [1].  In an effort
      to remove strlcpy() completely [2], replace strlcpy() here with strscpy().
      
      No return values were used, so direct replacement is safe.
      
      [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy
      [2] https://github.com/KSPP/linux/issues/89Signed-off-by: default avatarAzeem Shaikh <azeemshaikh38@gmail.com>
      Link: https://lore.kernel.org/r/20230621030033.3800351-2-azeemshaikh38@gmail.comReviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      d1e8a9fb
    • Arnd Bergmann's avatar
      scsi: lpfc: Fix lpfc_name struct packing · 00c2cae6
      Arnd Bergmann authored
      clang points out that the lpfc_name structure has an 8-byte alignment
      requirement on most architectures, but is embedded in a number of other
      structures that are forced to be only 1-byte aligned:
      
      drivers/scsi/lpfc/lpfc_hw.h:1516:30: error: field pe within 'struct lpfc_fdmi_reg_port_list' is less aligned than 'struct lpfc_fdmi_port_entry' and is usually due to 'struct lpfc_fdmi_reg_port_list' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
              struct lpfc_fdmi_port_entry pe;
      drivers/scsi/lpfc/lpfc_hw.h:850:19: error: field portName within 'struct _ADISC' is less aligned than 'struct lpfc_name' and is usually due to 'struct _ADISC' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
      drivers/scsi/lpfc/lpfc_hw.h:851:19: error: field nodeName within 'struct _ADISC' is less aligned than 'struct lpfc_name' and is usually due to 'struct _ADISC' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
      drivers/scsi/lpfc/lpfc_hw.h:922:19: error: field portName within 'struct _RNID' is less aligned than 'struct lpfc_name' and is usually due to 'struct _RNID' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
      drivers/scsi/lpfc/lpfc_hw.h:923:19: error: field nodeName within 'struct _RNID' is less aligned than 'struct lpfc_name' and is usually due to 'struct _RNID' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
      
      From the git history, I can see that all the __packed annotations were done
      specifically to avoid introducing implicit padding around the lpfc_name
      instances, though this was probably the wrong approach.
      
      To improve this, only annotate the one uint64_t field inside of lpfc_name
      as packed, with an explicit 4-byte alignment, as is the default already on
      the 32-bit x86 ABI but not on most others. With this, the other __packed
      annotations can be removed again, as this avoids the incorrect padding.
      
      Two other structures change their layout as a result of this change:
      
       - struct _LOGO never gained a __packed annotation even though it has the
         same alignment problem as the others but is not used anywhere in the
         driver today.
      
       - struct serv_param similarly has this issue, and it is used, my guess is
         that this is only an internal structure rather than part of a binary
         interface, so the padding has no negative effect here.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Link: https://lore.kernel.org/r/20230616090705.2623408-1-arnd@kernel.orgReviewed-by: default avatarJustin Tee <justin.tee@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      00c2cae6
  2. 16 Jun, 2023 23 commits
  3. 15 Jun, 2023 8 commits
  4. 08 Jun, 2023 7 commits