Re: [PATCH 1/2] init: Use strscpy() in do_initcalls()
From: David Laight
Date: Sun Nov 15 2026 - 10:01:03 EST
On Sat, 14 Nov 2026 12:52:29 +0100
Thorsten Blum <blum@xxxxxxxxxx> wrote:
> Replace the deprecated strcpy() [1] with strscpy() to bound the copy to
> the allocated buffer size.
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
> Signed-off-by: Thorsten Blum <blum@xxxxxxxxxx>
> ---
> init/main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/init/main.c b/init/main.c
> index db8fb6ebe830..93a2b12976f0 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -1481,7 +1481,7 @@ static void __init do_initcalls(void)
>
> for (level = 0; level < ARRAY_SIZE(initcall_levels) - 1; level++) {
> /* Parser modifies command_line, restore it each time */
> - strcpy(command_line, saved_command_line);
> + strscpy(command_line, saved_command_line, len);
That could be a memcpy().
David
> do_initcall_level(level, command_line);
> }
>
>