Skip to content

Commit f0e212d

Browse files
azeemshaikh38kees
authored andcommitted
Hexagon: 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]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b2f1014 commit f0e212d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/hexagon/kernel/setup.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,17 @@ void __init setup_arch(char **cmdline_p)
6666
on_simulator = 0;
6767

6868
if (p[0] != '\0')
69-
strlcpy(boot_command_line, p, COMMAND_LINE_SIZE);
69+
strscpy(boot_command_line, p, COMMAND_LINE_SIZE);
7070
else
71-
strlcpy(boot_command_line, default_command_line,
71+
strscpy(boot_command_line, default_command_line,
7272
COMMAND_LINE_SIZE);
7373

7474
/*
7575
* boot_command_line and the value set up by setup_arch
7676
* are both picked up by the init code. If no reason to
7777
* make them different, pass the same pointer back.
7878
*/
79-
strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);
79+
strscpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);
8080
*cmdline_p = cmd_line;
8181

8282
parse_early_param();

0 commit comments

Comments
 (0)