linux-stable/drivers/target
Wang Hai 8c1e6717f6 scsi: target: core: Fix null-ptr-deref in target_alloc_device()
[ Upstream commit fca6caeb4a ]

There is a null-ptr-deref issue reported by KASAN:

BUG: KASAN: null-ptr-deref in target_alloc_device+0xbc4/0xbe0 [target_core_mod]
...
 kasan_report+0xb9/0xf0
 target_alloc_device+0xbc4/0xbe0 [target_core_mod]
 core_dev_setup_virtual_lun0+0xef/0x1f0 [target_core_mod]
 target_core_init_configfs+0x205/0x420 [target_core_mod]
 do_one_initcall+0xdd/0x4e0
...
 entry_SYSCALL_64_after_hwframe+0x76/0x7e

In target_alloc_device(), if allocing memory for dev queues fails, then
dev will be freed by dev->transport->free_device(), but dev->transport
is not initialized at that time, which will lead to a null pointer
reference problem.

Fixing this bug by freeing dev with hba->backend->ops->free_device().

Fixes: 1526d9f10c ("scsi: target: Make state_list per CPU")
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Link: https://lore.kernel.org/r/20241011113444.40749-1-wanghai38@huawei.com
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-08 16:21:57 +01:00
..
iscsi scsi: target: iscsi: Fix buffer overflow in lio_target_nacl_info_show() 2023-09-23 11:01:08 +02:00
loopback scsi: target: tcm_loop: Fix possible name leak in tcm_loop_setup_hba_bus() 2022-11-25 17:45:55 +01:00
sbp
tcm_fc scsi: target: Make state_list per CPU 2023-05-17 11:47:48 +02:00
Kconfig
Makefile
target_core_alua.c scsi: target: Fix alua_tg_pt_gps_count tracking 2021-11-26 10:39:11 +01:00
target_core_alua.h
target_core_configfs.c scsi: target: Fix SELinux error when systemd-modules loads the target module 2024-05-17 11:48:04 +02:00
target_core_device.c scsi: target: core: Fix null-ptr-deref in target_alloc_device() 2024-11-08 16:21:57 +01:00
target_core_fabric_configfs.c
target_core_fabric_lib.c
target_core_file.c fix iov_iter_bvec() "direction" argument 2023-02-15 17:22:11 +01:00
target_core_file.h
target_core_hba.c
target_core_iblock.c
target_core_iblock.h
target_core_internal.h scsi: target: Fix ordered tag handling 2021-11-26 10:39:11 +01:00
target_core_pr.c
target_core_pr.h
target_core_pscsi.c
target_core_pscsi.h
target_core_rd.c
target_core_rd.h
target_core_sbc.c scsi: target: Rename cmd.bad_sector to cmd.sense_info 2023-05-17 11:47:48 +02:00
target_core_spc.c
target_core_stat.c
target_core_tmr.c scsi: target: Fix multiple LUN_RESET handling 2023-05-17 11:47:48 +02:00
target_core_tpg.c
target_core_transport.c scsi: target: core: Add TMF to tmr_list handling 2024-03-01 13:16:43 +01:00
target_core_ua.c
target_core_ua.h
target_core_user.c genetlink: hold RCU in genlmsg_mcast() 2024-11-08 16:21:57 +01:00
target_core_xcopy.c
target_core_xcopy.h