]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
misc: lkdtm: Add volatile to intentional NULL pointer reference
authorMichael Davidson <md@google.com>
Fri, 14 Apr 2017 21:15:09 +0000 (14:15 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 18 Apr 2017 16:03:42 +0000 (18:03 +0200)
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 <md@google.com>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/lkdtm_bugs.c

index ed4f4c56c796a9550d38be8abe3a8f47858b36f2..d9028ef50fbe7762ba2e8f86631beea0e18d9cf5 100644 (file)
@@ -69,7 +69,7 @@ void lkdtm_WARNING(void)
 
 void lkdtm_EXCEPTION(void)
 {
-       *((int *) 0) = 0;
+       *((volatile int *) 0) = 0;
 }
 
 void lkdtm_LOOP(void)