OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/nacl/loader/nonsfi/nonsfi_sandbox.h" | 5 #include "components/nacl/loader/nonsfi/nonsfi_sandbox.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <linux/net.h> | 9 #include <linux/net.h> |
10 #include <sys/prctl.h> | 10 #include <sys/prctl.h> |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 // Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen. | 136 // Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen. |
137 COMPILE_ASSERT(AF_UNIX == PF_UNIX, af_unix_pf_unix_different); | 137 COMPILE_ASSERT(AF_UNIX == PF_UNIX, af_unix_pf_unix_different); |
138 return sb->Cond(0, ErrorCode::TP_32BIT, | 138 return sb->Cond(0, ErrorCode::TP_32BIT, |
139 ErrorCode::OP_EQUAL, AF_UNIX, | 139 ErrorCode::OP_EQUAL, AF_UNIX, |
140 ErrorCode(ErrorCode::ERR_ALLOWED), | 140 ErrorCode(ErrorCode::ERR_ALLOWED), |
141 sb->Trap(sandbox::CrashSIGSYS_Handler, NULL)); | 141 sb->Trap(sandbox::CrashSIGSYS_Handler, NULL)); |
142 } | 142 } |
143 | 143 |
144 bool IsGracefullyDenied(int sysno) { | 144 bool IsGracefullyDenied(int sysno) { |
145 switch (sysno) { | 145 switch (sysno) { |
| 146 // libevent tries this first and then falls back to poll if |
| 147 // epoll_create fails. |
| 148 case __NR_epoll_create: |
146 // third_party/libevent uses them, but we can just return -1 from | 149 // third_party/libevent uses them, but we can just return -1 from |
147 // them as it is just checking getuid() != geteuid() and | 150 // them as it is just checking getuid() != geteuid() and |
148 // getgid() != getegid() | 151 // getgid() != getegid() |
149 #if defined(__i386__) || defined(__arm__) | 152 #if defined(__i386__) || defined(__arm__) |
150 case __NR_getegid32: | 153 case __NR_getegid32: |
151 case __NR_geteuid32: | 154 case __NR_geteuid32: |
152 case __NR_getgid32: | 155 case __NR_getgid32: |
153 case __NR_getuid32: | 156 case __NR_getuid32: |
154 #elif defined(__x86_64__) | 157 #elif defined(__x86_64__) |
155 case __NR_getegid: | 158 case __NR_getegid: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 case __NR__llseek: | 212 case __NR__llseek: |
210 #elif defined(__x86_64__) | 213 #elif defined(__x86_64__) |
211 case __NR_lseek: | 214 case __NR_lseek: |
212 #endif | 215 #endif |
213 // NaCl runtime exposes clock_gettime and clock_getres to untrusted code. | 216 // NaCl runtime exposes clock_gettime and clock_getres to untrusted code. |
214 case __NR_clock_getres: | 217 case __NR_clock_getres: |
215 case __NR_clock_gettime: | 218 case __NR_clock_gettime: |
216 case __NR_close: | 219 case __NR_close: |
217 case __NR_dup: | 220 case __NR_dup: |
218 case __NR_dup2: | 221 case __NR_dup2: |
219 case __NR_epoll_create: | |
220 case __NR_epoll_ctl: | |
221 case __NR_epoll_wait: | |
222 case __NR_exit: | 222 case __NR_exit: |
223 case __NR_exit_group: | 223 case __NR_exit_group: |
224 #if defined(__i386__) || defined(__arm__) | 224 #if defined(__i386__) || defined(__arm__) |
225 case __NR_fstat64: | 225 case __NR_fstat64: |
226 #elif defined(__x86_64__) | 226 #elif defined(__x86_64__) |
227 case __NR_fstat: | 227 case __NR_fstat: |
228 #endif | 228 #endif |
229 // TODO(hamaji): Allow only FUTEX_PRIVATE_FLAG. | 229 // TODO(hamaji): Allow only FUTEX_PRIVATE_FLAG. |
230 case __NR_futex: | 230 case __NR_futex: |
231 // TODO(hamaji): Remove the need of gettid. Currently, this is | 231 // TODO(hamaji): Remove the need of gettid. Currently, this is |
232 // called from PlatformThread::CurrentId(). | 232 // called from PlatformThread::CurrentId(). |
233 case __NR_gettid: | 233 case __NR_gettid: |
234 case __NR_gettimeofday: | 234 case __NR_gettimeofday: |
235 case __NR_munmap: | 235 case __NR_munmap: |
236 case __NR_nanosleep: | 236 case __NR_nanosleep: |
237 // TODO(hamaji): Remove the need of pipe. Currently, this is | 237 // TODO(hamaji): Remove the need of pipe. Currently, this is |
238 // called from base::MessagePumpLibevent::Init(). | 238 // called from base::MessagePumpLibevent::Init(). |
239 case __NR_pipe: | 239 case __NR_pipe: |
| 240 case __NR_poll: |
240 case __NR_pread64: | 241 case __NR_pread64: |
241 case __NR_pwrite64: | 242 case __NR_pwrite64: |
242 case __NR_read: | 243 case __NR_read: |
243 case __NR_restart_syscall: | 244 case __NR_restart_syscall: |
244 case __NR_sched_yield: | 245 case __NR_sched_yield: |
245 // __NR_times needed as clock() is called by CommandBufferHelper, which is | 246 // __NR_times needed as clock() is called by CommandBufferHelper, which is |
246 // used by NaCl applications that use Pepper's 3D interfaces. | 247 // used by NaCl applications that use Pepper's 3D interfaces. |
247 // See crbug.com/264856 for details. | 248 // See crbug.com/264856 for details. |
248 case __NR_times: | 249 case __NR_times: |
249 case __NR_write: | 250 case __NR_write: |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 scoped_ptr<sandbox::SandboxBPFPolicy>( | 311 scoped_ptr<sandbox::SandboxBPFPolicy>( |
311 new nacl::nonsfi::NaClNonSfiBPFSandboxPolicy())); | 312 new nacl::nonsfi::NaClNonSfiBPFSandboxPolicy())); |
312 if (!sandbox_is_initialized) | 313 if (!sandbox_is_initialized) |
313 return false; | 314 return false; |
314 RunSandboxSanityChecks(); | 315 RunSandboxSanityChecks(); |
315 return true; | 316 return true; |
316 } | 317 } |
317 | 318 |
318 } // namespace nonsfi | 319 } // namespace nonsfi |
319 } // namespace nacl | 320 } // namespace nacl |
OLD | NEW |