Implements r_sys_aslr for NetBSD ##port (#17588)

ASLR on NetBSD is also settable via sysctl call.
This commit is contained in:
David CARLIER 2020-09-04 20:52:16 +01:00 committed by GitHub
parent 52d5b867aa
commit 15e73666b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -278,7 +278,7 @@ static void setASLR(RRunProfile *r, int enabled) {
// for osxver>=10.7
// "unset the MH_PIE bit in an already linked executable" with --no-pie flag of the script
// the right way is to disable the aslr bit in the spawn call
#elif __FreeBSD__
#elif __FreeBSD__ || __NetBSD__
r_sys_aslr (enabled);
#else
// not supported for this platform

View File

@ -5,6 +5,7 @@
#include <string.h>
#if defined(__NetBSD__)
# include <sys/param.h>
# include <sys/sysctl.h>
# if __NetBSD_Prereq__(7,0,0)
# define NETBSD_WITH_BACKTRACE
# endif
@ -553,6 +554,12 @@ R_API bool r_sys_aslr(int val) {
ret = false;
}
#endif
#elif __NetBSD__
size_t vlen = sizeof (val);
if (sysctlbyname ("security.pax.aslr.enabled", NULL, 0, &val, vlen) == -1) {
eprintf ("Failed to set RVA\n");
ret = false;
}
#endif
return ret;
}