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

Side by Side Diff: content/common/sandbox_seccomp_bpf_linux.cc

Issue 11096012: Add a platform-specific syscall number iterator. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed one comment. Created 8 years, 2 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 <asm/unistd.h> 5 #include <asm/unistd.h>
6 #include <dlfcn.h> 6 #include <dlfcn.h>
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <linux/audit.h> 9 #include <linux/audit.h>
10 #include <linux/filter.h> 10 #include <linux/filter.h>
(...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 if (IsSystemVSharedMemory(sysno)) 1288 if (IsSystemVSharedMemory(sysno))
1289 return ErrorCode(ErrorCode::ERR_ALLOWED); 1289 return ErrorCode(ErrorCode::ERR_ALLOWED);
1290 #endif 1290 #endif
1291 1291
1292 // Default on the baseline policy. 1292 // Default on the baseline policy.
1293 return BaselinePolicy_x86_64(sysno); 1293 return BaselinePolicy_x86_64(sysno);
1294 } 1294 }
1295 } 1295 }
1296 1296
1297 ErrorCode BlacklistDebugAndNumaPolicy(int sysno) { 1297 ErrorCode BlacklistDebugAndNumaPolicy(int sysno) {
1298 if (sysno < static_cast<int>(MIN_SYSCALL) || 1298 if (!Sandbox::isValidSyscallNumber(sysno)) {
1299 sysno > static_cast<int>(MAX_SYSCALL)) {
1300 // TODO(jln) we should not have to do that in a trivial policy. 1299 // TODO(jln) we should not have to do that in a trivial policy.
1301 return ErrorCode(ENOSYS); 1300 return ErrorCode(ENOSYS);
1302 } 1301 }
1303 1302
1304 if (IsDebug(sysno) || IsNuma(sysno)) 1303 if (IsDebug(sysno) || IsNuma(sysno))
1305 return Sandbox::Trap(CrashSIGSYS_Handler, NULL); 1304 return Sandbox::Trap(CrashSIGSYS_Handler, NULL);
1306 1305
1307 return ErrorCode(ErrorCode::ERR_ALLOWED); 1306 return ErrorCode(ErrorCode::ERR_ALLOWED);
1308 } 1307 }
1309 1308
1310 // Allow all syscalls. 1309 // Allow all syscalls.
1311 // This will still deny x32 or IA32 calls in 64 bits mode or 1310 // This will still deny x32 or IA32 calls in 64 bits mode or
1312 // 64 bits system calls in compatibility mode. 1311 // 64 bits system calls in compatibility mode.
1313 ErrorCode AllowAllPolicy(int sysno) { 1312 ErrorCode AllowAllPolicy(int sysno) {
1314 if (sysno < static_cast<int>(MIN_SYSCALL) || 1313 if (!Sandbox::isValidSyscallNumber(sysno)) {
1315 sysno > static_cast<int>(MAX_SYSCALL)) {
1316 // TODO(jln) we should not have to do that in a trivial policy. 1314 // TODO(jln) we should not have to do that in a trivial policy.
1317 return ErrorCode(ENOSYS); 1315 return ErrorCode(ENOSYS);
1318 } else { 1316 } else {
1319 return ErrorCode(ErrorCode::ERR_ALLOWED); 1317 return ErrorCode(ErrorCode::ERR_ALLOWED);
1320 } 1318 }
1321 } 1319 }
1322 1320
1323 // Warms up/preloads resources needed by the policies. 1321 // Warms up/preloads resources needed by the policies.
1324 void WarmupPolicy(Sandbox::EvaluateSyscall policy) { 1322 void WarmupPolicy(Sandbox::EvaluateSyscall policy) {
1325 #if defined(__x86_64__) 1323 #if defined(__x86_64__)
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 #if defined(__arm__) 1411 #if defined(__arm__)
1414 // We disable the sandbox on ARM for now until crbug.com/148856 is fixed. 1412 // We disable the sandbox on ARM for now until crbug.com/148856 is fixed.
1415 return false; 1413 return false;
1416 #else 1414 #else
1417 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 1415 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
1418 if (process_type == switches::kGpuProcess) 1416 if (process_type == switches::kGpuProcess)
1419 return !command_line.HasSwitch(switches::kDisableGpuSandbox); 1417 return !command_line.HasSwitch(switches::kDisableGpuSandbox);
1420 1418
1421 return true; 1419 return true;
1422 #endif // __arm__ 1420 #endif // __arm__
1423 #endif // process_type 1421 #endif // SECCOMP_BPF_SANDBOX
1424 return false; 1422 return false;
1425 } 1423 }
1426 1424
1427 bool SandboxSeccompBpf::SupportsSandbox() { 1425 bool SandboxSeccompBpf::SupportsSandbox() {
1428 #if defined(SECCOMP_BPF_SANDBOX) 1426 #if defined(SECCOMP_BPF_SANDBOX)
1429 // TODO(jln): pass the saved proc_fd_ from the LinuxSandbox singleton 1427 // TODO(jln): pass the saved proc_fd_ from the LinuxSandbox singleton
1430 // here. 1428 // here.
1431 if (Sandbox::supportsSeccompSandbox(-1) == 1429 if (Sandbox::supportsSeccompSandbox(-1) ==
1432 Sandbox::STATUS_AVAILABLE) { 1430 Sandbox::STATUS_AVAILABLE) {
1433 return true; 1431 return true;
(...skipping 10 matching lines...) Expand all
1444 // Process-specific policy. 1442 // Process-specific policy.
1445 ShouldEnableSeccompBpf(process_type) && 1443 ShouldEnableSeccompBpf(process_type) &&
1446 SupportsSandbox()) { 1444 SupportsSandbox()) {
1447 return StartBpfSandbox(command_line, process_type); 1445 return StartBpfSandbox(command_line, process_type);
1448 } 1446 }
1449 #endif 1447 #endif
1450 return false; 1448 return false;
1451 } 1449 }
1452 1450
1453 } // namespace content 1451 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | sandbox/linux/sandbox_linux.gypi » ('j') | sandbox/linux/seccomp-bpf/syscall_iterator.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698