Skip to content

Instantly share code, notes, and snippets.

@simonask
Created September 9, 2009 21:12
Show Gist options
  • Save simonask/184085 to your computer and use it in GitHub Desktop.
Save simonask/184085 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <string.h>
#define PAGESIZE 4096
typedef unsigned char byte;
int main (int argc, char const *argv[])
{
byte* a = (byte*)malloc(PAGESIZE);
memset(a, 0xcd, PAGESIZE);
byte* b = (byte*)valloc(PAGESIZE);
memset(b, 0xab, PAGESIZE);
mprotect(b, PAGESIZE, PROT_NONE);
free(a);
free(b);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment