summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobertswiecki <robert@swiecki.net>2023-12-07 06:53:24 +0100
committerGitHub <noreply@github.com>2023-12-07 06:53:24 +0100
commit5d924635d460515430e05b382e9f45e70f478a62 (patch)
tree8caf8d509fe2395828e7b5666fb1de92f5f98a55
parented603620dd8c48ab27bcbc0e3cbc373a4839168c (diff)
parent47bb7adc5dbc1f2ef67d449b3aadb6c758c44c51 (diff)
downloadhonggfuzz-5d924635d460515430e05b382e9f45e70f478a62.tar.gz
Merge pull request #505 from devnexen/solaris_noaslr
solaris based system, disable process ASLR.
-rw-r--r--Makefile4
-rw-r--r--posix/arch.c25
2 files changed, 27 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index b123b2b0..df0bc4f6 100644
--- a/Makefile
+++ b/Makefile
@@ -161,8 +161,8 @@ else
-Wno-unknown-warning-option -Wno-unknown-pragmas
ARCH_LDFLAGS := -L/usr/local/lib -lm
ifeq ($(OS),SunOS)
- ARCH_CFLAGS += -D_POSIX_C_SOURCE=200809L -D__EXTENSIONS__=1
- ARCH_LDFLAGS += -lkstat -lsocket -lnsl
+ ARCH_CFLAGS += -m64 -D_POSIX_C_SOURCE=200809L -D__EXTENSIONS__=1
+ ARCH_LDFLAGS += -m64 -lkstat -lsocket -lnsl -lkvm
endif
ifneq ($(REALOS),OpenBSD)
ifneq ($(REALOS),Darwin)
diff --git a/posix/arch.c b/posix/arch.c
index 9e1cc3a0..1c874d72 100644
--- a/posix/arch.c
+++ b/posix/arch.c
@@ -34,6 +34,9 @@
#include <string.h>
#if !defined(__sun)
#include <sys/cdefs.h>
+#else
+#include <kvm.h>
+#include <sys/proc.h>
#endif
#if defined(__FreeBSD__)
#include <sys/procctl.h>
@@ -202,6 +205,28 @@ bool arch_launchChild(run_t* run) {
procctl(P_PID, 0, PROC_ASLR_CTL, &disableRandomization) == -1) {
PLOG_D("procctl(PROC_ASLR_CTL, PROC_ASLR_FORCE_DISABLE) failed");
}
+#elif defined(__sun)
+ if (run->global->arch_linux.disableRandomization) {
+ kvm_t* hd = NULL;
+ proc_t* cur = NULL;
+ int enableTrace = PROC_SEC_ASLR;
+ if ((hd = kvm_open(NULL, NULL, NULL, O_RDWR, NULL)) == NULL) {
+ PLOG_E("kvm_open() failed");
+ return false;
+ }
+
+ // unlikely but who knows
+ if ((cur = kvm_getproc(hd, getpid())) == NULL) {
+ PLOG_E("kvm_getproc() failed");
+ kvm_close(hd);
+ return false;
+ }
+ if (secflag_isset(cur->p_secflags.psf_effective, enableTrace)) {
+ secflag_clear(&cur->p_secflags.psf_effective, enableTrace);
+ }
+ kvm_close(hd);
+ }
+
#endif
/* alarm persists across forks, so disable it here */
alarm(0);