From 0b5da0bc80e4cfc1167d100f224ba577554909b0 Mon Sep 17 00:00:00 2001 From: caodongxia <315816521@qq.com> Date: Wed, 11 Aug 2021 09:31:37 +0800 Subject: [PATCH] fix --- js/xpconnect/src/XPCJSContext.cpp | 10 +--------- security/sandbox/linux/launch/SandboxLaunch.cpp | 11 ++++++++--- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/js/xpconnect/src/XPCJSContext.cpp b/js/xpconnect/src/XPCJSContext.cpp index 54461fb88c..9a998ac88d 100644 --- a/js/xpconnect/src/XPCJSContext.cpp +++ b/js/xpconnect/src/XPCJSContext.cpp @@ -81,14 +81,6 @@ using namespace xpc; using namespace JS; using mozilla::dom::AutoEntryScript; -// The watchdog thread loop is pretty trivial, and should not require much stack -// space to do its job. So only give it 32KiB or the platform minimum. -#if !defined(PTHREAD_STACK_MIN) -# define PTHREAD_STACK_MIN 0 -#endif -static constexpr size_t kWatchdogStackSize = - PTHREAD_STACK_MIN < 32 * 1024 ? 32 * 1024 : PTHREAD_STACK_MIN; - static void WatchdogMain(void* arg); class Watchdog; class WatchdogManager; @@ -161,7 +153,7 @@ class Watchdog { // watchdog, we need to join it on shutdown. mThread = PR_CreateThread(PR_USER_THREAD, WatchdogMain, this, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, - PR_JOINABLE_THREAD, kWatchdogStackSize); + PR_JOINABLE_THREAD, 0); if (!mThread) { MOZ_CRASH("PR_CreateThread failed!"); } diff --git a/security/sandbox/linux/launch/SandboxLaunch.cpp b/security/sandbox/linux/launch/SandboxLaunch.cpp index 33d33a00c9..b70fa693d4 100644 --- a/security/sandbox/linux/launch/SandboxLaunch.cpp +++ b/security/sandbox/linux/launch/SandboxLaunch.cpp @@ -489,7 +489,7 @@ static int CloneCallee(void* aPtr) { // we don't currently support sandboxing under valgrind. MOZ_NEVER_INLINE MOZ_ASAN_BLACKLIST static pid_t DoClone(int aFlags, jmp_buf* aCtx) { - uint8_t miniStack[PTHREAD_STACK_MIN]; + uint8_t miniStack[4096]; #ifdef __hppa__ void* stackPtr = miniStack; #else @@ -509,14 +509,19 @@ static pid_t ForkWithFlags(int aFlags) { CLONE_PARENT_SETTID | CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID; MOZ_RELEASE_ASSERT((aFlags & kBadFlags) == 0); + // Block signals due to small stack in DoClone + sigset_t oldSigs; + BlockAllSignals(&oldSigs); + int ret = 0; jmp_buf ctx; if (setjmp(ctx) == 0) { // In the parent and just called setjmp: - return DoClone(aFlags | SIGCHLD, &ctx); + ret = DoClone(aFlags | SIGCHLD, &ctx); } + RestoreSignals(&oldSigs); // In the child and have longjmp'ed: - return 0; + return ret; } static bool WriteStringToFile(const char* aPath, const char* aStr, -- 2.27.0