| 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 b6553d7e24da4fac9a63fe3b77095eb6cf8d9850..c96642ec408685548d96f056731469bc4844a0dc 100644
|
| --- a/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
|
| +++ b/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
|
| @@ -24,16 +24,13 @@
|
| #include "base/posix/eintr_wrapper.h"
|
| #include "base/third_party/valgrind/valgrind.h"
|
| #include "sandbox/linux/bpf_dsl/codegen.h"
|
| -#include "sandbox/linux/bpf_dsl/dump_bpf.h"
|
| #include "sandbox/linux/bpf_dsl/policy.h"
|
| #include "sandbox/linux/bpf_dsl/policy_compiler.h"
|
| #include "sandbox/linux/bpf_dsl/seccomp_macros.h"
|
| #include "sandbox/linux/bpf_dsl/syscall_set.h"
|
| #include "sandbox/linux/seccomp-bpf/die.h"
|
| -#include "sandbox/linux/seccomp-bpf/errorcode.h"
|
| #include "sandbox/linux/seccomp-bpf/syscall.h"
|
| #include "sandbox/linux/seccomp-bpf/trap.h"
|
| -#include "sandbox/linux/seccomp-bpf/verifier.h"
|
| #include "sandbox/linux/services/proc_util.h"
|
| #include "sandbox/linux/services/syscall_wrappers.h"
|
| #include "sandbox/linux/services/thread_helpers.h"
|
| @@ -79,6 +76,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,25 +189,12 @@ scoped_ptr<CodeGen::Program> SandboxBPF::AssembleFilter(
|
| force_verification = true;
|
| #endif
|
| DCHECK(policy_);
|
| +
|
| bpf_dsl::PolicyCompiler compiler(policy_.get(), Trap::Registry());
|
| - scoped_ptr<CodeGen::Program> program = compiler.Compile();
|
| -
|
| - // Make sure compilation resulted in a BPF program that executes
|
| - // correctly. Otherwise, there is an internal error in our BPF compiler.
|
| - // There is really nothing the caller can do until the bug is fixed.
|
| - if (force_verification) {
|
| - // Verification is expensive. We only perform this step, if we are
|
| - // compiled in debug mode, or if the caller explicitly requested
|
| - // verification.
|
| -
|
| - const char* err = NULL;
|
| - if (!Verifier::VerifyBPF(&compiler, *program, *policy_, &err)) {
|
| - bpf_dsl::DumpBPF::PrintProgram(*program);
|
| - SANDBOX_DIE(err);
|
| - }
|
| + if (Trap::SandboxDebuggingAllowedByUser()) {
|
| + compiler.DangerousSetEscapePC(EscapePC());
|
| }
|
| -
|
| - return program.Pass();
|
| + return compiler.Compile(force_verification);
|
| }
|
|
|
| void SandboxBPF::InstallFilter(bool must_sync_threads) {
|
|
|