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

Unified Diff: sandbox/linux/seccomp-bpf/sandbox_bpf.h

Issue 10536048: Instead of outputting one BPF check per possible system call. Coalesce (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplified the asserts Created 8 years, 6 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/seccomp-bpf/sandbox_bpf.cc » ('j') | sandbox/linux/seccomp-bpf/sandbox_bpf.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/linux/seccomp-bpf/sandbox_bpf.h
diff --git a/sandbox/linux/seccomp-bpf/sandbox_bpf.h b/sandbox/linux/seccomp-bpf/sandbox_bpf.h
index 0d8b754c1044fe80b025de9aca52c479b56bd640..62a09c2278294cbb80676bfaa9ab48749642b75a 100644
--- a/sandbox/linux/seccomp-bpf/sandbox_bpf.h
+++ b/sandbox/linux/seccomp-bpf/sandbox_bpf.h
@@ -33,6 +33,7 @@
#include <unistd.h>
#include <algorithm>
+#include <limits>
#include <utility>
#include <vector>
@@ -71,8 +72,8 @@
#endif
#if defined(__i386__)
-#define MIN_SYSCALL 0
-#define MAX_SYSCALL 1024
+#define MIN_SYSCALL 0u
+#define MAX_SYSCALL 1024u
#define SECCOMP_ARCH AUDIT_ARCH_I386
#define REG_RESULT REG_EAX
#define REG_SYSCALL REG_EAX
@@ -83,8 +84,8 @@
#define REG_PARM5 REG_EDI
#define REG_PARM6 REG_EBP
#elif defined(__x86_64__)
-#define MIN_SYSCALL 0
-#define MAX_SYSCALL 1024
+#define MIN_SYSCALL 0u
+#define MAX_SYSCALL 1024u
#define SECCOMP_ARCH AUDIT_ARCH_X86_64
#define REG_RESULT REG_RAX
#define REG_SYSCALL REG_RAX
@@ -139,6 +140,8 @@ class Sandbox {
SB_INSPECT_ARG_4 = 0x8008,
SB_INSPECT_ARG_5 = 0x8010,
SB_INSPECT_ARG_6 = 0x8020
+
+ // Also, any errno value is valid when cast to ErrorCode.
};
enum Operation {
@@ -230,13 +233,26 @@ class Sandbox {
static int getProcFd() { return proc_fd_; }
private:
- static ErrorCode probeEvaluator(int signo);
- static bool kernelSupportSeccompBPF(int proc_fd);
+ struct Range {
+ Range(uint32_t f, uint32_t t, ErrorCode e) :
+ from(f),
+ to(t),
+ err(e) {
+ }
+ uint32_t from, to;
+ ErrorCode err;
+ };
+ typedef std::vector<Range> Ranges;
+ typedef std::vector<struct sock_filter> Program;
- static bool isSingleThreaded(int proc_fd);
- static bool disableFilesystem();
- static void installFilter();
- static void sigSys(int nr, siginfo_t *info, void *void_context);
+ static ErrorCode probeEvaluator(int signo) __attribute__((const));
+ static bool kernelSupportSeccompBPF(int proc_fd);
+ static bool isSingleThreaded(int proc_fd);
+ static bool disableFilesystem();
+ static void installFilter();
+ static void findRanges(Ranges *ranges);
+ static void rangesToBPF(Program *program, const Ranges& ranges);
+ static void sigSys(int nr, siginfo_t *info, void *void_context);
static bool suppressLogging_;
static SandboxStatus status_;
« no previous file with comments | « no previous file | sandbox/linux/seccomp-bpf/sandbox_bpf.cc » ('j') | sandbox/linux/seccomp-bpf/sandbox_bpf.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698