linux/drivers/scsi/lpfc
Gustavo A. R. Silva a48e2c328c scsi: lpfc: Avoid -Wstringop-overflow warning
Prevent any potential integer wrapping issue, and avoid a
-Wstringop-overflow warning by using the check_mul_overflow() helper.

drivers/scsi/lpfc/lpfc.h:
837:#define LPFC_RAS_MIN_BUFF_POST_SIZE (256 * 1024)

drivers/scsi/lpfc/lpfc_debugfs.c:
2266 size = LPFC_RAS_MIN_BUFF_POST_SIZE * phba->cfg_ras_fwlog_buffsize;

this can wrap to negative if cfg_ras_fwlog_buffsize is large
enough. And even when in practice this is not possible (due to
phba->cfg_ras_fwlog_buffsize never being larger than 4[1]), the
compiler is legitimately warning us about potentially buggy code.

Fix the following warning seen under GCC-13:
In function ‘lpfc_debugfs_ras_log_data’,
    inlined from ‘lpfc_debugfs_ras_log_open’ at drivers/scsi/lpfc/lpfc_debugfs.c:2271:15:
drivers/scsi/lpfc/lpfc_debugfs.c:2210:25: warning: ‘memcpy’ specified bound between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
 2210 |                         memcpy(buffer + copied, dmabuf->virt,
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2211 |                                size - copied - 1);
      |                                ~~~~~~~~~~~~~~~~~~

Link: https://github.com/KSPP/linux/issues/305
Link: https://lore.kernel.org/linux-hardening/CABPRKS8zyzrbsWt4B5fp7kMowAZFiMLKg5kW26uELpg1cDKY3A@mail.gmail.com/ [1]
Co-developed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/ZHkseX6TiFahvxJA@work
Reviewed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-06-07 21:20:21 -04:00
..
lpfc_attr.c scsi: lpfc: Update congestion warning notification period 2023-05-08 07:16:05 -04:00
lpfc_attr.h
lpfc_bsg.c scsi: lpfc: Copyright updates for 14.2.0.11 patches 2023-03-09 21:21:45 -05:00
lpfc_bsg.h scsi: lpfc: Copyright updates for 14.2.0.5 patches 2022-07-07 17:21:44 -04:00
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: Use struct_size() helper 2023-06-07 21:20:21 -04:00
lpfc_debugfs.c scsi: lpfc: Avoid -Wstringop-overflow warning 2023-06-07 21:20:21 -04: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: Revise NPIV ELS unsol rcv cmpl logic to drop ndlp based on nlp_state 2023-05-31 18:14:20 -04:00
lpfc_hbadisc.c Merge patch series "lpfc: Update lpfc to revision 14.2.0.13" 2023-05-31 18:15:07 -04:00
lpfc_hw4.h scsi: lpfc: Clean up SLI-4 CQE status handling 2023-05-31 18:14:20 -04:00
lpfc_hw.h scsi: lpfc: Fix incorrect big endian type assignments in FDMI and VMID paths 2023-05-31 18:17:52 -04:00
lpfc_ids.h scsi: lpfc: Copyright updates for 14.2.0.5 patches 2022-07-07 17:21:44 -04:00
lpfc_init.c scsi: lpfc: Enhance congestion statistics collection 2023-05-31 18:14:20 -04:00
lpfc_logmsg.h scsi: lpfc: Copyright updates for 14.2.0.13 patches 2023-05-31 18:14:20 -04:00
lpfc_mbox.c scsi: lpfc: Fix double word in comments 2023-02-21 22:00:51 -05:00
lpfc_mem.c scsi: lpfc: Copyright updates for 14.2.0.6 patches 2022-08-31 23:39:58 -04:00
lpfc_nl.h
lpfc_nportdisc.c scsi: lpfc: Fix port stuck in bypassed state after LIP in PT2PT topology 2022-06-07 21:38:18 -04:00
lpfc_nvme.c scsi: lpfc: Clean up SLI-4 CQE status handling 2023-05-31 18:14:20 -04:00
lpfc_nvme.h scsi: lpfc: Copyright updates for 14.2.0.0 patches 2022-03-15 13:51:50 -04:00
lpfc_nvmet.c scsi: lpfc: Copyright updates for 14.2.0.13 patches 2023-05-31 18:14:20 -04:00
lpfc_scsi.c scsi: lpfc: Clean up SLI-4 CQE status handling 2023-05-31 18:14:20 -04: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: Change firmware upgrade logging to KERN_NOTICE instead of TRACE_EVENT 2023-05-31 18:14:20 -04:00
lpfc_sli.h scsi: lpfc: Remove Menlo/Hornet related code 2022-07-07 17:21:44 -04:00
lpfc_version.h scsi: lpfc: Update lpfc version to 14.2.0.13 2023-05-31 18:14:20 -04:00
lpfc_vmid.c scsi: lpfc: Copyright updates for 14.2.0.10 patches 2023-01-12 00:03:15 -05:00
lpfc_vport.c scsi: lpfc: Copyright updates for 14.2.0.10 patches 2023-01-12 00:03:15 -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: Enhance congestion statistics collection 2023-05-31 18:14:20 -04:00
Makefile scsi: lpfc: Commonize VMID code location 2022-05-19 20:24:56 -04:00