diff --git a/headers/posix/signal.h b/headers/posix/signal.h index 7415cfe99c..d56cf2edfa 100644 --- a/headers/posix/signal.h +++ b/headers/posix/signal.h @@ -95,7 +95,7 @@ struct sigaction { #define SS_ONSTACK 0x1 #define SS_DISABLE 0x2 -#define MINSIGSTKSZ 4096 +#define MINSIGSTKSZ 8192 #define SIGSTKSZ 16384 /* for signals using an alternate stack */ diff --git a/src/system/kernel/arch/x86/32/thread.cpp b/src/system/kernel/arch/x86/32/thread.cpp index 66465c2951..7bed6a0f4d 100644 --- a/src/system/kernel/arch/x86/32/thread.cpp +++ b/src/system/kernel/arch/x86/32/thread.cpp @@ -110,6 +110,15 @@ x86_set_tls_context(Thread *thread) } +static addr_t +arch_randomize_stack_pointer(addr_t value) +{ + STATIC_ASSERT(MAX_RANDOM_VALUE >= B_PAGE_SIZE - 1); + value -= random_value() & (B_PAGE_SIZE - 1); + return value & ~addr_t(0xf); +} + + static uint8* get_signal_stack(Thread* thread, struct iframe* frame, struct sigaction* action) { @@ -119,7 +128,8 @@ get_signal_stack(Thread* thread, struct iframe* frame, struct sigaction* action) && (frame->user_sp < thread->signal_stack_base || frame->user_sp >= thread->signal_stack_base + thread->signal_stack_size)) { - return (uint8*)(thread->signal_stack_base + thread->signal_stack_size); + addr_t stackTop = thread->signal_stack_base + thread->signal_stack_size; + return (uint8*)arch_randomize_stack_pointer(stackTop); } return (uint8*)frame->user_sp; @@ -202,15 +212,6 @@ arch_thread_dump_info(void *info) } -static addr_t -arch_randomize_stack_pointer(addr_t value) -{ - STATIC_ASSERT(MAX_RANDOM_VALUE >= B_PAGE_SIZE - 1); - value -= random_value() & (B_PAGE_SIZE - 1); - return value & ~addr_t(0xf); -} - - /*! Sets up initial thread context and enters user space */ status_t diff --git a/src/system/kernel/arch/x86/64/thread.cpp b/src/system/kernel/arch/x86/64/thread.cpp index e1a337fe3c..59db5028e4 100644 --- a/src/system/kernel/arch/x86/64/thread.cpp +++ b/src/system/kernel/arch/x86/64/thread.cpp @@ -95,6 +95,15 @@ x86_set_tls_context(Thread* thread) } +static addr_t +arch_randomize_stack_pointer(addr_t value) +{ + STATIC_ASSERT(MAX_RANDOM_VALUE >= B_PAGE_SIZE - 1); + value -= random_value() & (B_PAGE_SIZE - 1); + return value & ~addr_t(0xf); +} + + static uint8* get_signal_stack(Thread* thread, iframe* frame, struct sigaction* action) { @@ -104,7 +113,8 @@ get_signal_stack(Thread* thread, iframe* frame, struct sigaction* action) && (frame->user_sp < thread->signal_stack_base || frame->user_sp >= thread->signal_stack_base + thread->signal_stack_size)) { - return (uint8*)(thread->signal_stack_base + thread->signal_stack_size); + addr_t stackTop = thread->signal_stack_base + thread->signal_stack_size; + return (uint8*)arch_randomize_stack_pointer(stackTop); } // We are going to use the stack that we are already on. We must not touch @@ -198,15 +208,6 @@ arch_thread_dump_info(void* info) } -static addr_t -arch_randomize_stack_pointer(addr_t value) -{ - STATIC_ASSERT(MAX_RANDOM_VALUE >= B_PAGE_SIZE - 1); - value -= random_value() & (B_PAGE_SIZE - 1); - return value & ~addr_t(0xf); -} - - /*! Sets up initial thread context and enters user space */ status_t