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)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 31 Jul 2023 16:09:58 +0000 (12:09 -0400)
commit801f287c93ff95582b0a2d2163f12870a2f076d4
tree508818520bfae5566a43e336d70d97143ab72339
parent06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5
scsi: target: iscsi: Fix buffer overflow in lio_target_nacl_info_show()

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>
drivers/target/iscsi/iscsi_target_configfs.c