From: Kees Cook Date: Mon, 8 Jul 2013 17:01:30 +0000 (-0700) Subject: lkdtm: fix stack protector trigger X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4f198289747f0391bc5a5574279b1791a8ca2d06;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git lkdtm: fix stack protector trigger The -fstack-protector compiler flag will only build stack protections if a character array is seen. Additionally, the offset to the saved instruction pointer changes based on architecture, so stomp much harder (64 bytes) when corrupting the stack. Signed-off-by: Kees Cook Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c index 08aad69c8da4..adb6bde2ecc2 100644 --- a/drivers/misc/lkdtm.c +++ b/drivers/misc/lkdtm.c @@ -295,10 +295,10 @@ static void lkdtm_do_action(enum ctype which) (void) recursive_loop(0); break; case CT_CORRUPT_STACK: { - volatile u32 data[8]; - volatile u32 *p = data; + /* Make sure the compiler creates and uses an 8 char array. */ + volatile char data[8]; - p[12] = 0x12345678; + memset((void *)data, 0, 64); break; } case CT_UNALIGNED_LOAD_STORE_WRITE: {