#include "sandbox/policy/linux/sandbox_seccomp_bpf_linux.h"
#include <errno.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <memory>
#include <utility>
#include "base/check_op.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/notreached.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "ppapi/buildflags/buildflags.h"
#include "printing/buildflags/buildflags.h"
#include "sandbox/linux/bpf_dsl/bpf_dsl.h"
#include "sandbox/linux/bpf_dsl/trap_registry.h"
#include "sandbox/policy/mojom/sandbox.mojom.h"
#include "sandbox/policy/switches.h"
#include "sandbox/sandbox_buildflags.h"
#if BUILDFLAG(USE_SECCOMP_BPF)
#include "base/files/scoped_file.h"
#include "base/posix/eintr_wrapper.h"
#include "sandbox/linux/seccomp-bpf-helpers/baseline_policy.h"
#include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h"
#include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h"
#include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h"
#include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
#include "sandbox/linux/system_headers/linux_syscalls.h"
#include "sandbox/policy/chromecast_sandbox_allowlist_buildflags.h"
#include "sandbox/policy/linux/bpf_audio_policy_linux.h"
#include "sandbox/policy/linux/bpf_base_policy_linux.h"
#include "sandbox/policy/linux/bpf_cdm_policy_linux.h"
#include "sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.h"
#include "sandbox/policy/linux/bpf_cros_arm_gpu_policy_linux.h"
#include "sandbox/policy/linux/bpf_cros_intel_gpu_policy_linux.h"
#include "sandbox/policy/linux/bpf_cros_nvidia_gpu_policy_linux.h"
#include "sandbox/policy/linux/bpf_cros_virtio_gpu_policy_linux.h"
#include "sandbox/policy/linux/bpf_gpu_policy_linux.h"
#include "sandbox/policy/linux/bpf_network_policy_linux.h"
#include "sandbox/policy/linux/bpf_ppapi_policy_linux.h"
#include "sandbox/policy/linux/bpf_print_backend_policy_linux.h"
#include "sandbox/policy/linux/bpf_print_compositor_policy_linux.h"
#include "sandbox/policy/linux/bpf_renderer_policy_linux.h"
#include "sandbox/policy/linux/bpf_service_policy_linux.h"
#include "sandbox/policy/linux/bpf_speech_recognition_policy_linux.h"
#include "sandbox/policy/linux/bpf_utility_policy_linux.h"
#if BUILDFLAG(ENABLE_SCREEN_AI_SERVICE)
#include "sandbox/policy/linux/bpf_screen_ai_policy_linux.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/ash/components/assistant/buildflags.h"
#include "sandbox/policy/features.h"
#include "sandbox/policy/linux/bpf_ime_policy_linux.h"
#include "sandbox/policy/linux/bpf_nearby_policy_linux.h"
#include "sandbox/policy/linux/bpf_tts_policy_linux.h"
#if BUILDFLAG(ENABLE_CROS_LIBASSISTANT)
#include "sandbox/policy/linux/bpf_libassistant_policy_linux.h"
#endif
#endif
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_ASH)
#include "sandbox/policy/linux/bpf_hardware_video_decoding_policy_linux.h"
#endif
Allow;
ResultExpr;
#else
#if !defined(ARCH_CPU_ARM64) && !defined(ARCH_CPU_MIPS64EL)
#error "Seccomp-bpf disabled on supported architecture!"
#endif
#endif
namespace sandbox {
namespace policy {
#if BUILDFLAG(USE_SECCOMP_BPF)
namespace {
#if !defined(IN_NACL_HELPER)
inline bool IsChromeOS() { … }
inline bool UseChromecastSandboxAllowlist() { … }
inline bool IsArchitectureArm() { … }
std::unique_ptr<BPFBasePolicy> GetGpuProcessSandbox(
const SandboxSeccompBPF::Options& options) { … }
#endif
}
#endif
bool SandboxSeccompBPF::IsSeccompBPFDesired() { … }
bool SandboxSeccompBPF::SupportsSandbox() { … }
bool SandboxSeccompBPF::SupportsSandboxWithTsync() { … }
std::unique_ptr<BPFBasePolicy> SandboxSeccompBPF::PolicyForSandboxType(
sandbox::mojom::Sandbox sandbox_type,
const SandboxSeccompBPF::Options& options) { … }
void SandboxSeccompBPF::RunSandboxSanityChecks(
sandbox::mojom::Sandbox sandbox_type,
const SandboxSeccompBPF::Options& options) { … }
bool SandboxSeccompBPF::StartSandboxWithExternalPolicy(
std::unique_ptr<bpf_dsl::Policy> policy,
base::ScopedFD proc_fd,
SandboxBPF::SeccompLevel seccomp_level,
bool force_disable_spectre_variant2_mitigation) { … }
std::unique_ptr<bpf_dsl::Policy> SandboxSeccompBPF::GetBaselinePolicy() { … }
}
}