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

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

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

Powered by Google App Engine
This is Rietveld 408576698