Bug 1009995 - Require seccomp-bpf on B2G devices based on Android >= KitKat. r=mwu r=kang

This commit is contained in:
Jed Davis 2014-08-15 11:56:28 -07:00
parent 88f1f148ae
commit d419b12871
2 changed files with 28 additions and 4 deletions

View File

@ -918,13 +918,21 @@ ContentChild::AllocPBackgroundChild(Transport* aTransport,
bool
ContentChild::RecvSetProcessSandbox()
{
// We may want to move the sandbox initialization somewhere else
// at some point; see bug 880808.
// We may want to move the sandbox initialization somewhere else
// at some point; see bug 880808.
#if defined(MOZ_CONTENT_SANDBOX)
#if defined(XP_LINUX)
if (CanSandboxContentProcess()) {
SetContentProcessSandbox();
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 19
// For B2G >= KitKat, sandboxing is mandatory; this has already
// been enforced by ContentParent::StartUp().
MOZ_ASSERT(CanSandboxContentProcess());
#else
// Otherwise, sandboxing is best-effort.
if (!CanSandboxContentProcess()) {
return true;
}
#endif
SetContentProcessSandbox();
#elif defined(XP_WIN)
mozilla::SandboxTarget::Instance()->StartSandbox();
#endif

View File

@ -177,6 +177,10 @@ using namespace mozilla::system;
#include "nsIIPCBackgroundChildCreateCallback.h"
#endif
#if defined(MOZ_CONTENT_SANDBOX) && defined(XP_LINUX)
#include "mozilla/Sandbox.h"
#endif
static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
static const char* sClipboardTextFlavors[] = { kUnicodeMime };
@ -647,6 +651,18 @@ ContentParent::StartUp()
return;
}
#if defined(MOZ_CONTENT_SANDBOX) && defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 19
// Require sandboxing on B2G >= KitKat. This condition must stay
// in sync with ContentChild::RecvSetProcessSandbox.
if (!CanSandboxContentProcess()) {
// MOZ_CRASH strings are only for debug builds; make sure the
// message is clear on non-debug builds as well:
printf_stderr("Sandboxing support is required on this platform. "
"Recompile kernel with CONFIG_SECCOMP_FILTER=y\n");
MOZ_CRASH("Sandboxing support is required on this platform.");
}
#endif
// Note: This reporter measures all ContentParents.
RegisterStrongMemoryReporter(new ContentParentsMemoryReporter());