Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: content/renderer/renderer_main_platform_delegate_android.cc

Issue 180783019: [Android] Define a baseline seccomp-bpf sandbox policy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fun With Flags! Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/renderer_main_platform_delegate.h" 5 #include "content/renderer/renderer_main_platform_delegate.h"
6
7 #include "base/command_line.h"
6 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/rand_util.h"
10 #include "base/sys_info.h"
11 #include "content/common/sandbox_linux/android/sandbox_bpf_base_policy_android.h "
12 #include "content/public/common/content_switches.h"
13 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
14 #include "third_party/skia/include/ports/SkFontConfigInterface.h"
15 #include "v8/include/v8.h"
7 16
8 #ifdef ENABLE_VTUNE_JIT_INTERFACE 17 #ifdef ENABLE_VTUNE_JIT_INTERFACE
9 #include "content/public/common/content_switches.h"
10 #include "v8/src/third_party/vtune/v8-vtune.h" 18 #include "v8/src/third_party/vtune/v8-vtune.h"
11 #endif 19 #endif
12 20
13 namespace content { 21 namespace content {
14 22
23 namespace {
24
25 bool GenerateEntropy(unsigned char* buffer, size_t length) {
26 base::RandBytes(buffer, length);
27 return true;
28 }
29
30 void PreSandboxWarmUp() {
31 base::RandUint64();
32
33 base::SysInfo::AmountOfPhysicalMemory();
jochen (gone - plz use gerrit) 2014/04/10 07:37:42 add base::SysInfo::AmountOfVirtualMemory()
Robert Sesek 2014/04/10 14:36:24 See below.
34 base::SysInfo::MaxSharedMemorySize();
35 base::SysInfo::NumberOfProcessors();
36
37 v8::V8::SetEntropySource(&GenerateEntropy);
38 v8::V8::Initialize();
jochen (gone - plz use gerrit) 2014/04/10 07:37:42 can you explain why you add this here? This confli
Robert Sesek 2014/04/10 14:36:24 Thanks for calling this out. All of this was lefto
39
40 SkFontConfigInterface::GetSingletonDirectInterface();
41 }
42
43 } // namespace
44
15 RendererMainPlatformDelegate::RendererMainPlatformDelegate( 45 RendererMainPlatformDelegate::RendererMainPlatformDelegate(
16 const MainFunctionParams& parameters) 46 const MainFunctionParams& parameters)
17 : parameters_(parameters) { 47 : parameters_(parameters) {
18 } 48 }
19 49
20 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() { 50 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() {
21 } 51 }
22 52
23 void RendererMainPlatformDelegate::PlatformInitialize() { 53 void RendererMainPlatformDelegate::PlatformInitialize() {
24 #ifdef ENABLE_VTUNE_JIT_INTERFACE 54 #ifdef ENABLE_VTUNE_JIT_INTERFACE
25 const CommandLine& command_line = parameters_.command_line; 55 const CommandLine& command_line = parameters_.command_line;
26 if (command_line.HasSwitch(switches::kEnableVtune)) 56 if (command_line.HasSwitch(switches::kEnableVtune))
27 vTune::InitializeVtuneForV8(); 57 vTune::InitializeVtuneForV8();
28 #endif 58 #endif
29 } 59 }
30 60
31 void RendererMainPlatformDelegate::PlatformUninitialize() { 61 void RendererMainPlatformDelegate::PlatformUninitialize() {
32 } 62 }
33 63
34 bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { 64 bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) {
35 return true; 65 return true;
36 } 66 }
37 67
38 bool RendererMainPlatformDelegate::EnableSandbox() { 68 bool RendererMainPlatformDelegate::EnableSandbox() {
69 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
70 switches::kEnableSeccompFilterSandbox)) {
71 return true;
72 }
73
74 PreSandboxWarmUp();
75
76 sandbox::SandboxBPF sandbox;
77 sandbox.SetSandboxPolicy(new SandboxBPFBasePolicyAndroid());
78 CHECK(sandbox.StartSandbox(sandbox::SandboxBPF::PROCESS_MULTI_THREADED));
39 return true; 79 return true;
40 } 80 }
41 81
42 void RendererMainPlatformDelegate::RunSandboxTests(bool no_sandbox) { 82 void RendererMainPlatformDelegate::RunSandboxTests(bool no_sandbox) {
43 } 83 }
44 84
45 } // namespace content 85 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698