Skip to content

Commit 1457da7

Browse files
authored
Merge pull request #161 from devnexen/solaris_sys_support
solaris/illumos platform minimal support.
2 parents 511555b + e5feacf commit 1457da7

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ AUTO_CTOR_DTOR = -DAUTO_CTOR_DTOR=1
183183
## that call free will segfault
184184
ISO_DTOR_CLEANUP = -DISO_DTOR_CLEANUP=0
185185

186+
LTO = -flto
187+
186188
LIBNAME = libisoalloc.so
187189

188190
UNAME := $(shell uname)
@@ -223,6 +225,16 @@ STRIP = strip -s $(BUILD_DIR)/$(LIBNAME)
223225
HUGE_PAGES =
224226
endif
225227

228+
ifeq ($(UNAME), SunOS)
229+
STRIP = strip -s $(BUILD_DIR)/$(LIBNAME)
230+
# this platform is both 32 and 64 bits
231+
# we have to be explicit
232+
CFLAGS += -m64
233+
CXXFLAGS += -m64
234+
LTO =
235+
HUGE_PAGES =
236+
endif
237+
226238
HOOKS = $(MALLOC_HOOK)
227239
OPTIMIZE = -O2 -fstrict-aliasing -Wstrict-aliasing
228240
COMMON_CFLAGS = -Wall -Iinclude/ $(THREAD_SUPPORT) $(PRE_POPULATE_PAGES) $(STARTUP_MEM_USAGE)
@@ -237,7 +249,7 @@ CFLAGS += $(COMMON_CFLAGS) $(SECURITY_FLAGS) $(BUILD_ERROR_FLAGS) $(HOOKS) $(HEA
237249
$(EXPERIMENTAL) $(UAF_PTR_PAGE) $(VERIFY_FREE_BIT_SLOTS) $(NAMED_MAPPINGS) $(ABORT_ON_NULL) $(NO_ZERO_ALLOCATIONS) \
238250
$(ABORT_NO_ENTROPY) $(ISO_DTOR_CLEANUP) $(RANDOMIZE_FREELIST) $(USE_SPINLOCK) $(HUGE_PAGES) $(USE_MLOCK) \
239251
$(MEMORY_TAGGING) $(STRONG_SIZE_ISOLATION) $(MEMSET_SANITY) $(AUTO_CTOR_DTOR)
240-
CXXFLAGS = $(COMMON_CFLAGS) -DCPP_SUPPORT=1 -std=c++17 $(SANITIZER_SUPPORT) $(HOOKS)
252+
CXXFLAGS += $(COMMON_CFLAGS) -DCPP_SUPPORT=1 -std=c++17 $(SANITIZER_SUPPORT) $(HOOKS)
241253
EXE_CFLAGS = -fPIE
242254
GDB_FLAGS = -g -ggdb3 -fno-omit-frame-pointer
243255
PERF_FLAGS = -pg -DPERF_TEST_BUILD=1
@@ -247,7 +259,7 @@ C_SRCS = $(SRC_DIR)/*.c
247259
CXX_SRCS = $(SRC_DIR)/*.cpp
248260
ISO_ALLOC_PRINTF_SRC = $(SRC_DIR)/iso_alloc_printf.c
249261
BUILD_DIR = build
250-
LDFLAGS = -L$(BUILD_DIR) -lisoalloc -flto
262+
LDFLAGS = -L$(BUILD_DIR) -lisoalloc $(LTO)
251263

252264
all: tests
253265

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Isolation Alloc (or IsoAlloc) is a secure and fast(ish) memory allocator written in C11. It is a drop in replacement for `malloc` on Linux / Mac OS using `LD_PRELOAD` or `DYLD_INSERT_LIBRARIES` respectively. Its security strategy is originally inspired by Chrome's [PartitionAlloc](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/base/allocator/partition_allocator/PartitionAlloc.md). A memory allocation isolation security strategy is best summed up as maintaining spatial separation, or isolation between objects of different sizes or types. While IsoAlloc wraps `malloc` and enforces naive isolation by default very strict isolation of allocations can be achieved using the APIs directly.
88

9-
IsoAlloc is designed and [tested](https://github.com/struct/isoalloc/actions) for 64 bit Linux and MacOS. The space afforded by a 64 bit process makes this possible, therefore Isolation Alloc does not support 32 bit targets. The number of bits of entropy provided to `mmap` based page allocations is far too low in a 32 bit process to provide much security value. It may work on operating systems other than Linux/MacOS but that is also untested at this time. There is partial FreeBSD support but CI is often flakey.
9+
IsoAlloc is designed and [tested](https://github.com/struct/isoalloc/actions) for 64 bit Linux and MacOS. The space afforded by a 64 bit process makes this possible, therefore Isolation Alloc does not support 32 bit targets. The number of bits of entropy provided to `mmap` based page allocations is far too low in a 32 bit process to provide much security value. It may work on operating systems other than Linux/MacOS but that is also untested at this time. There is partial FreeBSD support but CI is often flakey. A minimal Solaris/Illumos support is available, LTO not supported by the compilers backends.
1010

1111
## Design
1212

src/iso_alloc_random.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <sys/random.h>
1818
#elif __NetBSD__
1919
#include <stdlib.h>
20+
#elif __sun
21+
#include <sys/random.h>
2022
#else
2123
#error "unknown OS"
2224
#endif
@@ -55,7 +57,7 @@ INTERNAL_HIDDEN INLINE uint64_t rand_uint64(void) {
5557
ret = syscall(SYS_getrandom, &val, sizeof(val), GRND_NONBLOCK) != sizeof(val);
5658
#elif __APPLE__
5759
ret = SecRandomCopyBytes(kSecRandomDefault, sizeof(val), &val);
58-
#elif __FreeBSD__ || __DragonFly__ || __linux__ || __ANDROID__
60+
#elif __FreeBSD__ || __DragonFly__ || __linux__ || __ANDROID__ || __sun
5961
ret = getrandom(&val, sizeof(val), GRND_NONBLOCK) != sizeof(val);
6062
#elif __NetBSD__
6163
/* Temporary solution until NetBSD 10 released with getrandom support */

0 commit comments

Comments
 (0)