diff options
author | Arnd Bergmann <arnd@arndb.de> | 2017-01-11 15:56:44 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-01-19 12:42:25 +0100 |
commit | 7a11a1d1b58873b2e5a6922dcdc23b6b339b14ba (patch) | |
tree | 822667e7c3c8d81f37ed1363a672bbe8f4e5c6af /drivers/misc | |
parent | 4474f4c40a9c607c7317e686b23619b7b768004f (diff) | |
download | linux-7a11a1d1b58873b2e5a6922dcdc23b6b339b14ba.tar.gz linux-7a11a1d1b58873b2e5a6922dcdc23b6b339b14ba.tar.bz2 linux-7a11a1d1b58873b2e5a6922dcdc23b6b339b14ba.zip |
lkdtm: hide stack overflow warning for corrupt-stack test
After the latest change to make sure the compiler actually does a memset,
it is now smart enough to flag the stack overflow at compile time,
at least with gcc-7.0:
drivers/misc/lkdtm_bugs.c: In function 'lkdtm_CORRUPT_STACK':
drivers/misc/lkdtm_bugs.c:88:144: warning: 'memset' writing 64 bytes into a region of size 8 overflows the destination [-Wstringop-overflow=]
To outsmart the compiler again, this moves the memset into a noinline
function where (for now) it doesn't see that we intentionally write
broken code here.
Fixes: c55d240003ae ("lkdtm: Prevent the compiler from optimising lkdtm_CORRUPT_STACK()")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/lkdtm_bugs.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/misc/lkdtm_bugs.c b/drivers/misc/lkdtm_bugs.c index 91edd0b55e5c..bb3bb8ef5f44 100644 --- a/drivers/misc/lkdtm_bugs.c +++ b/drivers/misc/lkdtm_bugs.c @@ -80,12 +80,17 @@ void lkdtm_OVERFLOW(void) (void) recursive_loop(recur_count); } +static noinline void __lkdtm_CORRUPT_STACK(void *stack) +{ + memset(stack, 'a', 64); +} + noinline void lkdtm_CORRUPT_STACK(void) { /* Use default char array length that triggers stack protection. */ char data[8]; + __lkdtm_CORRUPT_STACK(&data); - memset((void *)data, 'a', 64); pr_info("Corrupted stack with '%16s'...\n", data); } |