this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Implement _POSIX_SPAWN_DISABLE_ASLR (darlinghq/darling#304)

+16 -1
+16 -1
src/kernel/emulation/linux/process/posix_spawn.c
··· 20 20 #include "fork.h" 21 21 #include <stddef.h> 22 22 #include <stdint.h> 23 - #include "../../../../../kernel-include/sys/spawn.h" 23 + #include <sys/spawn.h> 24 + 25 + #ifndef _POSIX_SPAWN_DISABLE_ASLR 26 + #define _POSIX_SPAWN_DISABLE_ASLR 0x0100 27 + #endif 28 + 29 + #define LINUX_ADDR_NO_RANDOMIZE 0x40000 24 30 25 31 long sys_posix_spawn(int* pid, const char* path, const struct _posix_spawn_args_desc* desc, 26 32 char** argvp, char** envp) ··· 60 66 ret = sys_sigprocmask(3 /* SIG_SETMASK */, &desc->attrp->psa_sigmask, NULL); 61 67 if (ret != 0) 62 68 goto fail; 69 + } 70 + if (desc->attrp->psa_flags & _POSIX_SPAWN_DISABLE_ASLR) 71 + { 72 + unsigned int pers = LINUX_SYSCALL(__NR_personality, 0xffffffff); 73 + if (!(pers & LINUX_ADDR_NO_RANDOMIZE)) 74 + { 75 + pers |= LINUX_ADDR_NO_RANDOMIZE; 76 + LINUX_SYSCALL(__NR_personality, pers); 77 + } 63 78 } 64 79 65 80 // TODO: other attributes