| OLD | NEW |
| 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 #include "sandbox/linux/seccomp-bpf-helpers/baseline_policy.h" | 5 #include "sandbox/linux/seccomp-bpf-helpers/baseline_policy.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <sys/mman.h> | 8 #include <sys/mman.h> |
| 9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
| 10 #include <sys/syscall.h> | 10 #include <sys/syscall.h> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 bool IsBaselinePolicyAllowed(int sysno) { | 30 bool IsBaselinePolicyAllowed(int sysno) { |
| 31 return SyscallSets::IsAllowedAddressSpaceAccess(sysno) || | 31 return SyscallSets::IsAllowedAddressSpaceAccess(sysno) || |
| 32 SyscallSets::IsAllowedBasicScheduler(sysno) || | 32 SyscallSets::IsAllowedBasicScheduler(sysno) || |
| 33 SyscallSets::IsAllowedEpoll(sysno) || | 33 SyscallSets::IsAllowedEpoll(sysno) || |
| 34 SyscallSets::IsAllowedFileSystemAccessViaFd(sysno) || | 34 SyscallSets::IsAllowedFileSystemAccessViaFd(sysno) || |
| 35 SyscallSets::IsAllowedFutex(sysno) || | 35 SyscallSets::IsAllowedFutex(sysno) || |
| 36 SyscallSets::IsAllowedGeneralIo(sysno) || | 36 SyscallSets::IsAllowedGeneralIo(sysno) || |
| 37 SyscallSets::IsAllowedGetOrModifySocket(sysno) || | 37 SyscallSets::IsAllowedGetOrModifySocket(sysno) || |
| 38 SyscallSets::IsAllowedGettime(sysno) || | 38 SyscallSets::IsAllowedGettime(sysno) || |
| 39 SyscallSets::IsAllowedPrctl(sysno) || | |
| 40 SyscallSets::IsAllowedProcessStartOrDeath(sysno) || | 39 SyscallSets::IsAllowedProcessStartOrDeath(sysno) || |
| 41 SyscallSets::IsAllowedSignalHandling(sysno) || | 40 SyscallSets::IsAllowedSignalHandling(sysno) || |
| 42 SyscallSets::IsGetSimpleId(sysno) || | 41 SyscallSets::IsGetSimpleId(sysno) || |
| 43 SyscallSets::IsKernelInternalApi(sysno) || | 42 SyscallSets::IsKernelInternalApi(sysno) || |
| 44 #if defined(__arm__) | 43 #if defined(__arm__) |
| 45 SyscallSets::IsArmPrivate(sysno) || | 44 SyscallSets::IsArmPrivate(sysno) || |
| 46 #endif | 45 #endif |
| 47 SyscallSets::IsAllowedOperationOnFd(sysno); | 46 SyscallSets::IsAllowedOperationOnFd(sysno); |
| 48 } | 47 } |
| 49 | 48 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 64 SyscallSets::IsInotify(sysno) || | 63 SyscallSets::IsInotify(sysno) || |
| 65 SyscallSets::IsKernelModule(sysno) || | 64 SyscallSets::IsKernelModule(sysno) || |
| 66 SyscallSets::IsKeyManagement(sysno) || | 65 SyscallSets::IsKeyManagement(sysno) || |
| 67 SyscallSets::IsKill(sysno) || | 66 SyscallSets::IsKill(sysno) || |
| 68 SyscallSets::IsMessageQueue(sysno) || | 67 SyscallSets::IsMessageQueue(sysno) || |
| 69 SyscallSets::IsMisc(sysno) || | 68 SyscallSets::IsMisc(sysno) || |
| 70 #if defined(__x86_64__) | 69 #if defined(__x86_64__) |
| 71 SyscallSets::IsNetworkSocketInformation(sysno) || | 70 SyscallSets::IsNetworkSocketInformation(sysno) || |
| 72 #endif | 71 #endif |
| 73 SyscallSets::IsNuma(sysno) || | 72 SyscallSets::IsNuma(sysno) || |
| 73 SyscallSets::IsPrctl(sysno) || |
| 74 SyscallSets::IsProcessGroupOrSession(sysno) || | 74 SyscallSets::IsProcessGroupOrSession(sysno) || |
| 75 #if defined(__i386__) | 75 #if defined(__i386__) |
| 76 SyscallSets::IsSocketCall(sysno) || | 76 SyscallSets::IsSocketCall(sysno) || |
| 77 #endif | 77 #endif |
| 78 #if defined(__arm__) | 78 #if defined(__arm__) |
| 79 SyscallSets::IsArmPciConfig(sysno) || | 79 SyscallSets::IsArmPciConfig(sysno) || |
| 80 #endif | 80 #endif |
| 81 SyscallSets::IsTimer(sysno); | 81 SyscallSets::IsTimer(sysno); |
| 82 } | 82 } |
| 83 | 83 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 #endif | 138 #endif |
| 139 | 139 |
| 140 #if defined(__i386__) || defined(__arm__) | 140 #if defined(__i386__) || defined(__arm__) |
| 141 if (sysno == __NR_mmap2) | 141 if (sysno == __NR_mmap2) |
| 142 return RestrictMmapFlags(sandbox); | 142 return RestrictMmapFlags(sandbox); |
| 143 #endif | 143 #endif |
| 144 | 144 |
| 145 if (sysno == __NR_mprotect) | 145 if (sysno == __NR_mprotect) |
| 146 return RestrictMprotectFlags(sandbox); | 146 return RestrictMprotectFlags(sandbox); |
| 147 | 147 |
| 148 if (sysno == __NR_prctl) |
| 149 return sandbox::RestrictPrctl(sandbox); |
| 150 |
| 148 #if defined(__x86_64__) || defined(__arm__) | 151 #if defined(__x86_64__) || defined(__arm__) |
| 149 if (sysno == __NR_socketpair) { | 152 if (sysno == __NR_socketpair) { |
| 150 // Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen. | 153 // Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen. |
| 151 COMPILE_ASSERT(AF_UNIX == PF_UNIX, af_unix_pf_unix_different); | 154 COMPILE_ASSERT(AF_UNIX == PF_UNIX, af_unix_pf_unix_different); |
| 152 return sandbox->Cond(0, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, AF_UNIX, | 155 return sandbox->Cond(0, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, AF_UNIX, |
| 153 ErrorCode(ErrorCode::ERR_ALLOWED), | 156 ErrorCode(ErrorCode::ERR_ALLOWED), |
| 154 sandbox->Trap(CrashSIGSYS_Handler, NULL)); | 157 sandbox->Trap(CrashSIGSYS_Handler, NULL)); |
| 155 } | 158 } |
| 156 #endif | 159 #endif |
| 157 | 160 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 ErrorCode BaselinePolicy::EvaluateSyscall(SandboxBPF* sandbox, | 212 ErrorCode BaselinePolicy::EvaluateSyscall(SandboxBPF* sandbox, |
| 210 int sysno) const { | 213 int sysno) const { |
| 211 // Make sure that this policy is used in the creating process. | 214 // Make sure that this policy is used in the creating process. |
| 212 if (1 == sysno) { | 215 if (1 == sysno) { |
| 213 DCHECK_EQ(syscall(__NR_getpid), current_pid_); | 216 DCHECK_EQ(syscall(__NR_getpid), current_pid_); |
| 214 } | 217 } |
| 215 return EvaluateSyscallImpl(fs_denied_errno_, current_pid_, sandbox, sysno); | 218 return EvaluateSyscallImpl(fs_denied_errno_, current_pid_, sandbox, sysno); |
| 216 } | 219 } |
| 217 | 220 |
| 218 } // namespace sandbox. | 221 } // namespace sandbox. |
| OLD | NEW |