lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 28 Sep 2023 23:44:53 +0200
From: Linus Walleij <linus.walleij@...aro.org>
To: Justin Stitt <justinstitt@...gle.com>
Cc: Lee Jones <lee@...nel.org>, linux-arm-kernel@...ts.infradead.org, 
	linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH] mfd: db8500-prcmu: replace deprecated strncpy with strscpy

Hi Justin,

thanks for your patch!

On Wed, Sep 27, 2023 at 7:10 AM Justin Stitt <justinstitt@...gle.com> wrote:

> `strncpy` is deprecated for use on NUL-terminated destination strings
> [1] and as such we should prefer more robust and less ambiguous string
> interfaces.
>
> We expect project_name to be NUL-terminated based on its use with
> pr_info:
> |       pr_info("PRCMU firmware: %s(%d), version %d.%d.%d\n",
> |               fw_info.version.project_name,
> |               fw_info.version.project,
> |               fw_info.version.api_version,
> |               fw_info.version.func_version,
> |               fw_info.version.errata);
>
> Moreover, NUL-padding does not seem to be needed.
>
> Considering the above, a suitable replacement is `strscpy` [2] due to
> the fact that it guarantees NUL-termination on the destination buffer
> without unnecessarily NUL-padding.
>
> Let's also change `PRCMU_FW_PROJECT_NAME_LEN` to just
> sizeof(fw_info.version.project_name) as this is more idiomatic strscpy
> usage.
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
> Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2]
> Link: https://github.com/KSPP/linux/issues/90
> Cc: linux-hardening@...r.kernel.org
> Signed-off-by: Justin Stitt <justinstitt@...gle.com>

Well analyzed, well patched, what can I say! Hats off.
Reviewed-by: Linus Walleij <linus.walleij@...aro.org>

Yours,
Linus Walleij

Powered by blists - more mailing lists