linux/drivers/scsi/mpi3mr
Shin'ichiro Kawasaki fb428a2005 scsi: mpi3mr: Fix issues in mpi3mr_get_all_tgt_info()
The function mpi3mr_get_all_tgt_info() has four issues:

1) It calculates valid entry length in alltgt_info assuming the header part
   of the struct mpi3mr_device_map_info would equal to sizeof(u32).  The
   correct size is sizeof(u64).

2) When it calculates the valid entry length kern_entrylen, it excludes one
   entry by subtracting 1 from num_devices.

3) It copies num_device by calling memcpy(). Substitution is enough.

4) It does not specify the calculated length to sg_copy_from_buffer().
   Instead, it specifies the payload length which is larger than the
   alltgt_info size. It causes "BUG: KASAN: slab-out-of-bounds".

Fix the issues by using the correct header size, removing the subtraction
from num_devices, replacing the memcpy() with substitution and specifying
the correct length to sg_copy_from_buffer().

Link: https://lore.kernel.org/r/20230214005019.1897251-2-shinichiro.kawasaki@wdc.com
Cc: stable@vger.kernel.org
Fixes: f5e6d5a343 ("scsi: mpi3mr: Add support for driver commands")
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Acked-by: Sathya Prakash Veerichetty <sathya.prakash@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-21 22:00:50 -05:00
..
mpi scsi: mpi3mr: Update mpi3 header files 2022-09-25 13:49:51 -04:00
Kconfig scsi: mpi3mr: Select CONFIG_SCSI_SAS_ATTRS 2022-10-22 03:14:51 +00:00
Makefile scsi: mpi3mr: Add framework to add phys to STL 2022-08-22 23:34:05 -04:00
mpi3mr_app.c scsi: mpi3mr: Fix issues in mpi3mr_get_all_tgt_info() 2023-02-21 22:00:50 -05:00
mpi3mr_debug.h scsi: mpi3mr: Add config and transport related debug flags 2022-08-22 23:34:04 -04:00
mpi3mr_fw.c scsi: mpi3mr: Remove unnecessary cast 2022-09-25 14:22:56 -04:00
mpi3mr_os.c scsi: mpi3mr: Suppress command reply debug prints 2022-11-17 17:42:38 +00:00
mpi3mr_transport.c scsi: mpi3mr: Fix an issue found by KASAN 2023-02-21 22:00:50 -05:00
mpi3mr.h scsi: mpi3mr: Update driver version to 8.2.0.3.0 2022-09-25 13:49:52 -04:00