From: Bagas Sanjaya <bagasdotme@gmail.com>
To: Kees Cook <keescook@chromium.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
Nick Desaulniers <ndesaulniers@google.com>,
Guenter Roeck <linux@roeck-us.net>,
Linus Torvalds <torvalds@linux-foundation.org>,
Jonathan Corbet <corbet@lwn.net>, Len Baker <len.baker@gmx.com>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Francis Laniel <laniel_francis@privacyrequired.com>,
Paolo Abeni <pabeni@redhat.com>,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH v2] string: Introduce strtomem() and strtomem_pad()
Date: Fri, 2 Sep 2022 11:21:21 +0700 [thread overview]
Message-ID: <YxGEwdc69waEXhnV@debian.me> (raw)
In-Reply-To: <20220901190952.2229696-1-keescook@chromium.org>
[-- Attachment #1: Type: text/plain, Size: 2557 bytes --]
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2022-09-02 4:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-01 19:09 [PATCH v2] string: Introduce strtomem() and strtomem_pad() Kees Cook
2022-09-01 19:34 ` Guenter Roeck
2022-09-02 20:52 ` Kees Cook
2022-09-02 21:47 ` Guenter Roeck
2022-09-02 22:37 ` Kees Cook
2022-09-02 1:53 ` Bagas Sanjaya
2022-09-02 20:56 ` Kees Cook
2022-09-02 4:21 ` Bagas Sanjaya [this message]
2022-09-02 21:01 ` Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YxGEwdc69waEXhnV@debian.me \
--to=bagasdotme@gmail.com \
--cc=corbet@lwn.net \
--cc=geert@linux-m68k.org \
--cc=gustavoars@kernel.org \
--cc=keescook@chromium.org \
--cc=laniel_francis@privacyrequired.com \
--cc=len.baker@gmx.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=ndesaulniers@google.com \
--cc=pabeni@redhat.com \
--cc=torvalds@linux-foundation.org \
--cc=wsa+renesas@sang-engineering.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).