Skip to content

Commit e5feacf

Browse files
committed
solaris/illumos platform minimal support.
disabling LTO for this one.
1 parent 59ac285 commit e5feacf

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
@@ -182,6 +182,8 @@ AUTO_CTOR_DTOR = -DAUTO_CTOR_DTOR=1
182182
## that call free will segfault
183183
ISO_DTOR_CLEANUP = -DISO_DTOR_CLEANUP=0
184184

185+
LTO = -flto
186+
185187
LIBNAME = libisoalloc.so
186188

187189
UNAME := $(shell uname)
@@ -222,6 +224,16 @@ STRIP = strip -s $(BUILD_DIR)/$(LIBNAME)
222224
HUGE_PAGES =
223225
endif
224226

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

251263
all: tests
252264

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)