#include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h"
#include <errno.h>
#include <fcntl.h>
#include <linux/net.h>
#include <sched.h>
#include <signal.h>
#include <stdint.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/prctl.h>
#include <sys/ptrace.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include "base/notreached.h"
#include "base/synchronization/synchronization_buildflags.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "sandbox/linux/bpf_dsl/bpf_dsl.h"
#include "sandbox/linux/bpf_dsl/seccomp_macros.h"
#include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h"
#include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
#include "sandbox/linux/system_headers/linux_futex.h"
#include "sandbox/linux/system_headers/linux_prctl.h"
#include "sandbox/linux/system_headers/linux_ptrace.h"
#include "sandbox/linux/system_headers/linux_syscalls.h"
#include "sandbox/linux/system_headers/linux_time.h"
#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && \
!defined(__arm__) && !defined(__aarch64__) && \
!defined(PTRACE_GET_THREAD_AREA)
#include <asm/ptrace-abi.h>
#endif
#if BUILDFLAG(IS_ANDROID)
#if !defined(F_DUPFD_CLOEXEC)
#define F_DUPFD_CLOEXEC …
#endif
#endif
#if defined(__arm__) && !defined(MAP_STACK)
#define MAP_STACK …
#endif
#if defined(__mips__) && !defined(MAP_STACK)
#define MAP_STACK …
#endif
#if defined(ARCH_CPU_ARM64)
#define PROT_MTE …
#define PROT_BTI …
#endif
namespace {
inline bool IsArchitectureX86_64() { … }
inline bool IsArchitectureI386() { … }
inline bool IsAndroid() { … }
inline bool IsArchitectureMips() { … }
inline bool IsBuggyGlibcSemPost() { … }
}
Allow;
Arg;
BoolExpr;
Error;
If;
ResultExpr;
namespace sandbox {
ResultExpr RestrictCloneToThreadsAndEPERMFork() { … }
#ifndef PR_PAC_RESET_KEYS
#define PR_PAC_RESET_KEYS …
#endif
ResultExpr RestrictPrctl() { … }
ResultExpr RestrictIoctl() { … }
ResultExpr RestrictMmapFlags() { … }
ResultExpr RestrictMprotectFlags() { … }
ResultExpr RestrictFcntlCommands() { … }
#if defined(__i386__) || defined(__mips__)
ResultExpr RestrictSocketcallCommand() {
const Arg<int> call(0);
return Switch(call)
.Cases({SYS_SOCKETPAIR,
SYS_SHUTDOWN,
SYS_RECV,
SYS_SEND,
SYS_RECVFROM,
SYS_SENDTO,
SYS_RECVMSG,
SYS_SENDMSG},
Allow())
.Default(Error(EPERM));
}
#endif
ResultExpr RestrictKillTarget(pid_t target_pid, int sysno) { … }
ResultExpr RestrictFutex() { … }
ResultExpr RestrictGetSetpriority(pid_t target_pid) { … }
ResultExpr RestrictSchedTarget(pid_t target_pid, int sysno) { … }
ResultExpr RestrictPrlimit64(pid_t target_pid) { … }
ResultExpr RestrictGetrusage() { … }
ResultExpr RestrictClockID() { … }
#if !defined(GRND_NONBLOCK)
#define GRND_NONBLOCK …
#endif
#if !defined(GRND_INSECURE)
#define GRND_INSECURE …
#endif
ResultExpr RestrictGetRandom() { … }
ResultExpr RestrictPrlimit(pid_t target_pid) { … }
ResultExpr RestrictPrlimitToGetrlimit(pid_t target_pid) { … }
ResultExpr RestrictPtrace() { … }
ResultExpr RestrictPkeyAllocFlags() { … }
ResultExpr RestrictGoogle3Threading(int sysno) { … }
ResultExpr RestrictPipe2() { … }
}