[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <cbfda101-9ba6-4130-88e8-be49e15df642@gmx.de>
Date: Fri, 17 Nov 2023 15:48:21 +0100
From: Helge Deller <deller@....de>
To: Kees Cook <keescook@...omium.org>,
"James E.J. Bottomley" <James.Bottomley@...senPartnership.com>
Cc: Azeem Shaikh <azeemshaikh38@...il.com>,
linux-parisc@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-hardening@...r.kernel.org
Subject: Re: [PATCH] parisc: Replace strlcpy() with strscpy()
On 11/16/23 20:13, Kees Cook wrote:
> 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].
> Additionally, it returns the size of the source string, not the
> resulting size of the destination string. In an effort to remove strlcpy()
> completely[2], replace strlcpy() here with strscpy().
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy [1]
> Link: https://github.com/KSPP/linux/issues/89 [2]
> Cc: "James E.J. Bottomley" <James.Bottomley@...senPartnership.com>
> Cc: Helge Deller <deller@....de>
> Cc: Azeem Shaikh <azeemshaikh38@...il.com>
> Cc: linux-parisc@...r.kernel.org
> Signed-off-by: Kees Cook <keescook@...omium.org>
applied.
Thanks!
Helge
> ---
> arch/parisc/kernel/processor.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/parisc/kernel/processor.c b/arch/parisc/kernel/processor.c
> index 29e2750f86a4..e95a977ba5f3 100644
> --- a/arch/parisc/kernel/processor.c
> +++ b/arch/parisc/kernel/processor.c
> @@ -383,7 +383,7 @@ show_cpuinfo (struct seq_file *m, void *v)
> char cpu_name[60], *p;
>
> /* strip PA path from CPU name to not confuse lscpu */
> - strlcpy(cpu_name, per_cpu(cpu_data, 0).dev->name, sizeof(cpu_name));
> + strscpy(cpu_name, per_cpu(cpu_data, 0).dev->name, sizeof(cpu_name));
> p = strrchr(cpu_name, '[');
> if (p)
> *(--p) = 0;
Powered by blists - more mailing lists