diff options
author | Michael Ellerman <mpe@ellerman.id.au> | 2016-11-15 02:02:32 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-11-15 13:26:06 -0500 |
commit | c55d240003ae253d3057dcf93510c9bd64bb7a09 (patch) | |
tree | c80233dfdea2ba01b6a627fbe9cbc52a45df203c | |
parent | 967b274e02e18c9fbb4d19b96a89bd0afbc77b7a (diff) |
lkdtm: Prevent the compiler from optimising lkdtm_CORRUPT_STACK()
At least on powerpc with GCC 6, the compiler is smart enough to optimise
lkdtm_CORRUPT_STACK() into an empty function that just returns.
If we print the buffer after we've written to it that prevents the
compiler from optimising away data and the memset().
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/misc/lkdtm_bugs.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/misc/lkdtm_bugs.c b/drivers/misc/lkdtm_bugs.c index 182ae1894b32..30e62dd7e7ca 100644 --- a/drivers/misc/lkdtm_bugs.c +++ b/drivers/misc/lkdtm_bugs.c | |||
@@ -80,7 +80,8 @@ noinline void lkdtm_CORRUPT_STACK(void) | |||
80 | /* Use default char array length that triggers stack protection. */ | 80 | /* Use default char array length that triggers stack protection. */ |
81 | char data[8]; | 81 | char data[8]; |
82 | 82 | ||
83 | memset((void *)data, 0, 64); | 83 | memset((void *)data, 'a', 64); |
84 | pr_info("Corrupted stack with '%16s'...\n", data); | ||
84 | } | 85 | } |
85 | 86 | ||
86 | void lkdtm_UNALIGNED_LOAD_STORE_WRITE(void) | 87 | void lkdtm_UNALIGNED_LOAD_STORE_WRITE(void) |