lkml.org 
[lkml]   [2017]   [Apr]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] misc: lkdtm: Add volatile to intentional NULL pointer reference
On Fri, Apr 14, 2017 at 2:15 PM, Matthias Kaehlcke <mka@chromium.org> wrote:
> From: Michael Davidson <md@google.com>
>
> 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>

Thanks!

Acked-by: Kees Cook <keescook@chromium.org>

Greg, please add this to drivers/misc when you get a chance. :)

-Kees

> ---
> drivers/misc/lkdtm_bugs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/misc/lkdtm_bugs.c b/drivers/misc/lkdtm_bugs.c
> index e3f4cd8876b5..d734d75afade 100644
> --- a/drivers/misc/lkdtm_bugs.c
> +++ b/drivers/misc/lkdtm_bugs.c
> @@ -67,7 +67,7 @@ void lkdtm_WARNING(void)
>
> void lkdtm_EXCEPTION(void)
> {
> - *((int *) 0) = 0;
> + *((volatile int *) 0) = 0;
> }
>
> void lkdtm_LOOP(void)
> --
> 2.12.2.762.g0e3151a226-goog
>



--
Kees Cook
Pixel Security

\
 
 \ /
  Last update: 2017-04-15 19:42    [W:0.035 / U:0.280 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site