Skip to content

Commit

Permalink
misc: lkdtm: Add volatile to intentional NULL pointer reference
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Davidson authored and Greg Kroah-Hartman committed Apr 18, 2017
1 parent 073a457 commit 9e18308
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/misc/lkdtm_bugs.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void lkdtm_WARNING(void)

void lkdtm_EXCEPTION(void)
{
*((int *) 0) = 0;
*((volatile int *) 0) = 0;
}

void lkdtm_LOOP(void)
Expand Down

0 comments on commit 9e18308

Please sign in to comment.