From df608af11ff903836b8a2be235719511df03b025 Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 16 Jan 2016 02:52:43 +0200 Subject: [PATCH] use compat memory layout seems to help with hiding crocodingus' bugs --- loader/loader.c | 8 ++++++++ loader/syscalls.S | 1 + loader/syscalls.h | 1 + 3 files changed, 10 insertions(+) diff --git a/loader/loader.c b/loader/loader.c index 8a021df..84758c1 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -15,6 +15,7 @@ #include "header.h" #include "realfuncs.h" +#include "syscalls.h" char *bin_path; char **g_argv; @@ -76,6 +77,7 @@ int main(int argc, char *argv[]) long *stack_frame; struct stat st; char buf[64]; + long lret; if (argc < 2) { fprintf(stderr, "usage: %s [args]\n", argv[0]); @@ -84,6 +86,12 @@ int main(int argc, char *argv[]) g_argv = argv; + lret = g_personality(-1); + if (g_syscall_error(lret) != -1) { + lret |= 0x0240000; // ADDR_COMPAT_LAYOUT | ADDR_NO_RANDOMIZE + g_personality(lret); + } + fi = fopen("/proc/self/maps", "r"); CHECK_NE(fi, NULL, "fopen maps"); diff --git a/loader/syscalls.S b/loader/syscalls.S index d478582..f08de56 100644 --- a/loader/syscalls.S +++ b/loader/syscalls.S @@ -103,4 +103,5 @@ raw_syscall_easy g_readlink_raw, __NR_readlink raw_syscall_easy g_execve_raw, __NR_execve raw_syscall_easy g_clock_gettime_raw, __NR_clock_gettime raw_syscall_easy g_rt_sigprocmask_raw, __NR_rt_sigprocmask +raw_syscall_easy g_personality, __NR_personality raw_syscall_easy g_exit_group_raw, __NR_exit_group diff --git a/loader/syscalls.h b/loader/syscalls.h index 9978532..5d38cbb 100644 --- a/loader/syscalls.h +++ b/loader/syscalls.h @@ -31,6 +31,7 @@ long g_execve_raw(const char *filename, char * const argv[], long g_clock_gettime_raw(int clk_id, const struct timespec *tp); long g_rt_sigprocmask_raw(int how, const void *set, void *oldset, size_t sigsetsize); +long g_personality(long persona); long __attribute__((noreturn)) g_exit_group_raw(int status); -- 2.39.5