Skip to content

Commit

Permalink
lkdtm: silence warnings about function declarations
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
kees committed Jul 15, 2016
1 parent 2b271cb commit 6d2e91a
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 25 deletions.
5 changes: 4 additions & 1 deletion drivers/misc/lkdtm.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#ifndef __LKDTM_H
#define __LKDTM_H

#define pr_fmt(fmt) "lkdtm: " fmt

#include <linux/kernel.h>

/* lkdtm_bugs.c */
void __init lkdtm_bugs_init(int *recur_param);
void lkdtm_PANIC(void);
Expand Down Expand Up @@ -53,5 +57,4 @@ void lkdtm_USERCOPY_STACK_FRAME_FROM(void);
void lkdtm_USERCOPY_STACK_BEYOND(void);
void lkdtm_USERCOPY_KERNEL(void);


#endif
6 changes: 1 addition & 5 deletions drivers/misc/lkdtm_bugs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
* lockups) along with other things that don't fit well into existing LKDTM
* test source files.
*/
#define pr_fmt(fmt) "lkdtm: " fmt

#include <linux/kernel.h>
#include <linux/sched.h>

#include "lkdtm.h"
#include <linux/sched.h>

/*
* Make sure our attempts to over run the kernel stack doesn't trigger
Expand Down
6 changes: 1 addition & 5 deletions drivers/misc/lkdtm_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
*
* See Documentation/fault-injection/provoke-crashes.txt for instructions
*/
#define pr_fmt(fmt) "lkdtm: " fmt

#include <linux/kernel.h>
#include "lkdtm.h"
#include <linux/fs.h>
#include <linux/module.h>
#include <linux/buffer_head.h>
Expand All @@ -49,8 +47,6 @@
#include <linux/ide.h>
#endif

#include "lkdtm.h"

#define DEFAULT_COUNT 10

static int lkdtm_debugfs_open(struct inode *inode, struct file *file);
Expand Down
6 changes: 1 addition & 5 deletions drivers/misc/lkdtm_heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
* This is for all the tests relating directly to heap memory, including
* page allocation and slab allocations.
*/
#define pr_fmt(fmt) "lkdtm: " fmt

#include <linux/kernel.h>
#include <linux/slab.h>

#include "lkdtm.h"
#include <linux/slab.h>

/*
* This tries to stay within the next largest power-of-2 kmalloc cache
Expand Down
6 changes: 1 addition & 5 deletions drivers/misc/lkdtm_perms.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
* permissions: non-executable regions, non-writable regions, and
* even non-readable regions.
*/
#define pr_fmt(fmt) "lkdtm: " fmt

#include <linux/kernel.h>
#include "lkdtm.h"
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/mman.h>
#include <linux/uaccess.h>
#include <asm/cacheflush.h>

#include "lkdtm.h"

/* Whether or not to fill the target memory area with do_nothing(). */
#define CODE_WRITE true
#define CODE_AS_IS false
Expand Down
2 changes: 1 addition & 1 deletion drivers/misc/lkdtm_rodata.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This includes functions that are meant to live entirely in .rodata
* (via objcopy tricks), to validate the non-executability of .rodata.
*/
#include <linux/kernel.h>
#include "lkdtm.h"

void lkdtm_rodata_do_nothing(void)
{
Expand Down
4 changes: 1 addition & 3 deletions drivers/misc/lkdtm_usercopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
* This is for all the tests related to copy_to_user() and copy_from_user()
* hardening.
*/
#define pr_fmt(fmt) "lkdtm: " fmt

#include <linux/kernel.h>
#include "lkdtm.h"
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/mman.h>
Expand Down

0 comments on commit 6d2e91a

Please sign in to comment.