diff options
author | Kees Cook <keescook@chromium.org> | 2013-10-25 01:05:42 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-11-29 19:27:56 (GMT) |
commit | 5bb21134853f6dc7bc16c7fcb24470e8676a3c54 (patch) | |
tree | 74030287f925e7aa0e8bc90d36c78d7606cfbe67 /drivers/misc/lkdtm.c | |
parent | adf0c46683b2c5b3ba261b21b68ad6e6b7592b89 (diff) | |
download | linux-fsl-qoriq-5bb21134853f6dc7bc16c7fcb24470e8676a3c54.tar.xz |
lkdtm: isolate stack corruption test
commit 629c66a22c21b692b6e58b9c1d8fa56a60ccb52d upstream.
When tests were added to lkdtm that grew the stack frame, the stack
corruption test stopped working. This isolates the test in its own
function, and forces it not to be inlined.
Signed-off-by: Kees Cook <keescook@chromium.org>
Fixes: cc33c537c12f ("lkdtm: add "EXEC_*" triggers")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/lkdtm.c')
-rw-r--r-- | drivers/misc/lkdtm.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c index 2fc0586..9cbd037 100644 --- a/drivers/misc/lkdtm.c +++ b/drivers/misc/lkdtm.c @@ -297,6 +297,14 @@ static void do_nothing(void) return; } +static noinline void corrupt_stack(void) +{ + /* Use default char array length that triggers stack protection. */ + char data[8]; + + memset((void *)data, 0, 64); +} + static void execute_location(void *dst) { void (*func)(void) = dst; @@ -327,13 +335,9 @@ static void lkdtm_do_action(enum ctype which) case CT_OVERFLOW: (void) recursive_loop(0); break; - case CT_CORRUPT_STACK: { - /* Make sure the compiler creates and uses an 8 char array. */ - volatile char data[8]; - - memset((void *)data, 0, 64); + case CT_CORRUPT_STACK: + corrupt_stack(); break; - } case CT_UNALIGNED_LOAD_STORE_WRITE: { static u8 data[5] __attribute__((aligned(4))) = {1, 2, 3, 4, 5}; |