#include "lkdtm.h"
#include <linux/fs.h>
#include <linux/module.h>
#include <linux/buffer_head.h>
#include <linux/kprobes.h>
#include <linux/list.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/debugfs.h>
#include <linux/utsname.h>
#define DEFAULT_COUNT …
static int lkdtm_debugfs_open(struct inode *inode, struct file *file);
static ssize_t lkdtm_debugfs_read(struct file *f, char __user *user_buf,
size_t count, loff_t *off);
static ssize_t direct_entry(struct file *f, const char __user *user_buf,
size_t count, loff_t *off);
#ifdef CONFIG_KPROBES
static int lkdtm_kprobe_handler(struct kprobe *kp, struct pt_regs *regs);
static ssize_t lkdtm_debugfs_entry(struct file *f,
const char __user *user_buf,
size_t count, loff_t *off);
#define CRASHPOINT_KPROBE(_symbol) …
#define CRASHPOINT_WRITE(_symbol) …
#else
#define CRASHPOINT_KPROBE …
#define CRASHPOINT_WRITE …
#endif
struct crashpoint { … };
#define CRASHPOINT(_name, _symbol) …
static struct crashpoint crashpoints[] = …;
static const struct crashtype_category *crashtype_categories[] = …;
static struct kprobe *lkdtm_kprobe;
static struct crashpoint *lkdtm_crashpoint;
static const struct crashtype *lkdtm_crashtype;
static int recur_count = …;
module_param(recur_count, int, 0644);
MODULE_PARM_DESC(…) …;
static char* cpoint_name;
module_param(cpoint_name, charp, 0444);
MODULE_PARM_DESC(…) …;
static char* cpoint_type;
module_param(cpoint_type, charp, 0444);
MODULE_PARM_DESC(…) …;
static int cpoint_count = …;
module_param(cpoint_count, int, 0644);
MODULE_PARM_DESC(…) …;
char *lkdtm_kernel_info;
static const struct crashtype *find_crashtype(const char *name)
{ … }
static noinline int lkdtm_do_action(const struct crashtype *crashtype)
{ … }
static int lkdtm_register_cpoint(struct crashpoint *crashpoint,
const struct crashtype *crashtype)
{ … }
#ifdef CONFIG_KPROBES
static int crash_count = …;
static DEFINE_SPINLOCK(crash_count_lock);
static int lkdtm_kprobe_handler(struct kprobe *kp, struct pt_regs *regs)
{ … }
static ssize_t lkdtm_debugfs_entry(struct file *f,
const char __user *user_buf,
size_t count, loff_t *off)
{ … }
#endif
static ssize_t lkdtm_debugfs_read(struct file *f, char __user *user_buf,
size_t count, loff_t *off)
{ … }
static int lkdtm_debugfs_open(struct inode *inode, struct file *file)
{ … }
static ssize_t direct_entry(struct file *f, const char __user *user_buf,
size_t count, loff_t *off)
{ … }
#ifndef MODULE
struct check_cmdline_args { … };
static int lkdtm_parse_one(char *param, char *val,
const char *unused, void *arg)
{ … }
int lkdtm_check_bool_cmdline(const char *param)
{ … }
#endif
static struct dentry *lkdtm_debugfs_root;
static int __init lkdtm_module_init(void)
{ … }
static void __exit lkdtm_module_exit(void)
{ … }
module_init(…) …;
module_exit(lkdtm_module_exit);
MODULE_LICENSE(…) …;
MODULE_DESCRIPTION(…) …;