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

Unified Diff: components/nacl/loader/nonsfi/nonsfi_sandbox.cc

Issue 1029283003: WIP: Implement seccomp-bpf sandbox for nacl_helper_nonsfi. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
Index: components/nacl/loader/nonsfi/nonsfi_sandbox.cc
diff --git a/components/nacl/loader/nonsfi/nonsfi_sandbox.cc b/components/nacl/loader/nonsfi/nonsfi_sandbox.cc
index 0340f6ff146c60669a1e4addea6570555b62da25..c4bd17e190003d98d9ace7041b5f6bf7f765ca4e 100644
--- a/components/nacl/loader/nonsfi/nonsfi_sandbox.cc
+++ b/components/nacl/loader/nonsfi/nonsfi_sandbox.cc
@@ -6,11 +6,8 @@
#include <errno.h>
#include <fcntl.h>
-#include <linux/futex.h>
-#include <linux/net.h>
#include <sys/mman.h>
#include <sys/prctl.h>
-#include <sys/ptrace.h>
#include <sys/socket.h>
#include <sys/syscall.h>
#include <sys/time.h>
@@ -23,13 +20,27 @@
#include "sandbox/linux/bpf_dsl/bpf_dsl.h"
#include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h"
#include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h"
+#include "sandbox/linux/system_headers/android_futex.h"
#include "sandbox/linux/system_headers/linux_syscalls.h"
+#if !defined(OS_NACL_NONSFI)
+#include <linux/net.h> // TODO move SYS_SOCKETPAIR etc to there.
+#include <sys/ptrace.h>
+#endif
+
#if defined(__arm__) && !defined(MAP_STACK)
// Chrome OS Daisy (ARM) build environment has old headers.
#define MAP_STACK 0x20000
#endif
+// TODO
+#if !defined(PR_SET_NAME)
+#define PR_SET_NAME 15
+#endif
+#if !defined(MAP_STACK)
+#define MAP_STACK 0x20000
+#endif
+
#define CASES SANDBOX_BPF_DSL_CASES
using sandbox::CrashSIGSYS;
@@ -183,12 +194,15 @@ bool IsGracefullyDenied(int sysno) {
}
void RunSandboxSanityChecks() {
+#if !defined(OS_NACL_NONSFI)
+ // TODO: Is this sanity check needed? Can we have alternative?
errno = 0;
// Make a ptrace request with an invalid PID.
long ptrace_ret = ptrace(PTRACE_PEEKUSER, -1 /* pid */, NULL, NULL);
CHECK_EQ(-1, ptrace_ret);
// Without the sandbox on, this ptrace call would ESRCH instead.
CHECK_EQ(EPERM, errno);
+#endif
}
} // namespace
« no previous file with comments | « components/nacl/loader/nacl_helper_linux.cc ('k') | components/nacl/loader/sandbox_linux/nacl_sandbox_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698