Skip to content

Commit 4b2e287

Browse files
azeemshaikh38martinkpetersen
authored andcommitted
scsi: target: tcmu: 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] KSPP#89 Signed-off-by: Azeem Shaikh <azeemshaikh38@gmail.com> Link: https://lore.kernel.org/r/20230621030033.3800351-3-azeemshaikh38@gmail.com Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent d1e8a9f commit 4b2e287

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/target/target_core_user.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2820,14 +2820,14 @@ static ssize_t tcmu_dev_config_store(struct config_item *item, const char *page,
28202820
pr_err("Unable to reconfigure device\n");
28212821
return ret;
28222822
}
2823-
strlcpy(udev->dev_config, page, TCMU_CONFIG_LEN);
2823+
strscpy(udev->dev_config, page, TCMU_CONFIG_LEN);
28242824

28252825
ret = tcmu_update_uio_info(udev);
28262826
if (ret)
28272827
return ret;
28282828
return count;
28292829
}
2830-
strlcpy(udev->dev_config, page, TCMU_CONFIG_LEN);
2830+
strscpy(udev->dev_config, page, TCMU_CONFIG_LEN);
28312831

28322832
return count;
28332833
}

0 commit comments

Comments
 (0)