Bug 1436882 - Fix termination signal when clone()ing child processes. r?gcp
This fixes a mistake in
bug 1401062: the termination signal was omitted,
so it's 0, and if it isn't exactly SIGCHLD, then a tracer/debugger will
receive PTRACE_EVENT_CLONE rather than PTRACE_EVENT_FORK. This causes
GDB to see the child process as a thread instead of a separate process,
and it becomes very confused after the process calls execve().
MozReview-Commit-ID: Baf2RFHVWRU
--- a/security/sandbox/linux/launch/SandboxLaunch.cpp
+++ b/security/sandbox/linux/launch/SandboxLaunch.cpp
@@ -385,17 +385,17 @@ ForkWithFlags(int aFlags)
// require clone() arguments we're not passing:
static const int kBadFlags = CLONE_VM | CLONE_VFORK | CLONE_SETTLS
| CLONE_PARENT_SETTID | CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID;
MOZ_RELEASE_ASSERT((aFlags & kBadFlags) == 0);
jmp_buf ctx;
if (setjmp(ctx) == 0) {
// In the parent and just called setjmp:
- return DoClone(aFlags, &ctx);
+ return DoClone(aFlags | SIGCHLD, &ctx);
}
// In the child and have longjmp'ed:
return 0;
}
static bool
WriteStringToFile(const char* aPath, const char* aStr, const size_t aLen)
{