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

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

Issue 939943002: bpf_dsl: decouple PolicyCompiler from Syscall (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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: sandbox/linux/seccomp-bpf/sandbox_bpf.cc
diff --git a/sandbox/linux/seccomp-bpf/sandbox_bpf.cc b/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
index 31975a1b98e33539d60a977cf70e789d09ecd6d5..5a6f9862534303b8d2282654ac811a4cb39aaec1 100644
--- a/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
+++ b/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
@@ -79,6 +79,14 @@ bool KernelSupportsSeccompTsync() {
}
}
+uint64_t EscapePC() {
+ intptr_t rv = Syscall::Call(-1);
+ if (rv == -1 && errno == ENOSYS) {
+ return 0;
+ }
+ return static_cast<uint64_t>(static_cast<uintptr_t>(rv));
+}
+
} // namespace
SandboxBPF::SandboxBPF(bpf_dsl::Policy* policy)
@@ -184,7 +192,7 @@ scoped_ptr<CodeGen::Program> SandboxBPF::AssembleFilter(
force_verification = true;
#endif
DCHECK(policy_);
- bpf_dsl::PolicyCompiler compiler(policy_.get(), Trap::Registry());
+ bpf_dsl::PolicyCompiler compiler(policy_.get(), Trap::Registry(), EscapePC());
scoped_ptr<CodeGen::Program> program = compiler.Compile();
// Make sure compilation resulted in a BPF program that executes
« sandbox/linux/bpf_dsl/policy_compiler.h ('K') | « sandbox/linux/bpf_dsl/policy_compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698