summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2017-01-11 15:56:44 +0100
committerMichael Bestas <mkbestas@lineageos.org>2020-02-02 01:41:07 +0200
commit9baaf4b3d95fb11826612b22b8e397691371279d (patch)
tree60ed681ba15c5cc92170433a7622bd46148365dd
parent8c0050c75a7dc7f67d74e70499041cd4b58b0c3c (diff)
BACKPORT: 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.c: In function 'lkdtm_CORRUPT_STACK': drivers/misc/lkdtm.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> Link: https://git.kernel.org/linus/7a11a1d1b58873b2e5a6922dcdc23b6b339b14ba Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
-rw-r--r--drivers/misc/lkdtm.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
index ba6b80715c39..7b8b2024b810 100644
--- a/drivers/misc/lkdtm.c
+++ b/drivers/misc/lkdtm.c
@@ -343,12 +343,17 @@ static void do_overwritten(void)
return;
}
+static noinline void __lkdtm_CORRUPT_STACK(void *stack)
+{
+ memset(stack, 'a', 64);
+}
+
static noinline void 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);
}