summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2016-11-15 18:02:32 +1100
committerMichael Bestas <mkbestas@lineageos.org>2020-02-02 01:41:07 +0200
commit8c0050c75a7dc7f67d74e70499041cd4b58b0c3c (patch)
treeaeb18cc738996a1d99447034417b2f5eef4b1640
parent469a6a56f4dd2a16bc3cad3072250e806b705156 (diff)
BACKPORT: 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> Link: https://git.kernel.org/linus/c55d240003ae253d3057dcf93510c9bd64bb7a09 Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
-rw-r--r--drivers/misc/lkdtm.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
index b083bca03abe..ba6b80715c39 100644
--- a/drivers/misc/lkdtm.c
+++ b/drivers/misc/lkdtm.c
@@ -348,7 +348,8 @@ static noinline void corrupt_stack(void)
/* Use default char array length that triggers stack protection. */
char data[8];
- memset((void *)data, 0, 64);
+ memset((void *)data, 'a', 64);
+ pr_info("Corrupted stack with '%16s'...\n", data);
}
static void execute_location(void *dst)