From: notaz Date: Sat, 16 Jan 2016 00:52:43 +0000 (+0200) Subject: use compat memory layout X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df608af11ff903836b8a2be235719511df03b025;p=ginge.git use compat memory layout seems to help with hiding crocodingus' bugs --- 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);