lib/test_stackinit: Handle Clang auto-initialization pattern
authorKees Cook <keescook@chromium.org>
Wed, 5 Jun 2019 05:13:59 +0000 (22:13 -0700)
committerKees Cook <keescook@chromium.org>
Wed, 5 Jun 2019 14:36:43 +0000 (07:36 -0700)
commit8c30d32b1a326bb120635a8b4836ec61cba454fa
treeb438b50b70a974396862fa57d5e5bd938296c70b
parentf2c7c76c5d0a443053e94adb9f0918fa2fb85c3a
lib/test_stackinit: Handle Clang auto-initialization pattern

While the gcc plugin for automatic stack variable initialization (i.e.
CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL) performs initialization with
0x00 bytes, the Clang automatic stack variable initialization (i.e.
CONFIG_INIT_STACK_ALL) uses various type-specific patterns that are
typically 0xAA. Therefore the stackinit selftest has been fixed to check
that bytes are no longer the test fill pattern of 0xFF (instead of looking
for bytes that have become 0x00). This retains the test coverage for the
0x00 pattern of the gcc plugin while adding coverage for the mostly 0xAA
pattern of Clang.

Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
lib/test_stackinit.c