Commit 75f98b7a authored by Kees Cook's avatar Kees Cook Committed by Greg Kroah-Hartman

lkdtm: Constify the crashtypes table

Since nothing in the crashtypes table ever changes, mark it const. Adds
some missing "static" markings as well.
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 31c5c870
...@@ -122,7 +122,7 @@ struct crashtype { ...@@ -122,7 +122,7 @@ struct crashtype {
} }
/* Define the possible types of crashes that can be triggered. */ /* Define the possible types of crashes that can be triggered. */
struct crashtype crashtypes[] = { static const struct crashtype crashtypes[] = {
CRASHTYPE(PANIC), CRASHTYPE(PANIC),
CRASHTYPE(BUG), CRASHTYPE(BUG),
CRASHTYPE(WARNING), CRASHTYPE(WARNING),
...@@ -188,8 +188,8 @@ struct crashtype crashtypes[] = { ...@@ -188,8 +188,8 @@ struct crashtype crashtypes[] = {
/* Global kprobe entry and crashtype. */ /* Global kprobe entry and crashtype. */
static struct kprobe *lkdtm_kprobe; static struct kprobe *lkdtm_kprobe;
struct crashpoint *lkdtm_crashpoint; static struct crashpoint *lkdtm_crashpoint;
struct crashtype *lkdtm_crashtype; static const struct crashtype *lkdtm_crashtype;
/* Module parameters */ /* Module parameters */
static int recur_count = -1; static int recur_count = -1;
...@@ -212,7 +212,7 @@ MODULE_PARM_DESC(cpoint_count, " Crash Point Count, number of times the "\ ...@@ -212,7 +212,7 @@ MODULE_PARM_DESC(cpoint_count, " Crash Point Count, number of times the "\
/* Return the crashtype number or NULL if the name is invalid */ /* Return the crashtype number or NULL if the name is invalid */
static struct crashtype *find_crashtype(const char *name) static const struct crashtype *find_crashtype(const char *name)
{ {
int i; int i;
...@@ -228,7 +228,7 @@ static struct crashtype *find_crashtype(const char *name) ...@@ -228,7 +228,7 @@ static struct crashtype *find_crashtype(const char *name)
* This is forced noinline just so it distinctly shows up in the stackdump * This is forced noinline just so it distinctly shows up in the stackdump
* which makes validation of expected lkdtm crashes easier. * which makes validation of expected lkdtm crashes easier.
*/ */
static noinline void lkdtm_do_action(struct crashtype *crashtype) static noinline void lkdtm_do_action(const struct crashtype *crashtype)
{ {
if (WARN_ON(!crashtype || !crashtype->func)) if (WARN_ON(!crashtype || !crashtype->func))
return; return;
...@@ -236,7 +236,7 @@ static noinline void lkdtm_do_action(struct crashtype *crashtype) ...@@ -236,7 +236,7 @@ static noinline void lkdtm_do_action(struct crashtype *crashtype)
} }
static int lkdtm_register_cpoint(struct crashpoint *crashpoint, static int lkdtm_register_cpoint(struct crashpoint *crashpoint,
struct crashtype *crashtype) const struct crashtype *crashtype)
{ {
int ret; int ret;
...@@ -300,7 +300,7 @@ static ssize_t lkdtm_debugfs_entry(struct file *f, ...@@ -300,7 +300,7 @@ static ssize_t lkdtm_debugfs_entry(struct file *f,
size_t count, loff_t *off) size_t count, loff_t *off)
{ {
struct crashpoint *crashpoint = file_inode(f)->i_private; struct crashpoint *crashpoint = file_inode(f)->i_private;
struct crashtype *crashtype = NULL; const struct crashtype *crashtype = NULL;
char *buf; char *buf;
int err; int err;
...@@ -368,7 +368,7 @@ static int lkdtm_debugfs_open(struct inode *inode, struct file *file) ...@@ -368,7 +368,7 @@ static int lkdtm_debugfs_open(struct inode *inode, struct file *file)
static ssize_t direct_entry(struct file *f, const char __user *user_buf, static ssize_t direct_entry(struct file *f, const char __user *user_buf,
size_t count, loff_t *off) size_t count, loff_t *off)
{ {
struct crashtype *crashtype; const struct crashtype *crashtype;
char *buf; char *buf;
if (count >= PAGE_SIZE) if (count >= PAGE_SIZE)
...@@ -404,7 +404,7 @@ static struct dentry *lkdtm_debugfs_root; ...@@ -404,7 +404,7 @@ static struct dentry *lkdtm_debugfs_root;
static int __init lkdtm_module_init(void) static int __init lkdtm_module_init(void)
{ {
struct crashpoint *crashpoint = NULL; struct crashpoint *crashpoint = NULL;
struct crashtype *crashtype = NULL; const struct crashtype *crashtype = NULL;
int ret = -EINVAL; int ret = -EINVAL;
int i; int i;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment