Skip to content

Commit

Permalink
misc-modules: faulty: Open code memset() to allow a buffer overflow
Browse files Browse the repository at this point in the history
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 <javier@dowhile0.org>
  • Loading branch information
martinezjavier committed Feb 25, 2018
1 parent 11b2dfc commit 799788b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion misc-modules/faulty.c
Expand Up @@ -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);
Expand Down

0 comments on commit 799788b

Please sign in to comment.