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 <[email protected]> Acked-by: John Stultz <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent f9cfb19 commit 76edc27

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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)