Re: [PATCH] dm ioctl: replace deprecated strncpy with strscpy_pad

From: Kees Cook
Date: Tue Oct 24 2023 - 17:19:19 EST


On Mon, 25 Sep 2023 06:54:51 +0000, Justin Stitt 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 `spec->target_type` to be NUL-terminated based on its use with
> a format string after `dm_table_add_target()` is called
> | r = dm_table_add_target(table, spec->target_type,
> | (sector_t) spec->sector_start,
> | (sector_t) spec->length,
> | target_params);
> ... wherein `spec->target_type` is passed as parameter `type` and later
> printed with DMERR:
> | DMERR("%s: %s: unknown target type", dm_device_name(t->md), type);
>
> [...]

Applied to for-next/hardening, thanks!

[1/1] dm ioctl: replace deprecated strncpy with strscpy_pad
https://git.kernel.org/kees/c/0f3f34ea3798

Take care,

--
Kees Cook