forked from ExpLife/kernel-exploitation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvuln-mod.c
51 lines (36 loc) · 1.02 KB
/
vuln-mod.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
Author: Marcin Kozlowski <[email protected]>
*/
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/sched.h>
#include <linux/uaccess.h>
struct proc_dir_entry *proc_file_entry;
// Buggy write handling
static ssize_t buggy_write(struct file *file,const char *buf, size_t len, loff_t *off){
char data[4];
printk("buggy_write %s %i", buf, len);
__copy_from_user(&data, buf,len);
return len;
}
static const struct file_operations proc_file_fops = {
.owner = THIS_MODULE,
.write = buggy_write
};
int init_module()
{
printk("module started");
printk("creating proc entry @ /proc/buggy");
// handle anything written to /proc/buggy
// pass it to buggy_write
proc_file_entry = proc_create_data("buggy", 0666, NULL, &proc_file_fops,NULL);
return 0;
}
void cleanup_module()
{
remove_proc_entry("buggy", NULL);
}