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

Unified Diff: content/common/sandbox_init_linux.cc

Issue 10833044: Refactored ErrorCode into it's own class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased, and removed "protected" as requested by jln Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sandbox/linux/sandbox_linux.gypi » ('j') | sandbox/linux/seccomp-bpf/errorcode.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/sandbox_init_linux.cc
diff --git a/content/common/sandbox_init_linux.cc b/content/common/sandbox_init_linux.cc
index a67a784232aa70bcd6c856baf2546384bbab83da..e8ac8a66564749d8e535a132a1ba171bd17dfa6a 100644
--- a/content/common/sandbox_init_linux.cc
+++ b/content/common/sandbox_init_linux.cc
@@ -216,7 +216,7 @@ intptr_t GpuOpenSIGSYS_Handler(const struct arch_seccomp_data& args,
#if defined(__x86_64__)
// x86_64 only because it references system calls that are multiplexed on IA32.
-playground2::Sandbox::ErrorCode GpuProcessPolicy_x86_64(int sysno) {
+playground2::ErrorCode GpuProcessPolicy_x86_64(int sysno) {
switch(sysno) {
case __NR_read:
case __NR_ioctl:
@@ -264,7 +264,7 @@ playground2::Sandbox::ErrorCode GpuProcessPolicy_x86_64(int sysno) {
case __NR_getppid: // ATI binary driver.
case __NR_shutdown: // Virtual driver.
case __NR_rt_sigaction: // Breakpad signal handler.
- return playground2::Sandbox::SB_ALLOWED;
+ return playground2::ErrorCode::ERR_ALLOWED;
case __NR_socket:
return EACCES; // Nvidia binary driver.
case __NR_fchmod:
@@ -273,11 +273,11 @@ playground2::Sandbox::ErrorCode GpuProcessPolicy_x86_64(int sysno) {
// Hook open() in the GPU process to allow opening /etc/drirc,
// needed by Mesa.
// The hook needs dup(), lseek(), and close() to be allowed.
- return playground2::Sandbox::ErrorCode(GpuOpenSIGSYS_Handler, NULL);
+ return playground2::Sandbox::Trap(GpuOpenSIGSYS_Handler, NULL);
default:
if (IsGettimeSyscall(sysno) ||
IsKillSyscall(sysno)) { // GPU watchdog.
- return playground2::Sandbox::SB_ALLOWED;
+ return playground2::ErrorCode::ERR_ALLOWED;
}
// Generally, filename-based syscalls will fail with ENOENT to behave
// similarly to a possible future setuid sandbox.
@@ -285,12 +285,12 @@ playground2::Sandbox::ErrorCode GpuProcessPolicy_x86_64(int sysno) {
return ENOENT;
}
// In any other case crash the program with our SIGSYS handler
- return playground2::Sandbox::ErrorCode(CrashSIGSYS_Handler, NULL);
+ return playground2::Sandbox::Trap(CrashSIGSYS_Handler, NULL);
}
}
// x86_64 only because it references system calls that are multiplexed on IA32.
-playground2::Sandbox::ErrorCode FlashProcessPolicy_x86_64(int sysno) {
+playground2::ErrorCode FlashProcessPolicy_x86_64(int sysno) {
switch (sysno) {
case __NR_futex:
case __NR_write:
@@ -336,7 +336,7 @@ playground2::Sandbox::ErrorCode FlashProcessPolicy_x86_64(int sysno) {
case __NR_shmctl:
case __NR_shmat:
case __NR_shmdt:
- return playground2::Sandbox::SB_ALLOWED;
+ return playground2::ErrorCode::ERR_ALLOWED;
case __NR_ioctl:
return ENOTTY; // Flash Access.
case __NR_socket:
@@ -345,18 +345,18 @@ playground2::Sandbox::ErrorCode FlashProcessPolicy_x86_64(int sysno) {
default:
if (IsGettimeSyscall(sysno) ||
IsKillSyscall(sysno)) {
- return playground2::Sandbox::SB_ALLOWED;
+ return playground2::ErrorCode::ERR_ALLOWED;
}
if (IsFileSystemSyscall(sysno)) {
return ENOENT;
}
// In any other case crash the program with our SIGSYS handler.
- return playground2::Sandbox::ErrorCode(CrashSIGSYS_Handler, NULL);
+ return playground2::Sandbox::Trap(CrashSIGSYS_Handler, NULL);
}
}
#endif
-playground2::Sandbox::ErrorCode BlacklistPtracePolicy(int sysno) {
+playground2::ErrorCode BlacklistPtracePolicy(int sysno) {
if (sysno < static_cast<int>(MIN_SYSCALL) ||
sysno > static_cast<int>(MAX_SYSCALL)) {
// TODO(jln) we should not have to do that in a trivial policy.
@@ -368,22 +368,22 @@ playground2::Sandbox::ErrorCode BlacklistPtracePolicy(int sysno) {
case __NR_process_vm_writev:
case __NR_migrate_pages:
case __NR_move_pages:
- return playground2::Sandbox::ErrorCode(CrashSIGSYS_Handler, NULL);
+ return playground2::Sandbox::Trap(CrashSIGSYS_Handler, NULL);
default:
- return playground2::Sandbox::SB_ALLOWED;
+ return playground2::ErrorCode::ERR_ALLOWED;
}
}
// Allow all syscalls.
// This will still deny x32 or IA32 calls in 64 bits mode or
// 64 bits system calls in compatibility mode.
-playground2::Sandbox::ErrorCode AllowAllPolicy(int sysno) {
+playground2::ErrorCode AllowAllPolicy(int sysno) {
if (sysno < static_cast<int>(MIN_SYSCALL) ||
sysno > static_cast<int>(MAX_SYSCALL)) {
// TODO(jln) we should not have to do that in a trivial policy.
return ENOSYS;
} else {
- return playground2::Sandbox::SB_ALLOWED;
+ return playground2::ErrorCode::ERR_ALLOWED;
}
}
« no previous file with comments | « no previous file | sandbox/linux/sandbox_linux.gypi » ('j') | sandbox/linux/seccomp-bpf/errorcode.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698