linux/drivers/scsi/lpfc
Justin Stitt e100c01efa scsi: lpfc: Replace deprecated strncpy() with strscpy()
strncpy() is deprecated for use on NUL-terminated destination strings [1]
and as such we should prefer more robust and less ambiguous string
interfaces.

We expect ae->value_string to be NUL-terminated because there's a comment
that says as much; these attr strings are also used with other string APIs,
further cementing the fact.

Now, the question of whether or not to NUL-pad the destination buffer:
lpfc_fdmi_rprt_defer() initializes vports (all zero-initialized), then we
call lpfc_fdmi_cmd() with each vport and a mask. Then, inside of
lpfc_fdmi_cmd() we check each bit in the mask to invoke the proper
callback. Importantly, the zero-initialized vport is passed in as the
"attr" parameter. Seeing this:
|	struct lpfc_fdmi_attr_string *ae = attr;
... we can tell that ae->value_string is entirely zero-initialized. Due
to this, NUL-padding is _not_ required as it would be redundant.

Considering the above, a suitable replacement is strscpy() [2].

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2]
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Link: https://lore.kernel.org/r/20240226-strncpy-drivers-scsi-lpfc-lpfc_ct-c-v2-1-2df2e46569b9@google.com
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-26 21:18:52 -05:00
..
lpfc_attr.c scsi: lpfc: Copyright updates for 14.4.0.0 patches 2024-02-05 20:51:36 -05:00
lpfc_attr.h
lpfc_bsg.c scsi: lpfc: Copyright updates for 14.4.0.0 patches 2024-02-05 20:51:36 -05:00
lpfc_bsg.h
lpfc_compat.h
lpfc_crtn.h scsi: lpfc: Replace blk_irq_poll intr handler with threaded IRQ 2023-05-08 07:16:05 -04:00
lpfc_ct.c scsi: lpfc: Replace deprecated strncpy() with strscpy() 2024-02-26 21:18:52 -05:00
lpfc_debugfs.c scsi: lpfc: Copyright updates for 14.4.0.0 patches 2024-02-05 20:51:36 -05:00
lpfc_debugfs.h scsi: lpfc: Copyright updates for 14.2.0.6 patches 2022-08-31 23:39:58 -04:00
lpfc_disc.h scsi: lpfc: Fix multiple NVMe remoteport registration calls for the same NPort ID 2022-09-15 22:18:27 -04:00
lpfc_els.c scsi: lpfc: Copyright updates for 14.4.0.0 patches 2024-02-05 20:51:36 -05:00
lpfc_hbadisc.c scsi: lpfc: Copyright updates for 14.4.0.0 patches 2024-02-05 20:51:36 -05:00
lpfc_hw4.h scsi: lpfc: Copyright updates for 14.4.0.0 patches 2024-02-05 20:51:36 -05:00
lpfc_hw.h scsi: lpfc: Set Establish Image Pair service parameter only for Target Functions 2023-07-23 16:17:07 -04:00
lpfc_ids.h
lpfc_init.c scsi: lpfc: Copyright updates for 14.4.0.0 patches 2024-02-05 20:51:36 -05:00
lpfc_logmsg.h scsi: lpfc: Introduce LOG_NODE_VERBOSE messaging flag 2023-10-13 16:58:27 -04:00
lpfc_mbox.c scsi: lpfc: Copyright updates for 14.4.0.0 patches 2024-02-05 20:51:36 -05:00
lpfc_mem.c scsi: lpfc: Copyright updates for 14.2.0.16 patches 2023-11-15 09:52:58 -05:00
lpfc_nl.h
lpfc_nportdisc.c scsi: lpfc: Copyright updates for 14.4.0.0 patches 2024-02-05 20:51:36 -05:00
lpfc_nvme.c scsi: lpfc: Copyright updates for 14.4.0.0 patches 2024-02-05 20:51:36 -05:00
lpfc_nvme.h
lpfc_nvmet.c scsi: lpfc: Copyright updates for 14.4.0.0 patches 2024-02-05 20:51:36 -05:00
lpfc_scsi.c scsi: lpfc: Copyright updates for 14.4.0.0 patches 2024-02-05 20:51:36 -05:00
lpfc_scsi.h scsi: lpfc: Copyright updates for 14.2.0.6 patches 2022-08-31 23:39:58 -04:00
lpfc_sli4.h scsi: lpfc: Replace blk_irq_poll intr handler with threaded IRQ 2023-05-08 07:16:05 -04:00
lpfc_sli.c scsi: lpfc: Copyright updates for 14.4.0.0 patches 2024-02-05 20:51:36 -05:00
lpfc_sli.h scsi: lpfc: Copyright updates for 14.2.0.16 patches 2023-11-15 09:52:58 -05:00
lpfc_version.h scsi: lpfc: Copyright updates for 14.4.0.0 patches 2024-02-05 20:51:36 -05:00
lpfc_vmid.c scsi: lpfc: Move determination of vmid_flag after VMID reinitialization completes 2023-12-13 22:17:57 -05:00
lpfc_vport.c scsi: lpfc: Copyright updates for 14.4.0.0 patches 2024-02-05 20:51:36 -05:00
lpfc_vport.h scsi: lpfc: Copyright updates for 14.2.0.6 patches 2022-08-31 23:39:58 -04:00
lpfc.h scsi: lpfc: Copyright updates for 14.4.0.0 patches 2024-02-05 20:51:36 -05:00
Makefile