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

Side by Side Diff: content/common/sandbox_linux/bpf_gpu_policy_linux.cc

Issue 260793003: [MIPS] Add seccomp bpf support (Closed) Base URL: https://git.chromium.org/git/chromium/src.git@master
Patch Set: Update per code review Created 6 years, 6 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/common/sandbox_linux/bpf_gpu_policy_linux.h" 5 #include "content/common/sandbox_linux/bpf_gpu_policy_linux.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
11 #include <sys/stat.h> 11 #include <sys/stat.h>
12 #include <sys/types.h> 12 #include <sys/types.h>
13 #include <unistd.h> 13 #include <unistd.h>
14 14
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 #include "base/bind.h" 18 #include "base/bind.h"
19 #include "base/command_line.h" 19 #include "base/command_line.h"
20 #include "base/compiler_specific.h" 20 #include "base/compiler_specific.h"
21 #include "base/logging.h" 21 #include "base/logging.h"
22 #include "base/memory/scoped_ptr.h" 22 #include "base/memory/scoped_ptr.h"
23 #include "build/build_config.h" 23 #include "build/build_config.h"
24 #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h" 24 #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h"
25 #include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h" 25 #include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h"
26 #include "content/common/set_process_title.h" 26 #include "content/common/set_process_title.h"
27 #include "content/public/common/content_switches.h" 27 #include "content/public/common/content_switches.h"
28 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h" 28 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h"
29 #include "sandbox/linux/seccomp-bpf/kernel_return_value_helpers.h"
29 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" 30 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
30 #include "sandbox/linux/services/broker_process.h" 31 #include "sandbox/linux/services/broker_process.h"
31 #include "sandbox/linux/services/linux_syscalls.h" 32 #include "sandbox/linux/services/linux_syscalls.h"
32 33
33 using sandbox::BrokerProcess; 34 using sandbox::BrokerProcess;
34 using sandbox::ErrorCode; 35 using sandbox::ErrorCode;
35 using sandbox::SandboxBPF; 36 using sandbox::SandboxBPF;
36 using sandbox::SyscallSets; 37 using sandbox::SyscallSets;
37 using sandbox::arch_seccomp_data; 38 using sandbox::arch_seccomp_data;
38 39
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 #endif 94 #endif
94 return broker_process->Open(reinterpret_cast<const char*>(args.args[0]), 95 return broker_process->Open(reinterpret_cast<const char*>(args.args[0]),
95 static_cast<int>(args.args[1])); 96 static_cast<int>(args.args[1]));
96 case __NR_openat: 97 case __NR_openat:
97 // Allow using openat() as open(). 98 // Allow using openat() as open().
98 if (static_cast<int>(args.args[0]) == AT_FDCWD) { 99 if (static_cast<int>(args.args[0]) == AT_FDCWD) {
99 return 100 return
100 broker_process->Open(reinterpret_cast<const char*>(args.args[1]), 101 broker_process->Open(reinterpret_cast<const char*>(args.args[1]),
101 static_cast<int>(args.args[2])); 102 static_cast<int>(args.args[2]));
102 } else { 103 } else {
103 return -EPERM; 104 return sandbox::ErrnoToKernelRet(EPERM);
jln (very slow on Chromium) 2014/06/13 02:47:36 Let's just declare that trap handlers have the sam
nedeljko 2014/06/18 13:41:00 Done.
104 } 105 }
105 default: 106 default:
106 RAW_CHECK(false); 107 RAW_CHECK(false);
107 return -ENOSYS; 108 return sandbox::ErrnoToKernelRet(ENOSYS);
108 } 109 }
109 } 110 }
110 111
111 class GpuBrokerProcessPolicy : public GpuProcessPolicy { 112 class GpuBrokerProcessPolicy : public GpuProcessPolicy {
112 public: 113 public:
113 static sandbox::SandboxBPFPolicy* Create() { 114 static sandbox::SandboxBPFPolicy* Create() {
114 return new GpuBrokerProcessPolicy(); 115 return new GpuBrokerProcessPolicy();
115 } 116 }
116 virtual ~GpuBrokerProcessPolicy() {} 117 virtual ~GpuBrokerProcessPolicy() {}
117 118
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 165
165 GpuProcessPolicy::GpuProcessPolicy() : broker_process_(NULL) {} 166 GpuProcessPolicy::GpuProcessPolicy() : broker_process_(NULL) {}
166 167
167 GpuProcessPolicy::~GpuProcessPolicy() {} 168 GpuProcessPolicy::~GpuProcessPolicy() {}
168 169
169 // Main policy for x86_64/i386. Extended by CrosArmGpuProcessPolicy. 170 // Main policy for x86_64/i386. Extended by CrosArmGpuProcessPolicy.
170 ErrorCode GpuProcessPolicy::EvaluateSyscall(SandboxBPF* sandbox, 171 ErrorCode GpuProcessPolicy::EvaluateSyscall(SandboxBPF* sandbox,
171 int sysno) const { 172 int sysno) const {
172 switch (sysno) { 173 switch (sysno) {
173 case __NR_ioctl: 174 case __NR_ioctl:
174 #if defined(__i386__) || defined(__x86_64__) 175 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
175 // The Nvidia driver uses flags not in the baseline policy 176 // The Nvidia driver uses flags not in the baseline policy
176 // (MAP_LOCKED | MAP_EXECUTABLE | MAP_32BIT) 177 // (MAP_LOCKED | MAP_EXECUTABLE | MAP_32BIT)
177 case __NR_mmap: 178 case __NR_mmap:
178 #endif 179 #endif
179 // We also hit this on the linux_chromeos bot but don't yet know what 180 // We also hit this on the linux_chromeos bot but don't yet know what
180 // weird flags were involved. 181 // weird flags were involved.
181 case __NR_mprotect: 182 case __NR_mprotect:
182 case __NR_sched_getaffinity: 183 case __NR_sched_getaffinity:
183 case __NR_sched_setaffinity: 184 case __NR_sched_setaffinity:
184 case __NR_setpriority: 185 case __NR_setpriority:
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 broker_process_ = new BrokerProcess(GetFSDeniedErrno(), 261 broker_process_ = new BrokerProcess(GetFSDeniedErrno(),
261 read_whitelist, 262 read_whitelist,
262 write_whitelist); 263 write_whitelist);
263 // The initialization callback will perform generic initialization and then 264 // The initialization callback will perform generic initialization and then
264 // call broker_sandboxer_callback. 265 // call broker_sandboxer_callback.
265 CHECK(broker_process_->Init(base::Bind(&UpdateProcessTypeAndEnableSandbox, 266 CHECK(broker_process_->Init(base::Bind(&UpdateProcessTypeAndEnableSandbox,
266 broker_sandboxer_allocator))); 267 broker_sandboxer_allocator)));
267 } 268 }
268 269
269 } // namespace content 270 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698