From 799788bab2730fa21bfa59b234f98d98c2feeea7 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Sun, 25 Feb 2018 23:16:18 +0100 Subject: misc-modules: faulty: Open code memset() to allow a buffer overflow The memset() function is now fortified, which means that provides both a compile and runtime buffer overflow checks. Since the goal of the faulty module is to cause a buffer overflow this function can't be used anymore and instead have to be open coded. Signed-off-by: Javier Martinez Canillas --- misc-modules/faulty.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/misc-modules/faulty.c b/misc-modules/faulty.c index 95038b7..c6c44b4 100644 --- a/misc-modules/faulty.c +++ b/misc-modules/faulty.c @@ -31,11 +31,13 @@ int faulty_major = 0; ssize_t faulty_read(struct file *filp, char __user *buf, size_t count, loff_t *pos) { + int i; int ret; char stack_buf[4]; /* Let's try a buffer overflow */ - memset(stack_buf, 0xff, 20); + for (i = 0; i < 20; i++) + *(stack_buf + i) = 0xff; if (count > 4) count = 4; /* copy 4 bytes to the user */ ret = copy_to_user(buf, stack_buf, count); -- cgit v1.2.1-18-gbd029