#include "lib/lizard.h"
#include <sys/mman.h>
-#include <sys/user.h>
#include <fcntl.h>
#include <signal.h>
#include <setjmp.h>
{
unhandle_signal(SIGSEGV);
if (buf->ptr)
- munmap(buf->ptr, buf->len + PAGE_SIZE);
+ munmap(buf->ptr, buf->len + CPU_PAGE_SIZE);
xfree(buf);
}
static void
lizard_realloc(struct lizard_buffer *buf, uns max_len)
- /* max_len needs to be aligned to PAGE_SIZE */
+ /* max_len needs to be aligned to CPU_PAGE_SIZE */
{
if (max_len <= buf->len)
return;
max_len = 2*buf->len;
if (buf->ptr)
- munmap(buf->ptr, buf->len + PAGE_SIZE);
+ munmap(buf->ptr, buf->len + CPU_PAGE_SIZE);
buf->len = max_len;
- buf->ptr = mmap(NULL, buf->len + PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
+ buf->ptr = mmap(NULL, buf->len + CPU_PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
if (buf->ptr == MAP_FAILED)
- die("mmap(anonymous, %d bytes): %m", (uns)(buf->len + PAGE_SIZE));
- if (mprotect(buf->ptr + buf->len, PAGE_SIZE, PROT_NONE) < 0)
+ die("mmap(anonymous, %d bytes): %m", (uns)(buf->len + CPU_PAGE_SIZE));
+ if (mprotect(buf->ptr + buf->len, CPU_PAGE_SIZE, PROT_NONE) < 0)
die("mprotect: %m");
}
* case of buffer-overflow. The function is not re-entrant because of a
* static longjmp handler. */
{
- uns lock_offset = ALIGN_TO(expected_length + 3, PAGE_SIZE); // +3 due to the unaligned access
+ uns lock_offset = ALIGN_TO(expected_length + 3, CPU_PAGE_SIZE); // +3 due to the unaligned access
if (lock_offset > buf->len)
lizard_realloc(buf, lock_offset);
volatile sh_sighandler_t old_handler = set_signal_handler(SIGSEGV, sigsegv_handler);