Re: [PATCH v5] hwmon: (acpi_power_meter) replace open-coded kmemdup_nul
From: Kees Cook
Date: Mon Oct 02 2023 - 13:39:51 EST
On Tue, Sep 26, 2023 at 06:59:15AM +0000, Justin Stitt wrote:
> `strncpy` is deprecated for use on NUL-terminated destination strings [1].
>
> Let's refactor this kcalloc() + strncpy() into a kmemdup_nul() which has
> more obvious behavior and is less error prone.
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
> Link: https://github.com/KSPP/linux/issues/90
> Cc: linux-hardening@xxxxxxxxxxxxxxx
> Signed-off-by: Justin Stitt <justinstitt@xxxxxxxxxx>
Thanks for continue to rev this change. This looks much nicer, is more
readable, etc. :)
Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>
--
Kees Cook