提交 c55d2400 编写于 作者: M Michael Ellerman 提交者: Greg Kroah-Hartman

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: NMichael Ellerman <mpe@ellerman.id.au>
Acked-by: NKees Cook <keescook@chromium.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 967b274e
...@@ -80,7 +80,8 @@ noinline void lkdtm_CORRUPT_STACK(void) ...@@ -80,7 +80,8 @@ noinline void lkdtm_CORRUPT_STACK(void)
/* Use default char array length that triggers stack protection. */ /* Use default char array length that triggers stack protection. */
char data[8]; char data[8];
memset((void *)data, 0, 64); memset((void *)data, 'a', 64);
pr_info("Corrupted stack with '%16s'...\n", data);
} }
void lkdtm_UNALIGNED_LOAD_STORE_WRITE(void) void lkdtm_UNALIGNED_LOAD_STORE_WRITE(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册