Message ID | 20250213141037.50394-2-thorsten.blum@linux.dev (mailing list archive) |
---|---|
State | In Next |
Commit | e333ac9cf7f97accf0690734eb9bbfaf68617d00 |
Headers | show |
Series | m68k: mm: Replace deprecated strncpy() with strscpy() | expand |
Hi Thorsten, On 2/13/25 3:10 PM, Thorsten Blum wrote: > strncpy() is deprecated for NUL-terminated destination buffers. Use > strscpy() instead and remove the manual NUL-termination. > > Compile-tested only. > > Link: https://github.com/KSPP/linux/issues/90 > Cc: linux-hardening@vger.kernel.org > Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Thanks for the patch ! It works fine for me: Tested-by: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org> > --- > arch/m68k/kernel/setup_mm.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/arch/m68k/kernel/setup_mm.c b/arch/m68k/kernel/setup_mm.c > index 15c1a595a1de..48ce67947678 100644 > --- a/arch/m68k/kernel/setup_mm.c > +++ b/arch/m68k/kernel/setup_mm.c > @@ -243,8 +243,7 @@ void __init setup_arch(char **cmdline_p) > setup_initial_init_mm((void *)PAGE_OFFSET, _etext, _edata, _end); > > #if defined(CONFIG_BOOTPARAM) > - strncpy(m68k_command_line, CONFIG_BOOTPARAM_STRING, CL_SIZE); > - m68k_command_line[CL_SIZE - 1] = 0; > + strscpy(m68k_command_line, CONFIG_BOOTPARAM_STRING, CL_SIZE); > #endif /* CONFIG_BOOTPARAM */ > process_uboot_commandline(&m68k_command_line[0], CL_SIZE); > *cmdline_p = m68k_command_line;
On Thu, 13 Feb 2025 at 15:11, Thorsten Blum <thorsten.blum@linux.dev> wrote: > strncpy() is deprecated for NUL-terminated destination buffers. Use > strscpy() instead and remove the manual NUL-termination. > > Compile-tested only. > > Link: https://github.com/KSPP/linux/issues/90 > Cc: linux-hardening@vger.kernel.org > Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> > --- a/arch/m68k/kernel/setup_mm.c > +++ b/arch/m68k/kernel/setup_mm.c > @@ -243,8 +243,7 @@ void __init setup_arch(char **cmdline_p) > setup_initial_init_mm((void *)PAGE_OFFSET, _etext, _edata, _end); > > #if defined(CONFIG_BOOTPARAM) > - strncpy(m68k_command_line, CONFIG_BOOTPARAM_STRING, CL_SIZE); > - m68k_command_line[CL_SIZE - 1] = 0; > + strscpy(m68k_command_line, CONFIG_BOOTPARAM_STRING, CL_SIZE); > #endif /* CONFIG_BOOTPARAM */ > process_uboot_commandline(&m68k_command_line[0], CL_SIZE); > *cmdline_p = m68k_command_line; This seems to be used mostly by Coldfire, so I'll let Greg handle it. Gr{oetje,eeting}s, Geert
Hi Thorsten, On 19/2/25 00:13, Geert Uytterhoeven wrote: > On Thu, 13 Feb 2025 at 15:11, Thorsten Blum <thorsten.blum@linux.dev> wrote: >> strncpy() is deprecated for NUL-terminated destination buffers. Use >> strscpy() instead and remove the manual NUL-termination. >> >> Compile-tested only. >> >> Link: https://github.com/KSPP/linux/issues/90 >> Cc: linux-hardening@vger.kernel.org >> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> > > Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> > >> --- a/arch/m68k/kernel/setup_mm.c >> +++ b/arch/m68k/kernel/setup_mm.c >> @@ -243,8 +243,7 @@ void __init setup_arch(char **cmdline_p) >> setup_initial_init_mm((void *)PAGE_OFFSET, _etext, _edata, _end); >> >> #if defined(CONFIG_BOOTPARAM) >> - strncpy(m68k_command_line, CONFIG_BOOTPARAM_STRING, CL_SIZE); >> - m68k_command_line[CL_SIZE - 1] = 0; >> + strscpy(m68k_command_line, CONFIG_BOOTPARAM_STRING, CL_SIZE); >> #endif /* CONFIG_BOOTPARAM */ >> process_uboot_commandline(&m68k_command_line[0], CL_SIZE); >> *cmdline_p = m68k_command_line; > > This seems to be used mostly by Coldfire, so I'll let Greg handle it. Looks good. Pushed into the m68knommu git tree, for-next branch, with JM's tested-by and Geert's reviewed-by added. Thanks Greg
diff --git a/arch/m68k/kernel/setup_mm.c b/arch/m68k/kernel/setup_mm.c index 15c1a595a1de..48ce67947678 100644 --- a/arch/m68k/kernel/setup_mm.c +++ b/arch/m68k/kernel/setup_mm.c @@ -243,8 +243,7 @@ void __init setup_arch(char **cmdline_p) setup_initial_init_mm((void *)PAGE_OFFSET, _etext, _edata, _end); #if defined(CONFIG_BOOTPARAM) - strncpy(m68k_command_line, CONFIG_BOOTPARAM_STRING, CL_SIZE); - m68k_command_line[CL_SIZE - 1] = 0; + strscpy(m68k_command_line, CONFIG_BOOTPARAM_STRING, CL_SIZE); #endif /* CONFIG_BOOTPARAM */ process_uboot_commandline(&m68k_command_line[0], CL_SIZE); *cmdline_p = m68k_command_line;
strncpy() is deprecated for NUL-terminated destination buffers. Use strscpy() instead and remove the manual NUL-termination. Compile-tested only. Link: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> --- arch/m68k/kernel/setup_mm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)