Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h

Issue 98373007: Move more helpers to seccomp-bpf-helpers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_HELPERS_SYSCALL_PARAMETERS_RESTRICTIONS_H_
6 #define SANDBOX_LINUX_SECCOMP_BPF_HELPERS_SYSCALL_PARAMETERS_RESTRICTIONS_H_
7
8 #include "build/build_config.h"
9
10 // These are helpers to build seccomp-bpf policies, i.e. policies for a
11 // sandbox that reduces the Linux kernel's attack surface. They return an
12 // ErrorCode suitable to restrict certain system call parameters.
13
14 namespace playground2 {
15 class ErrorCode;
16 class Sandbox;
17 }
18
19 using playground2::ErrorCode;
20 using playground2::Sandbox;
21
22 namespace sandbox {
23
24 // Allow clone(2) for threads.
25 // Reject fork(2) attempts with EPERM.
26 // Don't restrict on ASAN.
27 // Crash if anything else is attempted.
28 ErrorCode RestrictCloneToThreadsAndEPERMFork(Sandbox* sandbox);
29
30 // Allow PR_SET_NAME, PR_SET_DUMPABLE, PR_GET_DUMPABLE.
31 // Crash if anything else is attempted.
32 ErrorCode RestrictPrctl(Sandbox* sandbox);
33
34 // Allow TCGETS and FIONREAD.
35 // Crash if anything else is attempted.
36 ErrorCode RestrictIoctl(Sandbox* sandbox);
37
38 // Restrict the flags argument in mmap(2).
39 // Only allow: MAP_SHARED | MAP_PRIVATE | MAP_ANONYMOUS |
40 // MAP_STACK | MAP_NORESERVE | MAP_FIXED | MAP_DENYWRITE.
41 // Crash if any other flag is used.
42 ErrorCode RestrictMmapFlags(Sandbox* sandbox);
43
44 // Restrict the prot argument in mprotect(2).
45 // Only allow: PROT_READ | PROT_WRITE | PROT_EXEC.
46 ErrorCode RestrictMprotectFlags(Sandbox* sandbox);
47
48 // Restrict fcntl(2) cmd argument to:
49 // We allow F_GETFL, F_SETFL, F_GETFD, F_SETFD, F_DUPFD, F_DUPFD_CLOEXEC,
50 // F_SETLK, F_SETLKW and F_GETLK.
51 // Also, in F_SETFL, restrict the allowed flags to: O_ACCMODE | O_APPEND |
52 // O_NONBLOCK | O_SYNC | O_LARGEFILE | O_CLOEXEC | O_NOATIME.
53 ErrorCode RestrictFcntlCommands(Sandbox* sandbox);
54
55 #if defined(__i386__)
56 // Restrict socketcall(2) to only allow socketpair(2), send(2), recv(2),
57 // sendto(2), recvfrom(2), shutdown(2), sendmsg(2) and recvmsg(2).
58 ErrorCode RestrictSocketcallCommand(Sandbox* sandbox);
59 #endif
60
61 } // namespace sandbox.
62
63 #endif // SANDBOX_LINUX_SECCOMP_BPF_HELPERS_SYSCALL_PARAMETERS_RESTRICTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698