commit 2edb3478a22331e0fc882e25874b9403ee2575ee Author: Georg Koppen gk@torproject.org Date: Wed Jul 4 16:51:23 2018 +0000
Revert "Bug 20283: Tor Browser should run without a `/proc` filesystem."
This reverts commit 5bd6e492edc3fc4df748d1228360c80fee38e276. --- js/src/util/NativeStack.cpp | 60 +++------------------------------------------ 1 file changed, 4 insertions(+), 56 deletions(-)
diff --git a/js/src/util/NativeStack.cpp b/js/src/util/NativeStack.cpp index a695cb3bcd6c..2507374a36da 100644 --- a/js/src/util/NativeStack.cpp +++ b/js/src/util/NativeStack.cpp @@ -13,24 +13,10 @@ # if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) # include <pthread_np.h> # endif -# if defined(SOLARIS) || defined(AIX) -# include <ucontext.h> -# endif # if defined(ANDROID) && !defined(__aarch64__) # include <sys/types.h> # include <unistd.h> # endif -# if defined(XP_LINUX) && !defined(ANDROID) && defined(__GLIBC__) -# include <dlfcn.h> -# include <sys/syscall.h> -# include <sys/types.h> -# include <unistd.h> -static pid_t -gettid() -{ - return syscall(__NR_gettid); -} -# endif #else # error "Unsupported platform" #endif @@ -48,6 +34,8 @@ js::GetNativeStackBaseImpl()
#elif defined(SOLARIS)
+#include <ucontext.h> + JS_STATIC_ASSERT(JS_STACK_GROWTH_DIRECTION < 0);
void* @@ -60,6 +48,8 @@ js::GetNativeStackBaseImpl()
#elif defined(AIX)
+#include <ucontext.h> + JS_STATIC_ASSERT(JS_STACK_GROWTH_DIRECTION < 0);
void* @@ -71,48 +61,6 @@ js::GetNativeStackBaseImpl() context.uc_stack.ss_size; }
-#elif defined(XP_LINUX) && !defined(ANDROID) && defined(__GLIBC__) -void* -js::GetNativeStackBaseImpl() -{ - // On the main thread, get stack base from glibc's __libc_stack_end rather than pthread APIs - // to avoid filesystem calls /proc/self/maps. Non-main threads spawned with pthreads can read - // this information directly from their pthread struct, but the main thread must go parse - // /proc/self/maps to figure the mapped stack address space ranges. We want to avoid reading - // from /proc/ so that firefox can run in sandboxed environments where /proc may not be mounted - if (gettid() == getpid()) { - void** pLibcStackEnd = (void**)dlsym(RTLD_DEFAULT, "__libc_stack_end"); - // If __libc_stack_end is not found, architecture specific frame pointer hopping will need - // to be implemented. - MOZ_RELEASE_ASSERT(pLibcStackEnd, "__libc_stack_end unavailable, unable to setup stack range for JS"); - void* stackBase = *pLibcStackEnd; - MOZ_RELEASE_ASSERT(stackBase, "invalid stack base, unable to setup stack range for JS"); - // We don't need to fix stackBase, as it already roughly points to beginning of the stack - return stackBase; - } else { - // Non-main threads have the required info stored in memory, so no filesystem calls are made. - pthread_t thread = pthread_self(); - pthread_attr_t sattr; - pthread_attr_init(&sattr); - pthread_getattr_np(thread, &sattr); - // stackBase will be the *lowest* address on all architectures. - void* stackBase = nullptr; - size_t stackSize = 0; - int rc = pthread_attr_getstack(&sattr, &stackBase, &stackSize); - if (rc) { - MOZ_CRASH("call to pthread_attr_getstack failed, unable to setup stack range for JS"); - } - MOZ_RELEASE_ASSERT(stackBase, "invalid stack base, unable to setup stack range for JS"); - pthread_attr_destroy(&sattr); - -# if JS_STACK_GROWTH_DIRECTION > 0 - return stackBase; -# else - return static_cast<char*>(stackBase) + stackSize; -# endif - } -} - #else /* XP_UNIX */
void*
tor-commits@lists.torproject.org