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() | + * +--------------------+-----------------+------------+ * * Note strscpy*()'s differing return values for detecting truncation, * and strtomem*()'s expectation that the destination is marked with > + * Note strscpy*()'s differing return values for detecting truncation, > + * and strtomem*()'s expectation that the destination is marked with > + * __nonstring when it is a character array. > + * Regardless, I don't see these new table above in the output (am I missing something?). Thanks. -- An old man doll... just what I always wanted! - Clara
Attachment:
signature.asc
Description: PGP signature