kernel_samsung_a53x/drivers/scsi/mpt3sas
Breno Leitao cb8b2b8edc scsi: mpt3sas: Avoid test/set_bit() operating in non-allocated memory
commit 4254dfeda82f20844299dca6c38cbffcfd499f41 upstream.

There is a potential out-of-bounds access when using test_bit() on a single
word. The test_bit() and set_bit() functions operate on long values, and
when testing or setting a single word, they can exceed the word
boundary. KASAN detects this issue and produces a dump:

	 BUG: KASAN: slab-out-of-bounds in _scsih_add_device.constprop.0 (./arch/x86/include/asm/bitops.h:60 ./include/asm-generic/bitops/instrumented-atomic.h:29 drivers/scsi/mpt3sas/mpt3sas_scsih.c:7331) mpt3sas

	 Write of size 8 at addr ffff8881d26e3c60 by task kworker/u1536:2/2965

For full log, please look at [1].

Make the allocation at least the size of sizeof(unsigned long) so that
set_bit() and test_bit() have sufficient room for read/write operations
without overwriting unallocated memory.

[1] Link: https://lore.kernel.org/all/ZkNcALr3W3KGYYJG@gmail.com/

Fixes: c696f7b83ede ("scsi: mpt3sas: Implement device_remove_in_progress check in IOCTL path")
Cc: stable@vger.kernel.org
Suggested-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Breno Leitao <leitao@debian.org>
Link: https://lore.kernel.org/r/20240605085530.499432-1-leitao@debian.org
Reviewed-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-11-19 14:19:02 +01:00
..
mpi Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mpt3sas_base.c scsi: mpt3sas: Avoid test/set_bit() operating in non-allocated memory 2024-11-19 14:19:02 +01:00
mpt3sas_base.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mpt3sas_config.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mpt3sas_ctl.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mpt3sas_ctl.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mpt3sas_debug.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mpt3sas_debugfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mpt3sas_scsih.c scsi: mpt3sas: Fix in error path 2024-11-18 10:58:46 +01:00
mpt3sas_transport.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mpt3sas_trigger_diag.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mpt3sas_trigger_diag.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mpt3sas_warpdrive.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00