-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvuln_module.c
More file actions
34 lines (27 loc) · 805 Bytes
/
vuln_module.c
File metadata and controls
34 lines (27 loc) · 805 Bytes
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
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/uaccess.h>
#define DEVICE_NAME "vuln_dev"
static char buffer[64];
static ssize_t vuln_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) {
char local_buf[64];
copy_from_user(local_buf, user_buf, count); // ¡Desbordamiento si count > 64!
printk(KERN_INFO "Buffer: %s\n", local_buf);
return count;
}
static struct file_operations fops = {
.owner = THIS_MODULE,
.write = vuln_write,
};
static int __init vuln_init(void) {
register_chrdev(0, DEVICE_NAME, &fops);
return 0;
}
static void __exit vuln_exit(void) {
unregister_chrdev(0, DEVICE_NAME);
}
module_init(vuln_init);
module_exit(vuln_exit);
MODULE_LICENSE("GPL");