Re: [PATCH v3] lib/string.c: implement stpcpy

From: Kees Cook
Date: Thu Aug 27 2020 - 15:41:51 EST


On Thu, Aug 27, 2020 at 12:37:03PM -0700, Joe Perches wrote:
> On Thu, 2020-08-27 at 11:30 -0700, Kees Cook wrote:
>
> > Most of the uses of strcpy() in the kernel are just copying between two
> > known-at-compile-time NUL-terminated character arrays. We had wanted to
> > introduce stracpy() for this, but Linus objected to yet more string
> > functions.
>
> https://lore.kernel.org/kernel-hardening/24bb53c57767c1c2a8f266c305a670f7@xxxxxxx/T/
>
> I still think stracpy is a good idea.
>
> Maybe when the strcpy/strlcpy uses are removed
> it'll be more acceptable.
>
> And here's a cocci script to convert most of them.
> https://lore.kernel.org/kernel-hardening/b9bb5550b264d4b29b2b20f7ff8b1b40d20def6a.camel@xxxxxxxxxxx/

Yeah, thanks again for that. Most of this is very mechanical. (strncpy is not, unfortunately)

--
Kees Cook