Last active
June 22, 2016 15:33
-
-
Save strizhechenko/4e6269d1e891ff9c2b2c0b12c7654d45 to your computer and use it in GitHub Desktop.
xt_panic.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <linux/types.h> | |
#include <linux/unistd.h> | |
#include <linux/ctype.h> | |
#include <linux/module.h> | |
#include <linux/init.h> | |
#include <linux/kernel.h> | |
#include <linux/proc_fs.h> | |
#include <net/ip.h> | |
static struct proc_dir_entry *proc_xt_panic, *proc_xt_panic_ctl; | |
MODULE_ALIAS("xt_panic"); | |
MODULE_LICENSE("GPL"); | |
int try_to_panic() { | |
char *p; | |
kfree(p); | |
printk("%s%s", 1488/0, NULL); | |
return 0; | |
} | |
static int proc_read_panic_ctl(char *page, char **start, off_t off, | |
int count, int *eof, void *data) | |
{ | |
try_to_panic(); | |
return count; | |
} | |
static int proc_write_panic_ctl(struct file *file, const char *buffer, | |
unsigned long count, void *data) | |
{ | |
try_to_panic(); | |
return count; | |
} | |
static int __init xt_panic_init(void) | |
{ | |
proc_xt_panic = proc_mkdir("xt_panic", init_net.proc_net); | |
proc_xt_panic_ctl = create_proc_entry("ctl", 0644, proc_xt_panic); | |
proc_xt_panic_ctl->write_proc = proc_write_panic_ctl; | |
proc_xt_panic_ctl->read_proc = proc_read_panic_ctl; | |
return 0; | |
} | |
static void __exit xt_panic_cleanup(void) | |
{ | |
return; | |
} | |
module_init(xt_panic_init); | |
module_exit(xt_panic_cleanup); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment