Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lkdtm: silence warnings about function declarations

When building under W=1, the lack of lkdtm.h in lkdtm_usercopy.c and
lkdtm_rodata.c was discovered. This fixes the issue and consolidates
the common header and the pr_fmt macro for simplicity and regularity
across each test source file.

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

+10 -25
+4 -1
drivers/misc/lkdtm.h
··· 1 1 #ifndef __LKDTM_H 2 2 #define __LKDTM_H 3 3 4 + #define pr_fmt(fmt) "lkdtm: " fmt 5 + 6 + #include <linux/kernel.h> 7 + 4 8 /* lkdtm_bugs.c */ 5 9 void __init lkdtm_bugs_init(int *recur_param); 6 10 void lkdtm_PANIC(void); ··· 56 52 void lkdtm_USERCOPY_STACK_FRAME_FROM(void); 57 53 void lkdtm_USERCOPY_STACK_BEYOND(void); 58 54 void lkdtm_USERCOPY_KERNEL(void); 59 - 60 55 61 56 #endif
+1 -5
drivers/misc/lkdtm_bugs.c
··· 4 4 * lockups) along with other things that don't fit well into existing LKDTM 5 5 * test source files. 6 6 */ 7 - #define pr_fmt(fmt) "lkdtm: " fmt 8 - 9 - #include <linux/kernel.h> 10 - #include <linux/sched.h> 11 - 12 7 #include "lkdtm.h" 8 + #include <linux/sched.h> 13 9 14 10 /* 15 11 * Make sure our attempts to over run the kernel stack doesn't trigger
+1 -5
drivers/misc/lkdtm_core.c
··· 30 30 * 31 31 * See Documentation/fault-injection/provoke-crashes.txt for instructions 32 32 */ 33 - #define pr_fmt(fmt) "lkdtm: " fmt 34 - 35 - #include <linux/kernel.h> 33 + #include "lkdtm.h" 36 34 #include <linux/fs.h> 37 35 #include <linux/module.h> 38 36 #include <linux/buffer_head.h> ··· 46 48 #ifdef CONFIG_IDE 47 49 #include <linux/ide.h> 48 50 #endif 49 - 50 - #include "lkdtm.h" 51 51 52 52 #define DEFAULT_COUNT 10 53 53
+1 -5
drivers/misc/lkdtm_heap.c
··· 2 2 * This is for all the tests relating directly to heap memory, including 3 3 * page allocation and slab allocations. 4 4 */ 5 - #define pr_fmt(fmt) "lkdtm: " fmt 6 - 7 - #include <linux/kernel.h> 8 - #include <linux/slab.h> 9 - 10 5 #include "lkdtm.h" 6 + #include <linux/slab.h> 11 7 12 8 /* 13 9 * This tries to stay within the next largest power-of-2 kmalloc cache
+1 -5
drivers/misc/lkdtm_perms.c
··· 3 3 * permissions: non-executable regions, non-writable regions, and 4 4 * even non-readable regions. 5 5 */ 6 - #define pr_fmt(fmt) "lkdtm: " fmt 7 - 8 - #include <linux/kernel.h> 6 + #include "lkdtm.h" 9 7 #include <linux/slab.h> 10 8 #include <linux/vmalloc.h> 11 9 #include <linux/mman.h> 12 10 #include <linux/uaccess.h> 13 11 #include <asm/cacheflush.h> 14 - 15 - #include "lkdtm.h" 16 12 17 13 /* Whether or not to fill the target memory area with do_nothing(). */ 18 14 #define CODE_WRITE true
+1 -1
drivers/misc/lkdtm_rodata.c
··· 2 2 * This includes functions that are meant to live entirely in .rodata 3 3 * (via objcopy tricks), to validate the non-executability of .rodata. 4 4 */ 5 - #include <linux/kernel.h> 5 + #include "lkdtm.h" 6 6 7 7 void lkdtm_rodata_do_nothing(void) 8 8 {
+1 -3
drivers/misc/lkdtm_usercopy.c
··· 2 2 * This is for all the tests related to copy_to_user() and copy_from_user() 3 3 * hardening. 4 4 */ 5 - #define pr_fmt(fmt) "lkdtm: " fmt 6 - 7 - #include <linux/kernel.h> 5 + #include "lkdtm.h" 8 6 #include <linux/slab.h> 9 7 #include <linux/vmalloc.h> 10 8 #include <linux/mman.h>