Re: [PATCH] dm crypt: replace open-coded kmemdup_nul

From: Kees Cook
Date: Mon Sep 25 2023 - 14:04:43 EST


On Mon, Sep 25, 2023 at 06:35:54AM +0000, Justin Stitt wrote:
> kzalloc() followed by strncpy() on an expected NUL-terminated string is
> just kmemdup_nul(). Let's simplify this code (while also dropping a
> deprecated strncpy() call [1]).
>
> 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
> Cc: Kees Cook <keescook@xxxxxxxxxxxx>
> Signed-off-by: Justin Stitt <justinstitt@xxxxxxxxxx>

This looks correct to me. Thanks!

Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>

--
Kees Cook