misc: lkdtm: Add volatile to intentional NULL pointer reference
PATCH 1/1 misc: lkdtm: Add volatile to intentional NULL pointer reference
From: Michael Davidson <[email protected]>
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).
--- drivers/misc/lkdtm_bugs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/lkdtm_bugs.c +1 -1
@@ -67,7 +67,7 @@ void lkdtm_WARNING(void)void lkdtm_EXCEPTION (void ) { - *((int *)0 ) =0 ; + *((volatile int *)0 ) =0 ; }void lkdtm_LOOP (void )
Signature · 1 line
2.12.2.762.g0e3151a226-goog
Quoted 5 lines · Matthias Kaehlcke
From: Michael Davidson <[email protected]>
Add a volatile qualifier where a NULL pointer is deliberately dereferenced to trigger a panic.
Quoted 7 lines
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 onx86_64).Signed-off-by Michael Davidson <[email protected]>Signed-off-by Matthias Kaehlcke <[email protected]>
Thanks!
Greg, please add this to drivers/misc when you get a chance. :)
-Kees
Quoted 20 lines
--- drivers/misc/lkdtm_bugs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/misc/lkdtm_bugs.c +1
-2@@ -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
Signature · 2 lines
Kees Cook Pixel Security