scsi: Replace strlcpy with strscpy
Subsystems (3)
cover scsi: Replace strlcpy with strscpy
This patch series replaces strlcpy in the scsi subsystem wherever trivial replacement is possible, i.e return value from strlcpy is unused. The patches themselves are independent of each other and are included as a series for ease of review.
Azeem Shaikh (2):
scsi: Replace strlcpy with strscpy
scsi: target: tcmu: Replace strlcpy with strscpy
drivers/scsi/ncr53c8xx.c | 2 +- drivers/target/target_core_user.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.41.0.162.gfafddb0af9-goog
PATCH 1/2 scsi: 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]. In an effort to remove strlcpy() completely [2], replace strlcpy() here with strscpy().
No return values were used, so direct replacement is safe.
[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy
[2] https://github.com/KSPP/linux/issues/89
--- drivers/scsi/ncr53c8xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ncr53c8xx.c +1 -1
@@ -4555,7 +4555,7 @@ static void ncr_detach(struct ncb *np)char inst_name[16 ];/* Local copy so we don't access np after freeing it! */ -strlcpy (inst_name,ncr_name (np),sizeof (inst_name)); +strscpy (inst_name,ncr_name (np),sizeof (inst_name));printk ("%s: releasing host resources\n" ,ncr_name (np));
Signature · 1 line
2.41.0.162.gfafddb0af9-goog
Quoted 7 lines · Azeem Shaikh
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]. In an effort to removestrlcpy()completely [2], replacestrlcpy()here withstrscpy().
Quoted 6 lines
No return values were used, so direct replacement is safe.
[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy
[2] https://github.com/KSPP/linux/issues/89Signed-off-by Azeem Shaikh <[email protected]>
Signature · 1 line
Kees Cook
PATCH 2/2 scsi: target: tcmu: Replace strlcpy with strscpy
In reply to Azeem Shaikhstrlcpy() 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]. In an effort to remove strlcpy() completely [2], replace strlcpy() here with strscpy().
No return values were used, so direct replacement is safe.
[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy
[2] https://github.com/KSPP/linux/issues/89
--- drivers/target/target_core_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/target/target_core_user.c +2 -2
@@ -2820,14 +2820,14 @@ static ssize_t tcmu_dev_config_store(struct config_item *item, const char *page,pr_err ("Unable to reconfigure device\n" );return ret; } -strlcpy (udev->dev_config, page,TCMU_CONFIG_LEN ); +strscpy (udev->dev_config, page,TCMU_CONFIG_LEN ); ret =tcmu_update_uio_info (udev);if (ret)return ret;return count; } -strlcpy (udev->dev_config, page,TCMU_CONFIG_LEN ); +strscpy (udev->dev_config, page,TCMU_CONFIG_LEN );return count; }
Signature · 1 line
2.41.0.162.gfafddb0af9-goog
Re: [PATCH 2/2] scsi: target: tcmu: Replace strlcpy with strscpy
Quoted 7 lines · Azeem Shaikh
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]. In an effort to removestrlcpy()completely [2], replacestrlcpy()here withstrscpy().
Quoted 6 lines
No return values were used, so direct replacement is safe.
[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy
[2] https://github.com/KSPP/linux/issues/89Signed-off-by Azeem Shaikh <[email protected]>
Signature · 1 line
Kees Cook
Martin K. Petersen
AppliedAzeem,
Quoted 4 lines
This patch series replaces strlcpy in the scsi subsystem wherever trivial replacement is possible, i.e return value from strlcpy is unused. The patches themselves are independent of each other and are included as a series for ease of review.
Applied to 6.5/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 10 lines · Azeem Shaikh
This patch series replaces strlcpy in the scsi subsystem wherever trivial replacement is possible, i.e return value from strlcpy is unused. The patches themselves are independent of each other and are included as a series for ease of review.
Azeem Shaikh (2):
scsi: Replace strlcpy with strscpy
scsi: target: tcmu: Replace strlcpy with strscpy[...]
Applied to 6.5/scsi-queue, thanks!
[1/2] scsi: Replace strlcpy with strscpy
https://git.kernel.org/mkp/scsi/c/d1e8a9fbb392 [2/2] scsi: target: tcmu: Replace strlcpy with strscpy https://git.kernel.org/mkp/scsi/c/4b2e28758daf
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering