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

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

Issue 255993002: Cleanup: Mark a function as x86-64 / ARM only. Found by clang. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 8 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 | « no previous file | no next file » | 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>
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 const uint32_t denied_flag_mask = ~(MAP_SHARED | MAP_PRIVATE | 125 const uint32_t denied_flag_mask = ~(MAP_SHARED | MAP_PRIVATE |
126 MAP_ANONYMOUS | MAP_STACK | MAP_FIXED); 126 MAP_ANONYMOUS | MAP_STACK | MAP_FIXED);
127 // TODO(hamaji): Disallow RWX mmap. 127 // TODO(hamaji): Disallow RWX mmap.
128 return sb->Cond(3, ErrorCode::TP_32BIT, 128 return sb->Cond(3, ErrorCode::TP_32BIT,
129 ErrorCode::OP_HAS_ANY_BITS, 129 ErrorCode::OP_HAS_ANY_BITS,
130 denied_flag_mask, 130 denied_flag_mask,
131 sb->Trap(sandbox::CrashSIGSYS_Handler, NULL), 131 sb->Trap(sandbox::CrashSIGSYS_Handler, NULL),
132 RestrictMemoryProtection(sb, 2)); 132 RestrictMemoryProtection(sb, 2));
133 } 133 }
134 134
135 #if defined(__x86_64__) || defined(__arm__)
135 ErrorCode RestrictSocketpair(SandboxBPF* sb) { 136 ErrorCode RestrictSocketpair(SandboxBPF* sb) {
136 // Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen. 137 // Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen.
137 COMPILE_ASSERT(AF_UNIX == PF_UNIX, af_unix_pf_unix_different); 138 COMPILE_ASSERT(AF_UNIX == PF_UNIX, af_unix_pf_unix_different);
138 return sb->Cond(0, ErrorCode::TP_32BIT, 139 return sb->Cond(0, ErrorCode::TP_32BIT,
139 ErrorCode::OP_EQUAL, AF_UNIX, 140 ErrorCode::OP_EQUAL, AF_UNIX,
140 ErrorCode(ErrorCode::ERR_ALLOWED), 141 ErrorCode(ErrorCode::ERR_ALLOWED),
141 sb->Trap(sandbox::CrashSIGSYS_Handler, NULL)); 142 sb->Trap(sandbox::CrashSIGSYS_Handler, NULL));
142 } 143 }
144 #endif
143 145
144 bool IsGracefullyDenied(int sysno) { 146 bool IsGracefullyDenied(int sysno) {
145 switch (sysno) { 147 switch (sysno) {
146 // libevent tries this first and then falls back to poll if 148 // libevent tries this first and then falls back to poll if
147 // epoll_create fails. 149 // epoll_create fails.
148 case __NR_epoll_create: 150 case __NR_epoll_create:
149 // third_party/libevent uses them, but we can just return -1 from 151 // third_party/libevent uses them, but we can just return -1 from
150 // them as it is just checking getuid() != geteuid() and 152 // them as it is just checking getuid() != geteuid() and
151 // getgid() != getegid() 153 // getgid() != getegid()
152 #if defined(__i386__) || defined(__arm__) 154 #if defined(__i386__) || defined(__arm__)
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 scoped_ptr<sandbox::SandboxBPFPolicy>( 309 scoped_ptr<sandbox::SandboxBPFPolicy>(
308 new nacl::nonsfi::NaClNonSfiBPFSandboxPolicy())); 310 new nacl::nonsfi::NaClNonSfiBPFSandboxPolicy()));
309 if (!sandbox_is_initialized) 311 if (!sandbox_is_initialized)
310 return false; 312 return false;
311 RunSandboxSanityChecks(); 313 RunSandboxSanityChecks();
312 return true; 314 return true;
313 } 315 }
314 316
315 } // namespace nonsfi 317 } // namespace nonsfi
316 } // namespace nacl 318 } // namespace nacl
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698