summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Davidson <md@google.com>2017-04-14 14:15:09 -0700
committerMichael Bestas <mkbestas@lineageos.org>2020-02-02 01:40:03 +0200
commit422f6e6549b3bc5c2ca9b1e4a8fb0d2fa7f56578 (patch)
treedb8f3c1b9fee39e1c148c14a818cc219cc6dcc3e
parent1e0ab50e9c00857c1e256f2404cc03673c9769f7 (diff)
BACKPORT: 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 <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> Link: https://git.kernel.org/linus/9e18308a5dcc2250a271e598dfe0d917b5522475 Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
-rw-r--r--drivers/misc/lkdtm.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
index 8e06e1020ad9..b083bca03abe 100644
--- a/drivers/misc/lkdtm.c
+++ b/drivers/misc/lkdtm.c
@@ -392,7 +392,7 @@ static void lkdtm_do_action(enum ctype which)
WARN_ON(1);
break;
case CT_EXCEPTION:
- *((int *) 0) = 0;
+ *((volatile int *) 0) = 0;
break;
case CT_LOOP:
for (;;)