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

Side by Side Diff: components/nacl/loader/nonsfi/nonsfi_sandbox.cc

Issue 298163008: Non-SFI NaCl: Allow CLOCK_SYSTEM_TRACE on Chrome OS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment update Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « base/time/time_posix.cc ('k') | components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/nacl/loader/nonsfi/nonsfi_sandbox.h" 5 #include "components/nacl/loader/nonsfi/nonsfi_sandbox.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <linux/net.h> 9 #include <linux/net.h>
10 #include <sys/prctl.h> 10 #include <sys/prctl.h>
11 #include <sys/ptrace.h> 11 #include <sys/ptrace.h>
12 #include <sys/mman.h> 12 #include <sys/mman.h>
13 #include <sys/socket.h> 13 #include <sys/socket.h>
14 #include <sys/syscall.h> 14 #include <sys/syscall.h>
15 15
16 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/time/time.h"
18 #include "build/build_config.h" 19 #include "build/build_config.h"
19 #include "content/public/common/sandbox_init.h" 20 #include "content/public/common/sandbox_init.h"
20 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" 21 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h"
21 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" 22 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
22 #include "sandbox/linux/seccomp-bpf/sandbox_bpf_policy.h" 23 #include "sandbox/linux/seccomp-bpf/sandbox_bpf_policy.h"
23 #include "sandbox/linux/seccomp-bpf/trap.h" 24 #include "sandbox/linux/seccomp-bpf/trap.h"
24 #include "sandbox/linux/services/linux_syscalls.h" 25 #include "sandbox/linux/services/linux_syscalls.h"
25 26
26 #if defined(__arm__) && !defined(MAP_STACK) 27 #if defined(__arm__) && !defined(MAP_STACK)
27 // Chrome OS Daisy (ARM) build environment has old headers. 28 // Chrome OS Daisy (ARM) build environment has old headers.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 sb->Trap(sandbox::CrashSIGSYS_Handler, NULL)))); 74 sb->Trap(sandbox::CrashSIGSYS_Handler, NULL))));
74 } 75 }
75 76
76 ErrorCode RestrictClockID(SandboxBPF* sb) { 77 ErrorCode RestrictClockID(SandboxBPF* sb) {
77 // We allow accessing only CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID, 78 // We allow accessing only CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID,
78 // CLOCK_REALTIME, and CLOCK_THREAD_CPUTIME_ID. In particular, this disallows 79 // CLOCK_REALTIME, and CLOCK_THREAD_CPUTIME_ID. In particular, this disallows
79 // access to arbitrary per-{process,thread} CPU-time clock IDs (such as those 80 // access to arbitrary per-{process,thread} CPU-time clock IDs (such as those
80 // returned by {clock,pthread}_getcpuclockid), which can leak information 81 // returned by {clock,pthread}_getcpuclockid), which can leak information
81 // about the state of the host OS. 82 // about the state of the host OS.
82 COMPILE_ASSERT(4 == sizeof(clockid_t), clockid_is_not_32bit); 83 COMPILE_ASSERT(4 == sizeof(clockid_t), clockid_is_not_32bit);
83 return sb->Cond(0, ErrorCode::TP_32BIT, 84 ErrorCode result = sb->Cond(0, ErrorCode::TP_32BIT,
84 ErrorCode::OP_EQUAL, CLOCK_MONOTONIC, 85 ErrorCode::OP_EQUAL, CLOCK_MONOTONIC,
85 ErrorCode(ErrorCode::ERR_ALLOWED), 86 ErrorCode(ErrorCode::ERR_ALLOWED),
86 sb->Cond(0, ErrorCode::TP_32BIT, 87 sb->Cond(0, ErrorCode::TP_32BIT,
87 ErrorCode::OP_EQUAL, CLOCK_PROCESS_CPUTIME_ID, 88 ErrorCode::OP_EQUAL, CLOCK_PROCESS_CPUTIME_ID,
88 ErrorCode(ErrorCode::ERR_ALLOWED), 89 ErrorCode(ErrorCode::ERR_ALLOWED),
89 sb->Cond(0, ErrorCode::TP_32BIT, 90 sb->Cond(0, ErrorCode::TP_32BIT,
90 ErrorCode::OP_EQUAL, CLOCK_REALTIME, 91 ErrorCode::OP_EQUAL, CLOCK_REALTIME,
91 ErrorCode(ErrorCode::ERR_ALLOWED), 92 ErrorCode(ErrorCode::ERR_ALLOWED),
92 sb->Cond(0, ErrorCode::TP_32BIT, 93 sb->Cond(0, ErrorCode::TP_32BIT,
93 ErrorCode::OP_EQUAL, CLOCK_THREAD_CPUTIME_ID, 94 ErrorCode::OP_EQUAL, CLOCK_THREAD_CPUTIME_ID,
94 ErrorCode(ErrorCode::ERR_ALLOWED), 95 ErrorCode(ErrorCode::ERR_ALLOWED),
95 sb->Trap(sandbox::CrashSIGSYS_Handler, NULL))))); 96 sb->Trap(sandbox::CrashSIGSYS_Handler, NULL)))));
97 #if defined(OS_CHROMEOS)
98 // Allow the special clock for Chrome OS used by Chrome tracing.
99 result = sb->Cond(0, ErrorCode::TP_32BIT,
100 ErrorCode::OP_EQUAL, base::TimeTicks::kClockSystemTrace,
101 ErrorCode(ErrorCode::ERR_ALLOWED), result);
102 #endif
103 return result;
96 } 104 }
97 105
98 ErrorCode RestrictClone(SandboxBPF* sb) { 106 ErrorCode RestrictClone(SandboxBPF* sb) {
99 // We allow clone only for new thread creation. 107 // We allow clone only for new thread creation.
100 return sb->Cond(0, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, 108 return sb->Cond(0, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL,
101 CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | 109 CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
102 CLONE_THREAD | CLONE_SYSVSEM | CLONE_SETTLS | 110 CLONE_THREAD | CLONE_SYSVSEM | CLONE_SETTLS |
103 CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID, 111 CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID,
104 ErrorCode(ErrorCode::ERR_ALLOWED), 112 ErrorCode(ErrorCode::ERR_ALLOWED),
105 sb->Trap(sandbox::SIGSYSCloneFailure, NULL)); 113 sb->Trap(sandbox::SIGSYSCloneFailure, NULL));
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 scoped_ptr<sandbox::SandboxBPFPolicy>( 341 scoped_ptr<sandbox::SandboxBPFPolicy>(
334 new nacl::nonsfi::NaClNonSfiBPFSandboxPolicy())); 342 new nacl::nonsfi::NaClNonSfiBPFSandboxPolicy()));
335 if (!sandbox_is_initialized) 343 if (!sandbox_is_initialized)
336 return false; 344 return false;
337 RunSandboxSanityChecks(); 345 RunSandboxSanityChecks();
338 return true; 346 return true;
339 } 347 }
340 348
341 } // namespace nonsfi 349 } // namespace nonsfi
342 } // namespace nacl 350 } // namespace nacl
OLDNEW
« no previous file with comments | « base/time/time_posix.cc ('k') | components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698