]> git.baikalelectronics.ru Git - kernel.git/commit
scsi: target: iscsi: Fix buffer overflow in lio_target_nacl_info_show()
authorKonstantin Shelekhin <k.shelekhin@yadro.com>
Sat, 22 Jul 2023 15:26:37 +0000 (18:26 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Sep 2023 09:11:07 +0000 (11:11 +0200)
commit4738bf8b2d3635c2944b81b2a84d97b8c8b0978d
tree130ec999d7eafbdb0fc69f18c0b10cd38332d9e9
parent6c440fec96af102b0c0783d8ae3370636c0f6643
scsi: target: iscsi: Fix buffer overflow in lio_target_nacl_info_show()

[ Upstream commit 801f287c93ff95582b0a2d2163f12870a2f076d4 ]

The function lio_target_nacl_info_show() uses sprintf() in a loop to print
details for every iSCSI connection in a session without checking for the
buffer length. With enough iSCSI connections it's possible to overflow the
buffer provided by configfs and corrupt the memory.

This patch replaces sprintf() with sysfs_emit_at() that checks for buffer
boundries.

Signed-off-by: Konstantin Shelekhin <k.shelekhin@yadro.com>
Link: https://lore.kernel.org/r/20230722152657.168859-2-k.shelekhin@yadro.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/target/iscsi/iscsi_target_configfs.c