linux/drivers/s390
Kees Cook 0d224b1088 scsi: zfcp: Replace strlcpy() with strscpy()
strlcpy() reads the entire source buffer first. This read may exceed the
destination size limit. This is both inefficient and can lead to linear
read overflows if a source string is not NUL-terminated[1].  Additionally,
it returns the size of the source string, not the resulting size of the
destination string. In an effort to remove strlcpy() completely[2], replace
strlcpy() here with strscpy().

Overflow should be impossible here, but actually check for buffer sizes
being identical with BUILD_BUG_ON(), and include a run-time check as well.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy [1]
Link: https://github.com/KSPP/linux/issues/89 [2]
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: James E.J. Bottomley <jejb@linux.ibm.com>
Cc: Steffen Maier <maier@linux.ibm.com>
Cc: Benjamin Block <bblock@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Azeem Shaikh <azeemshaikh38@gmail.com>
Cc: <linux-s390@vger.kernel.org>
Cc: <linux-scsi@vger.kernel.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20231130204056.it.978-kees@kernel.org
Acked-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-12-05 21:01:52 -05:00
..
block s390/dasd: Convert to bdev_open_by_path() 2023-10-28 13:29:18 +02:00
char s390/sclp: replace deprecated strncpy with strtomem 2023-10-25 15:08:30 +02:00
cio s390 updates for the 6.7 merge window 2023-11-03 10:17:22 -10:00
crypto s390/ap: fix vanishing crypto cards in SE environment 2023-11-05 22:34:57 +01:00
net s390/qeth: Fix typo 'weed' in comment 2023-11-07 22:17:20 +00:00
scsi scsi: zfcp: Replace strlcpy() with strscpy() 2023-12-05 21:01:52 -05:00
virtio s390/airq: remove lsi_mask from airq_struct 2023-08-30 11:03:28 +02:00
Makefile