mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 10:15:57 +01:00
strlen_overflow and CONFIG_FORTIFY_SOURCE
This commit is contained in:
@@ -45,6 +45,8 @@
|
||||
.. link:netlink.c[]
|
||||
. Utilities
|
||||
.. link:kstrto.c[]
|
||||
. Hardening
|
||||
.. link:strlen_overflow.c[]
|
||||
. Arch
|
||||
.. x86
|
||||
... link:ring0.c[]
|
||||
|
||||
24
kernel_module/strlen_overflow.c
Normal file
24
kernel_module/strlen_overflow.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
static int myinit(void)
|
||||
{
|
||||
enum { size = 256 };
|
||||
int i = 1;
|
||||
char buf[size];
|
||||
char buf2[size];
|
||||
for (i = 0; i < size; i++) {
|
||||
buf[i] = 'a';
|
||||
buf2[i] = 'b';
|
||||
}
|
||||
/*char buf[] = {'p', 'w', 'n'};*/
|
||||
pr_info("%llu\n", (long long unsigned)strlen(buf));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void myexit(void) {}
|
||||
|
||||
module_init(myinit)
|
||||
module_exit(myexit)
|
||||
MODULE_LICENSE("GPL");
|
||||
Reference in New Issue
Block a user