[PATCH] D57924: [safestack] Move sysconf(_SC_PAGESIZE) back where it was before r351506
Vitaly Buka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 7 13:24:41 PST 2019
vitalybuka created this revision.
vitalybuka added a reviewer: eugenis.
Herald added projects: Sanitizers, LLVM.
Herald added a subscriber: Sanitizers.
3rd party sysconf interceptor may crash if it's called before unsafe_stack_setup
pageSize is used only for mmmap, which is going to round up it to page size anyway,
and for guard check in interceptor, which happens after sysconf().
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D57924
Files:
compiler-rt/lib/safestack/safestack.cc
Index: compiler-rt/lib/safestack/safestack.cc
===================================================================
--- compiler-rt/lib/safestack/safestack.cc
+++ compiler-rt/lib/safestack/safestack.cc
@@ -83,7 +83,7 @@
const unsigned kDefaultUnsafeStackSize = 0x2800000;
/// Runtime page size obtained through sysconf
-unsigned pageSize;
+unsigned pageSize = 4096;
// Per-thread unsafe stack information. It's not frequently accessed, so there
// it can be kept out of the tcb in normal thread-local variables.
@@ -264,11 +264,9 @@
__attribute__((constructor(0)))
#endif
void __safestack_init() {
- pageSize = sysconf(_SC_PAGESIZE);
-
// Determine the stack size for the main thread.
size_t size = kDefaultUnsafeStackSize;
- size_t guard = 4096;
+ size_t guard = pageSize;
struct rlimit limit;
if (getrlimit(RLIMIT_STACK, &limit) == 0 && limit.rlim_cur != RLIM_INFINITY)
@@ -276,8 +274,8 @@
// Allocate unsafe stack for main thread
void *addr = unsafe_stack_alloc(size, guard);
-
unsafe_stack_setup(addr, size, guard);
+ pageSize = sysconf(_SC_PAGESIZE);
// Setup the cleanup handler
pthread_key_create(&thread_cleanup_key, thread_cleanup_handler);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57924.185857.patch
Type: text/x-patch
Size: 1196 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190207/bbd40744/attachment.bin>
More information about the llvm-commits
mailing list