linux/drivers/target
Wang Haoran 53c6351597 scsi: target: target_core_configfs: Add length check to avoid buffer overflow
commit 27e06650a5 upstream.

A buffer overflow arises from the usage of snprintf to write into the
buffer "buf" in target_lu_gp_members_show function located in
/drivers/target/target_core_configfs.c. This buffer is allocated with
size LU_GROUP_NAME_BUF (256 bytes).

snprintf(...) formats multiple strings into buf with the HBA name
(hba->hba_group.cg_item), a slash character, a devicename (dev->
dev_group.cg_item) and a newline character, the total formatted string
length may exceed the buffer size of 256 bytes.

Since snprintf() returns the total number of bytes that would have been
written (the length of %s/%sn ), this value may exceed the buffer length
(256 bytes) passed to memcpy(), this will ultimately cause function
memcpy reporting a buffer overflow error.

An additional check of the return value of snprintf() can avoid this
buffer overflow.

Reported-by: Wang Haoran <haoranwangsec@gmail.com>
Reported-by: ziiiro <yuanmingbuaa@gmail.com>
Signed-off-by: Wang Haoran <haoranwangsec@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2025-10-06 11:17:52 +02:00
..
iscsi scsi: target: iscsi: Fix timeout on deleted connection 2025-05-29 11:01:58 +02:00
loopback scsi: target: tcm_loop: Make tcm_loop_lld_bus const 2024-02-05 20:58:55 -05:00
sbp move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
tcm_fc move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
tcm_remote scsi: target: Add virtual remote target 2023-03-16 23:36:37 -04:00
Kconfig scsi: target: Add virtual remote target 2023-03-16 23:36:37 -04:00
Makefile scsi: target: Add virtual remote target 2023-03-16 23:36:37 -04:00
target_core_alua.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
target_core_alua.h Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending 2017-11-24 19:19:20 -10:00
target_core_configfs.c scsi: target: target_core_configfs: Add length check to avoid buffer overflow 2025-10-06 11:17:52 +02:00
target_core_device.c SCSI fixes on 20241019 2024-10-19 12:52:19 -07:00
target_core_fabric_configfs.c scsi: target: Export fabric driver direct submit settings 2023-10-13 15:53:58 -04:00
target_core_fabric_lib.c scsi: target: core: Generate correct identifiers for PR OUT transport IDs 2025-08-20 18:30:48 +02:00
target_core_file.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
target_core_file.h scsi: target: target/file: Add support of direct and async I/O 2018-05-14 22:40:08 -04:00
target_core_hba.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
target_core_iblock.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
target_core_iblock.h target: port block device access to file 2024-02-25 12:05:25 +01:00
target_core_internal.h scsi: target: core: Generate correct identifiers for PR OUT transport IDs 2025-08-20 18:30:48 +02:00
target_core_pr.c scsi: target: core: Generate correct identifiers for PR OUT transport IDs 2025-08-20 18:30:48 +02:00
target_core_pr.h scsi: target: core: Unify NAA identifier generation 2021-05-15 14:14:28 -04:00
target_core_pscsi.c scsi: target: Fix incorrect function name in pscsi_create_type_disk() 2024-12-05 14:02:10 +01:00
target_core_pscsi.h target: port block device access to file 2024-02-25 12:05:25 +01:00
target_core_rd.c scsi: target: Rename sbc_ops to exec_cmd_ops 2023-04-11 21:55:36 -04:00
target_core_rd.h scsi: target: Add the DUMMY flag to rd_mcp 2021-04-05 23:26:38 -04:00
target_core_sbc.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
target_core_spc.c scsi: target: spc: Fix loop traversal in spc_rsoc_get_descr() 2025-05-29 11:02:54 +02:00
target_core_stat.c scsi: target: core: Use RTPI from target port 2023-03-09 21:29:23 -05:00
target_core_tmr.c scsi: target: Fix multiple LUN_RESET handling 2023-03-24 17:32:23 -04:00
target_core_tpg.c Merge patch series "target: TMF and recovery fixes" 2023-03-24 17:39:15 -04:00
target_core_transport.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
target_core_ua.c scsi: target: use an enum to track emulate_ua_intlck_ctrl 2020-02-21 17:37:16 -05:00
target_core_ua.h scsi: target: Fix handling of removed LUNs 2018-07-02 16:44:32 -04:00
target_core_user.c genetlink: hold RCU in genlmsg_mcast() 2024-10-15 17:52:58 -07:00
target_core_xcopy.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
target_core_xcopy.h scsi: target: core: Change the way target_xcopy_do_work() sets restiction on max I/O 2022-11-24 02:16:19 +00:00