From: Michael Davidson Date: Fri, 14 Apr 2017 21:15:09 +0000 (-0700) Subject: misc: lkdtm: Add volatile to intentional NULL pointer reference X-Git-Tag: v4.12-rc1~95^2~10 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=9e18308a5dcc2250a271e598dfe0d917b5522475;p=karo-tx-linux.git misc: lkdtm: Add volatile to intentional NULL pointer reference Add a volatile qualifier where a NULL pointer is deliberately dereferenced to trigger a panic. Without the volatile qualifier clang will issue the following warning: "indirection of non-volatile null pointer will be deleted, not trap [-Wnull-dereference]" and replace the pointer reference with a __builtin_trap() (which generates a ud2 instruction on x86_64). Signed-off-by: Michael Davidson Signed-off-by: Matthias Kaehlcke Acked-by: Kees Cook Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/misc/lkdtm_bugs.c b/drivers/misc/lkdtm_bugs.c index ed4f4c56c796..d9028ef50fbe 100644 --- a/drivers/misc/lkdtm_bugs.c +++ b/drivers/misc/lkdtm_bugs.c @@ -69,7 +69,7 @@ void lkdtm_WARNING(void) void lkdtm_EXCEPTION(void) { - *((int *) 0) = 0; + *((volatile int *) 0) = 0; } void lkdtm_LOOP(void)