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

Side by Side Diff: content/common/sandbox_linux/bpf_gpu_policy_linux.cc

Issue 598203004: Linux sandbox: Restrict sched_* syscalls on the GPU and ppapi processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename to policy_pid, add SANDBOX_EXPORT. Created 6 years, 2 months 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
« no previous file with comments | « no previous file | content/common/sandbox_linux/bpf_ppapi_policy_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/common/sandbox_linux/bpf_gpu_policy_linux.h" 5 #include "content/common/sandbox_linux/bpf_gpu_policy_linux.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
11 #include <sys/stat.h> 11 #include <sys/stat.h>
12 #include <sys/types.h> 12 #include <sys/types.h>
13 #include <unistd.h> 13 #include <unistd.h>
14 14
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 #include "base/bind.h" 18 #include "base/bind.h"
19 #include "base/command_line.h" 19 #include "base/command_line.h"
20 #include "base/compiler_specific.h" 20 #include "base/compiler_specific.h"
21 #include "base/logging.h" 21 #include "base/logging.h"
22 #include "base/memory/scoped_ptr.h" 22 #include "base/memory/scoped_ptr.h"
23 #include "build/build_config.h" 23 #include "build/build_config.h"
24 #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h" 24 #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h"
25 #include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h" 25 #include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h"
26 #include "content/common/set_process_title.h" 26 #include "content/common/set_process_title.h"
27 #include "content/public/common/content_switches.h" 27 #include "content/public/common/content_switches.h"
28 #include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h"
28 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h" 29 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h"
29 #include "sandbox/linux/seccomp-bpf/trap.h" 30 #include "sandbox/linux/seccomp-bpf/trap.h"
30 #include "sandbox/linux/services/broker_process.h" 31 #include "sandbox/linux/services/broker_process.h"
31 #include "sandbox/linux/services/linux_syscalls.h" 32 #include "sandbox/linux/services/linux_syscalls.h"
32 33
33 using sandbox::BrokerProcess; 34 using sandbox::BrokerProcess;
34 using sandbox::SyscallSets; 35 using sandbox::SyscallSets;
35 using sandbox::arch_seccomp_data; 36 using sandbox::arch_seccomp_data;
36 using sandbox::bpf_dsl::Allow; 37 using sandbox::bpf_dsl::Allow;
37 using sandbox::bpf_dsl::ResultExpr; 38 using sandbox::bpf_dsl::ResultExpr;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) 180 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
180 // The Nvidia driver uses flags not in the baseline policy 181 // The Nvidia driver uses flags not in the baseline policy
181 // (MAP_LOCKED | MAP_EXECUTABLE | MAP_32BIT) 182 // (MAP_LOCKED | MAP_EXECUTABLE | MAP_32BIT)
182 case __NR_mmap: 183 case __NR_mmap:
183 #endif 184 #endif
184 // We also hit this on the linux_chromeos bot but don't yet know what 185 // We also hit this on the linux_chromeos bot but don't yet know what
185 // weird flags were involved. 186 // weird flags were involved.
186 case __NR_mprotect: 187 case __NR_mprotect:
187 // TODO(jln): restrict prctl. 188 // TODO(jln): restrict prctl.
188 case __NR_prctl: 189 case __NR_prctl:
189 case __NR_sched_getaffinity:
190 case __NR_sched_setaffinity:
191 case __NR_setpriority:
192 return Allow(); 190 return Allow();
193 case __NR_access: 191 case __NR_access:
194 case __NR_open: 192 case __NR_open:
195 case __NR_openat: 193 case __NR_openat:
196 DCHECK(broker_process_); 194 DCHECK(broker_process_);
197 return Trap(GpuSIGSYS_Handler, broker_process_); 195 return Trap(GpuSIGSYS_Handler, broker_process_);
196 case __NR_setpriority:
197 return sandbox::RestrictGetSetpriority(GetPolicyPid());
198 case __NR_sched_getaffinity:
199 case __NR_sched_setaffinity:
200 return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno);
198 default: 201 default:
199 if (SyscallSets::IsEventFd(sysno)) 202 if (SyscallSets::IsEventFd(sysno))
200 return Allow(); 203 return Allow();
201 204
202 // Default on the baseline policy. 205 // Default on the baseline policy.
203 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); 206 return SandboxBPFBasePolicy::EvaluateSyscall(sysno);
204 } 207 }
205 } 208 }
206 209
207 bool GpuProcessPolicy::PreSandboxHook() { 210 bool GpuProcessPolicy::PreSandboxHook() {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 broker_process_ = new BrokerProcess(GetFSDeniedErrno(), 270 broker_process_ = new BrokerProcess(GetFSDeniedErrno(),
268 read_whitelist, 271 read_whitelist,
269 write_whitelist); 272 write_whitelist);
270 // The initialization callback will perform generic initialization and then 273 // The initialization callback will perform generic initialization and then
271 // call broker_sandboxer_callback. 274 // call broker_sandboxer_callback.
272 CHECK(broker_process_->Init(base::Bind(&UpdateProcessTypeAndEnableSandbox, 275 CHECK(broker_process_->Init(base::Bind(&UpdateProcessTypeAndEnableSandbox,
273 broker_sandboxer_allocator))); 276 broker_sandboxer_allocator)));
274 } 277 }
275 278
276 } // namespace content 279 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/sandbox_linux/bpf_ppapi_policy_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698