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

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

Issue 313053004: Revert "Non-SFI NaCl: Allow CLOCK_SYSTEM_TRACE on Chrome OS" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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"
19 #include "build/build_config.h" 18 #include "build/build_config.h"
20 #include "content/public/common/sandbox_init.h" 19 #include "content/public/common/sandbox_init.h"
21 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" 20 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h"
22 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" 21 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
23 #include "sandbox/linux/seccomp-bpf/sandbox_bpf_policy.h" 22 #include "sandbox/linux/seccomp-bpf/sandbox_bpf_policy.h"
24 #include "sandbox/linux/seccomp-bpf/trap.h" 23 #include "sandbox/linux/seccomp-bpf/trap.h"
25 #include "sandbox/linux/services/linux_syscalls.h" 24 #include "sandbox/linux/services/linux_syscalls.h"
26 25
27 #if defined(__arm__) && !defined(MAP_STACK) 26 #if defined(__arm__) && !defined(MAP_STACK)
28 // Chrome OS Daisy (ARM) build environment has old headers. 27 // Chrome OS Daisy (ARM) build environment has old headers.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 sb->Trap(sandbox::CrashSIGSYS_Handler, NULL)))); 73 sb->Trap(sandbox::CrashSIGSYS_Handler, NULL))));
75 } 74 }
76 75
77 ErrorCode RestrictClockID(SandboxBPF* sb) { 76 ErrorCode RestrictClockID(SandboxBPF* sb) {
78 // We allow accessing only CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID, 77 // We allow accessing only CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID,
79 // CLOCK_REALTIME, and CLOCK_THREAD_CPUTIME_ID. In particular, this disallows 78 // CLOCK_REALTIME, and CLOCK_THREAD_CPUTIME_ID. In particular, this disallows
80 // access to arbitrary per-{process,thread} CPU-time clock IDs (such as those 79 // access to arbitrary per-{process,thread} CPU-time clock IDs (such as those
81 // returned by {clock,pthread}_getcpuclockid), which can leak information 80 // returned by {clock,pthread}_getcpuclockid), which can leak information
82 // about the state of the host OS. 81 // about the state of the host OS.
83 COMPILE_ASSERT(4 == sizeof(clockid_t), clockid_is_not_32bit); 82 COMPILE_ASSERT(4 == sizeof(clockid_t), clockid_is_not_32bit);
84 ErrorCode result = sb->Cond(0, ErrorCode::TP_32BIT, 83 return sb->Cond(0, ErrorCode::TP_32BIT,
85 ErrorCode::OP_EQUAL, CLOCK_MONOTONIC, 84 ErrorCode::OP_EQUAL, CLOCK_MONOTONIC,
86 ErrorCode(ErrorCode::ERR_ALLOWED), 85 ErrorCode(ErrorCode::ERR_ALLOWED),
87 sb->Cond(0, ErrorCode::TP_32BIT, 86 sb->Cond(0, ErrorCode::TP_32BIT,
88 ErrorCode::OP_EQUAL, CLOCK_PROCESS_CPUTIME_ID, 87 ErrorCode::OP_EQUAL, CLOCK_PROCESS_CPUTIME_ID,
89 ErrorCode(ErrorCode::ERR_ALLOWED), 88 ErrorCode(ErrorCode::ERR_ALLOWED),
90 sb->Cond(0, ErrorCode::TP_32BIT, 89 sb->Cond(0, ErrorCode::TP_32BIT,
91 ErrorCode::OP_EQUAL, CLOCK_REALTIME, 90 ErrorCode::OP_EQUAL, CLOCK_REALTIME,
92 ErrorCode(ErrorCode::ERR_ALLOWED), 91 ErrorCode(ErrorCode::ERR_ALLOWED),
93 sb->Cond(0, ErrorCode::TP_32BIT, 92 sb->Cond(0, ErrorCode::TP_32BIT,
94 ErrorCode::OP_EQUAL, CLOCK_THREAD_CPUTIME_ID, 93 ErrorCode::OP_EQUAL, CLOCK_THREAD_CPUTIME_ID,
95 ErrorCode(ErrorCode::ERR_ALLOWED), 94 ErrorCode(ErrorCode::ERR_ALLOWED),
96 sb->Trap(sandbox::CrashSIGSYS_Handler, NULL))))); 95 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;
104 } 96 }
105 97
106 ErrorCode RestrictClone(SandboxBPF* sb) { 98 ErrorCode RestrictClone(SandboxBPF* sb) {
107 // We allow clone only for new thread creation. 99 // We allow clone only for new thread creation.
108 return sb->Cond(0, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, 100 return sb->Cond(0, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL,
109 CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | 101 CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
110 CLONE_THREAD | CLONE_SYSVSEM | CLONE_SETTLS | 102 CLONE_THREAD | CLONE_SYSVSEM | CLONE_SETTLS |
111 CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID, 103 CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID,
112 ErrorCode(ErrorCode::ERR_ALLOWED), 104 ErrorCode(ErrorCode::ERR_ALLOWED),
113 sb->Trap(sandbox::SIGSYSCloneFailure, NULL)); 105 sb->Trap(sandbox::SIGSYSCloneFailure, NULL));
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 scoped_ptr<sandbox::SandboxBPFPolicy>( 333 scoped_ptr<sandbox::SandboxBPFPolicy>(
342 new nacl::nonsfi::NaClNonSfiBPFSandboxPolicy())); 334 new nacl::nonsfi::NaClNonSfiBPFSandboxPolicy()));
343 if (!sandbox_is_initialized) 335 if (!sandbox_is_initialized)
344 return false; 336 return false;
345 RunSandboxSanityChecks(); 337 RunSandboxSanityChecks();
346 return true; 338 return true;
347 } 339 }
348 340
349 } // namespace nonsfi 341 } // namespace nonsfi
350 } // namespace nacl 342 } // 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