mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-23 05:56:14 -04:00
lkdtm: Avoid more compiler optimizations for bad writes
It seems at least Clang is able to throw away writes it knows are
destined for read-only memory, which makes things like the WRITE_RO test
fail, as the write gets elided. Instead, force the variable to be
volatile, and make similar changes through-out other tests in an effort
to avoid needing to repeat fixing these kinds of problems. Also includes
pr_err() calls in failure paths so that kernel logs are more clear in
the failure case.
Reported-by: Prasad Sodagudi <psodagud@codeaurora.org>
Suggested-by: Sami Tolvanen <samitolvanen@google.com>
Fixes: 9ae113ce5f ("lkdtm: add tests for additional page permissions")
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20200625203704.317097-2-keescook@chromium.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
4afc339ef0
commit
464e86b4ab
@@ -118,9 +118,8 @@ noinline void lkdtm_CORRUPT_STACK(void)
|
||||
/* Use default char array length that triggers stack protection. */
|
||||
char data[8] __aligned(sizeof(void *));
|
||||
|
||||
__lkdtm_CORRUPT_STACK(&data);
|
||||
|
||||
pr_info("Corrupted stack containing char array ...\n");
|
||||
pr_info("Corrupting stack containing char array ...\n");
|
||||
__lkdtm_CORRUPT_STACK((void *)&data);
|
||||
}
|
||||
|
||||
/* Same as above but will only get a canary with -fstack-protector-strong */
|
||||
@@ -131,9 +130,8 @@ noinline void lkdtm_CORRUPT_STACK_STRONG(void)
|
||||
unsigned long *ptr;
|
||||
} data __aligned(sizeof(void *));
|
||||
|
||||
__lkdtm_CORRUPT_STACK(&data);
|
||||
|
||||
pr_info("Corrupted stack containing union ...\n");
|
||||
pr_info("Corrupting stack containing union ...\n");
|
||||
__lkdtm_CORRUPT_STACK((void *)&data);
|
||||
}
|
||||
|
||||
void lkdtm_UNALIGNED_LOAD_STORE_WRITE(void)
|
||||
@@ -248,6 +246,7 @@ void lkdtm_ARRAY_BOUNDS(void)
|
||||
|
||||
kfree(not_checked);
|
||||
kfree(checked);
|
||||
pr_err("FAIL: survived array bounds overflow!\n");
|
||||
}
|
||||
|
||||
void lkdtm_CORRUPT_LIST_ADD(void)
|
||||
|
||||
Reference in New Issue
Block a user