* [PATCH] m68k: mm: Replace deprecated strncpy() with strscpy()
@ 2025-02-13 14:10 Thorsten Blum
2025-02-17 13:01 ` Jean-Michel Hautbois
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Thorsten Blum @ 2025-02-13 14:10 UTC (permalink / raw)
To: Geert Uytterhoeven, Jean-Michel Hautbois
Cc: Thorsten Blum, linux-hardening, linux-m68k, linux-kernel
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(-)
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;
--
2.48.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] m68k: mm: Replace deprecated strncpy() with strscpy()
2025-02-13 14:10 [PATCH] m68k: mm: Replace deprecated strncpy() with strscpy() Thorsten Blum
@ 2025-02-17 13:01 ` Jean-Michel Hautbois
2025-02-18 14:13 ` Geert Uytterhoeven
2025-02-20 2:21 ` Kees Cook
2 siblings, 0 replies; 5+ messages in thread
From: Jean-Michel Hautbois @ 2025-02-17 13:01 UTC (permalink / raw)
To: Thorsten Blum, Geert Uytterhoeven
Cc: linux-hardening, linux-m68k, linux-kernel
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;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] m68k: mm: Replace deprecated strncpy() with strscpy()
2025-02-13 14:10 [PATCH] m68k: mm: Replace deprecated strncpy() with strscpy() Thorsten Blum
2025-02-17 13:01 ` Jean-Michel Hautbois
@ 2025-02-18 14:13 ` Geert Uytterhoeven
2025-02-18 22:45 ` Greg Ungerer
2025-02-20 2:21 ` Kees Cook
2 siblings, 1 reply; 5+ messages in thread
From: Geert Uytterhoeven @ 2025-02-18 14:13 UTC (permalink / raw)
To: Thorsten Blum
Cc: Jean-Michel Hautbois, linux-hardening, linux-m68k, linux-kernel,
Greg Ungerer
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
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] m68k: mm: Replace deprecated strncpy() with strscpy()
2025-02-18 14:13 ` Geert Uytterhoeven
@ 2025-02-18 22:45 ` Greg Ungerer
0 siblings, 0 replies; 5+ messages in thread
From: Greg Ungerer @ 2025-02-18 22:45 UTC (permalink / raw)
To: Geert Uytterhoeven, Thorsten Blum
Cc: Jean-Michel Hautbois, linux-hardening, linux-m68k, linux-kernel
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] m68k: mm: Replace deprecated strncpy() with strscpy()
2025-02-13 14:10 [PATCH] m68k: mm: Replace deprecated strncpy() with strscpy() Thorsten Blum
2025-02-17 13:01 ` Jean-Michel Hautbois
2025-02-18 14:13 ` Geert Uytterhoeven
@ 2025-02-20 2:21 ` Kees Cook
2 siblings, 0 replies; 5+ messages in thread
From: Kees Cook @ 2025-02-20 2:21 UTC (permalink / raw)
To: Thorsten Blum
Cc: Geert Uytterhoeven, Jean-Michel Hautbois, linux-hardening,
linux-m68k, linux-kernel
On Thu, Feb 13, 2025 at 03:10:36PM +0100, 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>
> ---
> 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;
m68k_command_line lives in rwdata, so it should be 0-initialized by
default, so there should be no behavioral difference here (i.e. it will
be zero-padded), and it is used as a C String, so there was unlikely to
be anything depending on the NUL-padding.
Reviewed-by: Kees Cook <kees@kernel.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-02-20 2:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-13 14:10 [PATCH] m68k: mm: Replace deprecated strncpy() with strscpy() Thorsten Blum
2025-02-17 13:01 ` Jean-Michel Hautbois
2025-02-18 14:13 ` Geert Uytterhoeven
2025-02-18 22:45 ` Greg Ungerer
2025-02-20 2:21 ` Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).