1
linux/lib/test_fortify
Masahiro Yamada 9c6b7fbbd7 fortify: use if_changed_dep to record header dependency in *.cmd files
After building with CONFIG_FORTIFY_SOURCE=y, many .*.d files are left
in lib/test_fortify/ because the compiler outputs header dependencies
into *.d without fixdep being invoked.

When compiling C files, if_changed_dep should be used so that the
auto-generated header dependencies are recorded in .*.cmd files.

Currently, if_changed is incorrectly used, and only two headers are
hard-coded in lib/Makefile.

In the previous patch version, the kbuild test robot detected new errors
on GCC 7.

GCC 7 or older does not produce test.d with the following test code:

 $ echo 'void b(void) __attribute__((__error__(""))); void a(void) { b(); }' |
   gcc -Wp,-MMD,test.d -c -o /dev/null -x c -

Perhaps, this was a bug that existed in older GCC versions.

Skip the tests for GCC<=7 for now, as this will be eventually solved
when we bump the minimal supported GCC version.

Link: https://lore.kernel.org/oe-kbuild-all/CAK7LNARmJcyyzL-jVJfBPi3W684LTDmuhMf1koF0TXoCpKTmcw@mail.gmail.com/T/#m13771bf78ae21adff22efc4d310c973fb4bcaf67
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Link: https://lore.kernel.org/r/20240727150302.1823750-4-masahiroy@kernel.org
Signed-off-by: Kees Cook <kees@kernel.org>
2024-08-15 09:26:02 -07:00
..
.gitignore fortify: refactor test_fortify Makefile to fix some build problems 2024-08-15 09:26:02 -07:00
Makefile fortify: use if_changed_dep to record header dependency in *.cmd files 2024-08-15 09:26:02 -07:00
read_overflow2_field-memcpy.c
read_overflow2_field-memmove.c fortify: Detect struct member overflows in memmove() at compile-time 2022-02-13 16:50:06 -08:00
read_overflow2-memcmp.c
read_overflow2-memcpy.c
read_overflow2-memmove.c
read_overflow-memchr_inv.c
read_overflow-memchr.c
read_overflow-memcmp.c
read_overflow-memscan.c
test_fortify.h
test_fortify.sh fortify: move test_fortify.sh to lib/test_fortify/ 2024-08-15 09:26:02 -07:00
write_overflow_field-memcpy.c
write_overflow_field-memmove.c fortify: Detect struct member overflows in memmove() at compile-time 2022-02-13 16:50:06 -08:00
write_overflow_field-memset.c fortify: Detect struct member overflows in memset() at compile-time 2022-02-13 16:50:06 -08:00
write_overflow-memcpy.c
write_overflow-memmove.c
write_overflow-memset.c
write_overflow-strcpy-lit.c
write_overflow-strcpy.c
write_overflow-strncpy-src.c
write_overflow-strncpy.c
write_overflow-strscpy.c