2024-03-28 22:00:32

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH] pstore/blk: replace deprecated strncpy with strscpy

On Thu, 28 Mar 2024 20:54:16 +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 know that info-device should be NUL-terminated based on its use with
> strlen():
> | static int __init mtdpstore_init(void)
> | {
> | int ret;
> | struct mtdpstore_context *cxt = &oops_cxt;
> | struct pstore_blk_config *info = &cxt->info;
> |
> | ret = pstore_blk_get_config(info);
> | if (unlikely(ret))
> | return ret;
> |
> | if (strlen(info->device) == 0) {
> | pr_err("mtd device must be supplied (device name is empty)\n");
> ...
>
> [...]

Applied to for-next/pstore, thanks!

[1/1] pstore/blk: replace deprecated strncpy with strscpy
https://git.kernel.org/kees/c/80b735d01bbb

Take care,

--
Kees Cook