OLD | NEW |
---|---|
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> |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 case __NR_open: | 89 case __NR_open: |
90 return broker_process->Open(reinterpret_cast<const char*>(args.args[0]), | 90 return broker_process->Open(reinterpret_cast<const char*>(args.args[0]), |
91 static_cast<int>(args.args[1])); | 91 static_cast<int>(args.args[1])); |
92 case __NR_openat: | 92 case __NR_openat: |
93 // Allow using openat() as open(). | 93 // Allow using openat() as open(). |
94 if (static_cast<int>(args.args[0]) == AT_FDCWD) { | 94 if (static_cast<int>(args.args[0]) == AT_FDCWD) { |
95 return | 95 return |
96 broker_process->Open(reinterpret_cast<const char*>(args.args[1]), | 96 broker_process->Open(reinterpret_cast<const char*>(args.args[1]), |
97 static_cast<int>(args.args[2])); | 97 static_cast<int>(args.args[2])); |
98 } else { | 98 } else { |
99 #if defined(__mips__) | |
100 // On MIPS, kernel returns errno (instead of -errno) | |
101 return EPERM; | |
jln (very slow on Chromium)
2014/05/02 20:42:04
Ohh, this is very unfortunate :(
Let's add a help
nedeljko
2014/05/07 15:40:05
Helper added.
I created RetValToKernel instead of
| |
102 #else | |
99 return -EPERM; | 103 return -EPERM; |
104 #endif | |
100 } | 105 } |
101 default: | 106 default: |
102 RAW_CHECK(false); | 107 RAW_CHECK(false); |
108 #if defined(__mips__) | |
109 // On MIPS, kernel returns errno (instead of -errno) | |
110 return ENOSYS; | |
111 #else | |
103 return -ENOSYS; | 112 return -ENOSYS; |
113 #endif | |
104 } | 114 } |
105 } | 115 } |
106 | 116 |
107 class GpuBrokerProcessPolicy : public GpuProcessPolicy { | 117 class GpuBrokerProcessPolicy : public GpuProcessPolicy { |
108 public: | 118 public: |
109 static sandbox::SandboxBPFPolicy* Create() { | 119 static sandbox::SandboxBPFPolicy* Create() { |
110 return new GpuBrokerProcessPolicy(); | 120 return new GpuBrokerProcessPolicy(); |
111 } | 121 } |
112 virtual ~GpuBrokerProcessPolicy() {} | 122 virtual ~GpuBrokerProcessPolicy() {} |
113 | 123 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 | 170 |
161 GpuProcessPolicy::GpuProcessPolicy() : broker_process_(NULL) {} | 171 GpuProcessPolicy::GpuProcessPolicy() : broker_process_(NULL) {} |
162 | 172 |
163 GpuProcessPolicy::~GpuProcessPolicy() {} | 173 GpuProcessPolicy::~GpuProcessPolicy() {} |
164 | 174 |
165 // Main policy for x86_64/i386. Extended by CrosArmGpuProcessPolicy. | 175 // Main policy for x86_64/i386. Extended by CrosArmGpuProcessPolicy. |
166 ErrorCode GpuProcessPolicy::EvaluateSyscall(SandboxBPF* sandbox, | 176 ErrorCode GpuProcessPolicy::EvaluateSyscall(SandboxBPF* sandbox, |
167 int sysno) const { | 177 int sysno) const { |
168 switch (sysno) { | 178 switch (sysno) { |
169 case __NR_ioctl: | 179 case __NR_ioctl: |
170 #if defined(__i386__) || defined(__x86_64__) | 180 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) |
171 // The Nvidia driver uses flags not in the baseline policy | 181 // The Nvidia driver uses flags not in the baseline policy |
172 // (MAP_LOCKED | MAP_EXECUTABLE | MAP_32BIT) | 182 // (MAP_LOCKED | MAP_EXECUTABLE | MAP_32BIT) |
173 case __NR_mmap: | 183 case __NR_mmap: |
174 #endif | 184 #endif |
175 // We also hit this on the linux_chromeos bot but don't yet know what | 185 // We also hit this on the linux_chromeos bot but don't yet know what |
176 // weird flags were involved. | 186 // weird flags were involved. |
177 case __NR_mprotect: | 187 case __NR_mprotect: |
178 case __NR_sched_getaffinity: | 188 case __NR_sched_getaffinity: |
179 case __NR_sched_setaffinity: | 189 case __NR_sched_setaffinity: |
180 case __NR_setpriority: | 190 case __NR_setpriority: |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 broker_process_ = new BrokerProcess(GetFSDeniedErrno(), | 270 broker_process_ = new BrokerProcess(GetFSDeniedErrno(), |
261 read_whitelist, | 271 read_whitelist, |
262 write_whitelist); | 272 write_whitelist); |
263 // The initialization callback will perform generic initialization and then | 273 // The initialization callback will perform generic initialization and then |
264 // call broker_sandboxer_callback. | 274 // call broker_sandboxer_callback. |
265 CHECK(broker_process_->Init(base::Bind(&UpdateProcessTypeAndEnableSandbox, | 275 CHECK(broker_process_->Init(base::Bind(&UpdateProcessTypeAndEnableSandbox, |
266 broker_sandboxer_allocator))); | 276 broker_sandboxer_allocator))); |
267 } | 277 } |
268 | 278 |
269 } // namespace content | 279 } // namespace content |
OLD | NEW |