On Fri, Sep 02, 2022 at 11:21:21AM +0700, Bagas Sanjaya wrote: > On Thu, Sep 01, 2022 at 12:09:52PM -0700, Kees Cook wrote: > > + * Do not use this function. While FORTIFY_SOURCE tries to avoid > > + * over-reads of @q, it cannot defend against writing unterminated > > + * results to @p. Using strncpy() remains ambiguous and fragile. > > + * Instead, please choose an alternative, so that the expectation > > + * of @p's contents is unambiguous: > > + * > > + * @p needs to be: | padded to @size | not padded > > + * --------------------+-----------------+------------+ > > + * NUL-terminated | strscpy_pad() | strscpy() | > > + * --------------------+-----------------+------------+ > > + * not NUL-terminated | strtomem_pad() | strtomem() | > > + * --------------------+-----------------+------------+ > > + * > > My htmldocs build doesn't catch any new warnings, but I think the table > above can be fixed up: > > ---- >8 ---- > > diff --git a/include/linux/fortify-string.h b/include/linux/fortify-string.h > index eed2119b23c523..3413a8e561fc62 100644 > --- a/include/linux/fortify-string.h > +++ b/include/linux/fortify-string.h > @@ -95,12 +95,13 @@ extern char *__underlying_strncpy(char *p, const char *q, __kernel_size_t size) > * Instead, please choose an alternative, so that the expectation > * of @p's contents is unambiguous: > * > - * @p needs to be: | padded to @size | not padded > - * --------------------+-----------------+------------+ > - * NUL-terminated | strscpy_pad() | strscpy() | > - * --------------------+-----------------+------------+ > - * not NUL-terminated | strtomem_pad() | strtomem() | > - * --------------------+-----------------+------------+ > + * +--------------------+-----------------+------------+ > + * |@p needs to be: | padded to @size | not padded | > + * +====================+=================+============+ > + * | NUL-terminated | strscpy_pad() | strscpy() | > + * +--------------------+-----------------+------------+ > + * | not NUL-terminated | strtomem_pad() | strtomem() | > + * +--------------------+-----------------+------------+ Ah thank you! > Regardless, I don't see these new table above in the output (am I missing > something?). Oh, yes, you're right. I will add an kern-doc directive to pull in the file. -- Kees Cook