#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
#include <errno.h>
#include <stdint.h>
#include <string.h>
#include <sys/prctl.h>
#include <sys/types.h>
#include <unistd.h>
#include "base/check_op.h"
#include "base/compiler_specific.h"
#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/notreached.h"
#include "base/posix/eintr_wrapper.h"
#include "build/build_config.h"
#include "sandbox/linux/bpf_dsl/bpf_dsl.h"
#include "sandbox/linux/bpf_dsl/codegen.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/syscall.h"
#include "sandbox/linux/seccomp-bpf/trap.h"
#include "sandbox/linux/services/proc_util.h"
#include "sandbox/linux/services/syscall_wrappers.h"
#include "sandbox/linux/services/thread_helpers.h"
#include "sandbox/linux/system_headers/linux_filter.h"
#include "sandbox/linux/system_headers/linux_seccomp.h"
#include "sandbox/linux/system_headers/linux_syscalls.h"
#include "sandbox/sandbox_buildflags.h"
namespace sandbox {
namespace {
bool KernelSupportsSeccompBPF() { … }
bool KernelHasLGBug() { … }
bool KernelSupportsSeccompFlags(unsigned int flags) { … }
bool KernelSupportsSeccompTsync() { … }
#if BUILDFLAG(DISABLE_SECCOMP_SSBD)
bool KernelSupportSeccompSpecAllow() { … }
#endif
uint64_t EscapePC() { … }
intptr_t SandboxPanicTrap(const struct arch_seccomp_data&, void* aux) { … }
bpf_dsl::ResultExpr SandboxPanic(const char* error) { … }
}
SandboxBPF::SandboxBPF(std::unique_ptr<bpf_dsl::Policy> policy)
: … { … }
SandboxBPF::~SandboxBPF() { … }
bool SandboxBPF::SupportsSeccompSandbox(SeccompLevel level) { … }
bool SandboxBPF::StartSandbox(SeccompLevel seccomp_level, bool enable_ibpb) { … }
void SandboxBPF::SetProcFd(base::ScopedFD proc_fd) { … }
bool SandboxBPF::IsValidSyscallNumber(int sysnum) { … }
bool SandboxBPF::IsRequiredForUnsafeTrap(int sysno) { … }
intptr_t SandboxBPF::ForwardSyscall(const struct arch_seccomp_data& args) { … }
CodeGen::Program SandboxBPF::AssembleFilter() { … }
void SandboxBPF::InstallFilter(bool must_sync_threads, bool enable_ibpb) { … }
void SandboxBPF::DisableIBSpec() { … }
}