Skip to content

Commit 9c62b82

Browse files
committed
memcpy_overflow failed fortify source attempt
1 parent 5d9418b commit 9c62b82

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

README.adoc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4607,7 +4607,7 @@ Make it harder to get hacked and easier to notice that you were, at the cost of
46074607
Detects buffer overflows for us:
46084608

46094609
....
4610-
./build -C 'CONFIG_FORTIFY_SOURCE=y' -L fortify
4610+
./build -C 'CONFIG_FORTIFY_SOURCE=y' -L fortify -k
46114611
./run -F 'insmod /strlen_overflow.ko' -L fortify
46124612
....
46134613

@@ -4623,7 +4623,11 @@ followed by a trace.
46234623

46244624
You may not get this error because this depends on `strlen` overflowing at least until the next page: if a random `\0` appears soon enough, it won't blow up as desired.
46254625

4626-
I did observe this at link:http://github.com/cirosantilli/linux-kernel-module-cheat/commit/1b451a70d46a5c4619992ad4dd2e4b8f5a84c252[1b451a70d46a5c4619992ad4dd2e4b8f5a84c252] but not at link:http://github.com/cirosantilli/linux-kernel-module-cheat/commit/9b4c1984fc2cb04de0b4d62749cc1f8eabf26c6f[9b4c1984fc2cb04de0b4d62749cc1f8eabf26c6f] TODO: find a more reproducible failure.
4626+
TODO not always reproducible. Find a more reproducible failure. I could not observe it on:
4627+
4628+
....
4629+
insmod /memcpy_overflow.ko
4630+
....
46274631

46284632
Source: link:kernel_module/strlen_overflow.c[]
46294633

kernel_module/memcpy_overflow.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* https://github.com/cirosantilli/linux-kernel-module-cheat#config_fortify_source */
2+
3+
#include <linux/kernel.h>
4+
#include <linux/module.h>
5+
#include <linux/string.h>
6+
#include <linux/slab.h>
7+
8+
static int myinit(void)
9+
{
10+
void *dst, *src;
11+
dst = kmalloc(0x10, GFP_KERNEL);
12+
src = kmalloc(0x1000000, GFP_KERNEL);
13+
memcpy(dst, src, 0x1000000);
14+
return 0;
15+
}
16+
17+
static void myexit(void) {}
18+
19+
module_init(myinit)
20+
module_exit(myexit)
21+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)