Skip to content

Commit 76edc27

Browse files
azeemshaikh38kees
authored andcommitted
clocksource: Replace all non-returning 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> Acked-by: John Stultz <jstultz@google.com> Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20230530163546.986188-1-azeemshaikh38@gmail.com
1 parent f9cfb19 commit 76edc27

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

kernel/time/clocksource.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,7 @@ static int __init boot_override_clocksource(char* str)
14801480
{
14811481
mutex_lock(&clocksource_mutex);
14821482
if (str)
1483-
strlcpy(override_name, str, sizeof(override_name));
1483+
strscpy(override_name, str, sizeof(override_name));
14841484
mutex_unlock(&clocksource_mutex);
14851485
return 1;
14861486
}

0 commit comments

Comments
 (0)