| Index: sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h
|
| diff --git a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h b/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h
|
| index f348bb59a2671336aef234da8e84eebf1d34b078..a0b66d68dc8c118ea87726514a3980132059f9db 100644
|
| --- a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h
|
| +++ b/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h
|
| @@ -8,6 +8,7 @@
|
| #include <unistd.h>
|
|
|
| #include "build/build_config.h"
|
| +#include "sandbox/linux/seccomp-bpf-helpers/bpf_dsl.h"
|
| #include "sandbox/sandbox_export.h"
|
|
|
| // These are helpers to build seccomp-bpf policies, i.e. policies for a
|
| @@ -16,51 +17,48 @@
|
|
|
| namespace sandbox {
|
|
|
| -class ErrorCode;
|
| -class SandboxBPF;
|
| -
|
| // Allow clone(2) for threads.
|
| // Reject fork(2) attempts with EPERM.
|
| // Don't restrict on ASAN.
|
| // Crash if anything else is attempted.
|
| -SANDBOX_EXPORT ErrorCode
|
| - RestrictCloneToThreadsAndEPERMFork(SandboxBPF* sandbox);
|
| +SANDBOX_EXPORT bpf_dsl::ResultExpr RestrictCloneToThreadsAndEPERMFork();
|
|
|
| // Allow PR_SET_NAME, PR_SET_DUMPABLE, PR_GET_DUMPABLE.
|
| // Crash if anything else is attempted.
|
| -SANDBOX_EXPORT ErrorCode RestrictPrctl(SandboxBPF* sandbox);
|
| +SANDBOX_EXPORT bpf_dsl::ResultExpr RestrictPrctl();
|
|
|
| // Allow TCGETS and FIONREAD.
|
| // Crash if anything else is attempted.
|
| -SANDBOX_EXPORT ErrorCode RestrictIoctl(SandboxBPF* sandbox);
|
| +SANDBOX_EXPORT bpf_dsl::ResultExpr RestrictIoctl();
|
|
|
| // Restrict the flags argument in mmap(2).
|
| // Only allow: MAP_SHARED | MAP_PRIVATE | MAP_ANONYMOUS |
|
| // MAP_STACK | MAP_NORESERVE | MAP_FIXED | MAP_DENYWRITE.
|
| // Crash if any other flag is used.
|
| -SANDBOX_EXPORT ErrorCode RestrictMmapFlags(SandboxBPF* sandbox);
|
| +SANDBOX_EXPORT bpf_dsl::ResultExpr RestrictMmapFlags();
|
|
|
| // Restrict the prot argument in mprotect(2).
|
| // Only allow: PROT_READ | PROT_WRITE | PROT_EXEC.
|
| -SANDBOX_EXPORT ErrorCode RestrictMprotectFlags(SandboxBPF* sandbox);
|
| +SANDBOX_EXPORT bpf_dsl::ResultExpr RestrictMprotectFlags();
|
|
|
| // Restrict fcntl(2) cmd argument to:
|
| // We allow F_GETFL, F_SETFL, F_GETFD, F_SETFD, F_DUPFD, F_DUPFD_CLOEXEC,
|
| // F_SETLK, F_SETLKW and F_GETLK.
|
| // Also, in F_SETFL, restrict the allowed flags to: O_ACCMODE | O_APPEND |
|
| // O_NONBLOCK | O_SYNC | O_LARGEFILE | O_CLOEXEC | O_NOATIME.
|
| -SANDBOX_EXPORT ErrorCode RestrictFcntlCommands(SandboxBPF* sandbox);
|
| +SANDBOX_EXPORT bpf_dsl::ResultExpr RestrictFcntlCommands();
|
|
|
| #if defined(__i386__)
|
| // Restrict socketcall(2) to only allow socketpair(2), send(2), recv(2),
|
| // sendto(2), recvfrom(2), shutdown(2), sendmsg(2) and recvmsg(2).
|
| -SANDBOX_EXPORT ErrorCode RestrictSocketcallCommand(SandboxBPF* sandbox);
|
| +SANDBOX_EXPORT bpf_dsl::ResultExpr RestrictSocketcallCommand();
|
| #endif
|
|
|
| // Restrict |sysno| (which must be kill, tkill or tgkill) by allowing tgkill or
|
| // kill iff the first parameter is |target_pid|, crashing otherwise or if
|
| // |sysno| is tkill.
|
| -ErrorCode RestrictKillTarget(pid_t target_pid, SandboxBPF* sandbox, int sysno);
|
| +SANDBOX_EXPORT bpf_dsl::ResultExpr RestrictKillTarget(pid_t target_pid,
|
| + int sysno);
|
|
|
| } // namespace sandbox.
|
|
|
|
|