Home | History | Annotate | Download | only in seccomp-bpf

Lines Matching defs:Sandbox

26 #include "sandbox/linux/seccomp-bpf/codegen.h"
27 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
28 #include "sandbox/linux/seccomp-bpf/syscall.h"
29 #include "sandbox/linux/seccomp-bpf/syscall_iterator.h"
30 #include "sandbox/linux/seccomp-bpf/verifier.h"
36 using playground2::Sandbox;
64 // We define a really simple sandbox policy. It is just good enough for us
65 // to tell that the sandbox has actually been activated.
66 ErrorCode ProbeEvaluator(Sandbox *, int sysnum, void *) __attribute__((const));
67 ErrorCode ProbeEvaluator(Sandbox *, int sysnum, void *) {
87 ErrorCode AllowAllEvaluator(Sandbox *, int sysnum, void *) {
88 if (!Sandbox::IsValidSyscallNumber(sysnum)) {
166 // This means, we must conditionally disable the sandbox -- and that's not
174 Sandbox *sandbox = static_cast<Sandbox *>(aux);
177 insn->k = sandbox->Trap(ReturnErrno,
186 ErrorCode RedirectToUserspaceEvalWrapper(Sandbox *sandbox, int sysnum,
190 Sandbox::Evaluators *evaluators =
191 reinterpret_cast<Sandbox::Evaluators *>(aux);
192 const std::pair<Sandbox::EvaluateSyscall, void *>& evaluator =
195 ErrorCode err = evaluator.first(sandbox, sysnum, evaluator.second);
197 return sandbox->Trap(ReturnErrno,
209 // The kernel gives us a sandbox, we turn it into a playground :-)
214 Sandbox::Sandbox()
221 Sandbox::~Sandbox() {
227 // sandbox. But this won't happen, if the Sandbox object was created and
228 // never actually used to set up a sandbox. So, just in case, we are
232 // objects before setting up the sandbox.
241 bool Sandbox::IsValidSyscallNumber(int sysnum) {
246 bool Sandbox::RunFunctionInPolicy(void (*code_in_sandbox)(),
247 Sandbox::EvaluateSyscall syscall_evaluator,
272 // into running without a sandbox.
279 // Test a very simple sandbox policy to verify that we can
318 // Run our code in the sandbox.
361 bool Sandbox::KernelSupportSeccompBPF() {
367 Sandbox::SandboxStatus Sandbox::SupportsSeccompSandbox(int proc_fd) {
368 // It the sandbox is currently active, we clearly must have support for
374 // Even if the sandbox was previously available, something might have
395 // If we have not previously checked for availability of the sandbox or if
399 // We create our own private copy of a "Sandbox" object. This ensures that
402 Sandbox sandbox;
406 sandbox.quiet_ = true;
407 sandbox.set_proc_fd(proc_fd);
408 status_ = sandbox.KernelSupportSeccompBPF()
412 // environment that is visible to the sandbox is always guaranteed to be
414 // threaded. Otherwise, we mark the sandbox as temporarily unavailable.
422 void Sandbox::set_proc_fd(int proc_fd) {
426 void Sandbox::StartSandbox() {
428 SANDBOX_DIE("Trying to start sandbox, even though it is known to be "
431 SANDBOX_DIE("Cannot repeatedly start sandbox. Create a separate Sandbox "
442 SANDBOX_DIE("Cannot start sandbox, if process is already multi-threaded");
458 // We are now inside the sandbox.
462 void Sandbox::PolicySanityChecks(EvaluateSyscall syscall_evaluator,
474 void Sandbox::SetSandboxPolicy(EvaluateSyscall syscall_evaluator, void *aux) {
476 SANDBOX_DIE("Cannot change policy after sandbox has started");
482 void Sandbox::InstallFilter() {
485 // the sandbox is active, we shouldn't be relying on libraries that could
520 Sandbox::Program *Sandbox::AssembleFilter(bool force_verification) {
564 // If there is at least one UnsafeTrap() in our program, the entire sandbox
579 // measures that the sandbox provides, we print a big warning message --
581 // is actually requested by the sandbox policy.
629 // match, we continue evalutating the rest of the sandbox policy.
687 void Sandbox::VerifyProgram(const Program& program, bool has_unsafe_traps) {
707 void Sandbox::FindRanges(Ranges *ranges) {
723 // A proper sandbox policy should always treat system calls outside of
737 Instruction *Sandbox::AssembleJumpTable(CodeGen *gen,
764 Instruction *Sandbox::RetExpression(CodeGen *gen, const ErrorCode& err) {
772 Instruction *Sandbox::CondExpression(CodeGen *gen, const ErrorCode& cond) {
949 ErrorCode Sandbox::Unexpected64bitArgument() {
953 ErrorCode Sandbox::Trap(Trap::TrapFnc fnc, const void *aux) {
957 ErrorCode Sandbox::UnsafeTrap(Trap::TrapFnc fnc, const void *aux) {
961 intptr_t Sandbox::ForwardSyscall(const struct arch_seccomp_data& args) {
971 ErrorCode Sandbox::Cond(int argno, ErrorCode::ArgType width,
979 ErrorCode Sandbox::Kill(const char *msg) {
983 Sandbox::SandboxStatus Sandbox::status_ = STATUS_UNKNOWN;