<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/include/linux/fortify-string.h, branch v5.16.19</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.16.19</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.16.19'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2021-10-25T22:34:41Z</updated>
<entry>
<title>fortify: strlen: Avoid shadowing previous locals</title>
<updated>2021-10-25T22:34:41Z</updated>
<author>
<name>Qian Cai</name>
<email>quic_qiancai@quicinc.com</email>
</author>
<published>2021-10-25T21:05:28Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=95cadae320be46583078690ac89ffe63c95cc9d2'/>
<id>urn:sha1:95cadae320be46583078690ac89ffe63c95cc9d2</id>
<content type='text'>
The __compiletime_strlen() macro expansion will shadow p_size and p_len
local variables. No callers currently use any of the shadowed names
for their "p" variable, so there are no code generation problems.

Add "__" prefixes to variable definitions __compiletime_strlen() to
avoid new W=2 warnings:

./include/linux/fortify-string.h: In function 'strnlen':
./include/linux/fortify-string.h:17:9: warning: declaration of 'p_size' shadows a previous local [-Wshadow]
   17 |  size_t p_size = __builtin_object_size(p, 1); \
      |         ^~~~~~
./include/linux/fortify-string.h:77:17: note: in expansion of macro '__compiletime_strlen'
   77 |  size_t p_len = __compiletime_strlen(p);
      |                 ^~~~~~~~~~~~~~~~~~~~
./include/linux/fortify-string.h:76:9: note: shadowed declaration is here
   76 |  size_t p_size = __builtin_object_size(p, 1);
      |         ^~~~~~

Signed-off-by: Qian Cai &lt;quic_qiancai@quicinc.com&gt;
Signed-off-by: Kees Cook &lt;keescook@chromium.org&gt;
Link: https://lore.kernel.org/r/20211025210528.261643-1-quic_qiancai@quicinc.com
</content>
</entry>
<entry>
<title>fortify: Allow strlen() and strnlen() to pass compile-time known lengths</title>
<updated>2021-09-25T15:20:50Z</updated>
<author>
<name>Kees Cook</name>
<email>keescook@chromium.org</email>
</author>
<published>2021-08-03T05:51:31Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=3009f891bb9f328945ebd5b71e12df7e2467f3dd'/>
<id>urn:sha1:3009f891bb9f328945ebd5b71e12df7e2467f3dd</id>
<content type='text'>
Under CONFIG_FORTIFY_SOURCE, it is possible for the compiler to perform
strlen() and strnlen() at compile-time when the string size is known.
This is required to support compile-time overflow checking in strlcpy().

Signed-off-by: Kees Cook &lt;keescook@chromium.org&gt;
</content>
</entry>
<entry>
<title>fortify: Prepare to improve strnlen() and strlen() warnings</title>
<updated>2021-09-25T15:20:50Z</updated>
<author>
<name>Kees Cook</name>
<email>keescook@chromium.org</email>
</author>
<published>2021-08-04T21:20:14Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=369cd2165d7beac1db144b40811baa2c6b7d8c54'/>
<id>urn:sha1:369cd2165d7beac1db144b40811baa2c6b7d8c54</id>
<content type='text'>
In order to have strlen() use fortified strnlen() internally, swap their
positions in the source. Doing this as part of later changes makes
review difficult, so reoroder it here; no code changes.

Cc: Francis Laniel &lt;laniel_francis@privacyrequired.com&gt;
Signed-off-by: Kees Cook &lt;keescook@chromium.org&gt;
Reviewed-by: Nick Desaulniers &lt;ndesaulniers@google.com&gt;
</content>
</entry>
<entry>
<title>fortify: Fix dropped strcpy() compile-time write overflow check</title>
<updated>2021-09-25T15:20:50Z</updated>
<author>
<name>Kees Cook</name>
<email>keescook@chromium.org</email>
</author>
<published>2021-08-02T17:25:01Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=072af0c638dc8a5c7db2edc4dddbd6d44bee3bdb'/>
<id>urn:sha1:072af0c638dc8a5c7db2edc4dddbd6d44bee3bdb</id>
<content type='text'>
The implementation for intra-object overflow in str*-family functions
accidentally dropped compile-time write overflow checking in strcpy(),
leaving it entirely to run-time. Add back the intended check.

Fixes: 6a39e62abbaf ("lib: string.h: detect intra-object overflow in fortified string functions")
Cc: Daniel Axtens &lt;dja@axtens.net&gt;
Cc: Francis Laniel &lt;laniel_francis@privacyrequired.com&gt;
Signed-off-by: Kees Cook &lt;keescook@chromium.org&gt;
Reviewed-by: Nick Desaulniers &lt;ndesaulniers@google.com&gt;
</content>
</entry>
<entry>
<title>fortify: Move remaining fortify helpers into fortify-string.h</title>
<updated>2021-09-25T15:20:49Z</updated>
<author>
<name>Kees Cook</name>
<email>keescook@chromium.org</email>
</author>
<published>2021-04-14T22:45:39Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=c430f60036af44079170ff71a461b9d7cf5ee431'/>
<id>urn:sha1:c430f60036af44079170ff71a461b9d7cf5ee431</id>
<content type='text'>
When commit a28a6e860c6c ("string.h: move fortified functions definitions
in a dedicated header.") moved the fortify-specific code, some helpers
were left behind. Move the remaining fortify-specific helpers into
fortify-string.h so they're together where they're used. This requires
that any FORTIFY helper function prototypes be conditionally built to
avoid "no prototype" warnings. Additionally removes unused helpers.

Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: Daniel Axtens &lt;dja@axtens.net&gt;
Cc: Vincenzo Frascino &lt;vincenzo.frascino@arm.com&gt;
Cc: Andrey Konovalov &lt;andreyknvl@google.com&gt;
Cc: Dan Williams &lt;dan.j.williams@intel.com&gt;
Acked-by: Francis Laniel &lt;laniel_francis@privacyrequired.com&gt;
Reviewed-by: Nick Desaulniers &lt;ndesaulniers@google.com&gt;
Signed-off-by: Kees Cook &lt;keescook@chromium.org&gt;
</content>
</entry>
<entry>
<title>string.h: move fortified functions definitions in a dedicated header.</title>
<updated>2021-02-26T17:41:04Z</updated>
<author>
<name>Francis Laniel</name>
<email>laniel_francis@privacyrequired.com</email>
</author>
<published>2021-02-26T01:21:20Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=a28a6e860c6cf231cf3c5171c75c342adcd00406'/>
<id>urn:sha1:a28a6e860c6cf231cf3c5171c75c342adcd00406</id>
<content type='text'>
This patch adds fortify-string.h to contain fortified functions
definitions.  Thus, the code is more separated and compile time is
approximately 1% faster for people who do not set CONFIG_FORTIFY_SOURCE.

Link: https://lkml.kernel.org/r/20210111092141.22946-1-laniel_francis@privacyrequired.com
Link: https://lkml.kernel.org/r/20210111092141.22946-2-laniel_francis@privacyrequired.com
Signed-off-by: Francis Laniel &lt;laniel_francis@privacyrequired.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
</feed>
