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

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

Issue 794683005: replace COMPILE_ASSERT with static_assert in components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: formatting fixup Created 5 years, 12 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
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/futex.h> 9 #include <linux/futex.h>
10 #include <linux/net.h> 10 #include <linux/net.h>
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // so we do not need to allow PROT_EXEC in mmap. 125 // so we do not need to allow PROT_EXEC in mmap.
126 const uint64_t kAllowedProtMask = PROT_READ | PROT_WRITE; 126 const uint64_t kAllowedProtMask = PROT_READ | PROT_WRITE;
127 const Arg<int> prot(2), flags(3); 127 const Arg<int> prot(2), flags(3);
128 return If((prot & ~kAllowedProtMask) == 0 && (flags & ~kAllowedFlagMask) == 0, 128 return If((prot & ~kAllowedProtMask) == 0 && (flags & ~kAllowedFlagMask) == 0,
129 Allow()).Else(CrashSIGSYS()); 129 Allow()).Else(CrashSIGSYS());
130 } 130 }
131 131
132 #if defined(__x86_64__) || defined(__arm__) 132 #if defined(__x86_64__) || defined(__arm__)
133 ResultExpr RestrictSocketpair() { 133 ResultExpr RestrictSocketpair() {
134 // Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen. 134 // Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen.
135 COMPILE_ASSERT(AF_UNIX == PF_UNIX, af_unix_pf_unix_different); 135 static_assert(AF_UNIX == PF_UNIX, "AF_UNIX must equal PF_UNIX.");
136 const Arg<int> domain(0); 136 const Arg<int> domain(0);
137 return If(domain == AF_UNIX, Allow()).Else(CrashSIGSYS()); 137 return If(domain == AF_UNIX, Allow()).Else(CrashSIGSYS());
138 } 138 }
139 #endif 139 #endif
140 140
141 bool IsGracefullyDenied(int sysno) { 141 bool IsGracefullyDenied(int sysno) {
142 switch (sysno) { 142 switch (sysno) {
143 // libevent tries this first and then falls back to poll if 143 // libevent tries this first and then falls back to poll if
144 // epoll_create fails. 144 // epoll_create fails.
145 case __NR_epoll_create: 145 case __NR_epoll_create:
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 new nacl::nonsfi::NaClNonSfiBPFSandboxPolicy()), 306 new nacl::nonsfi::NaClNonSfiBPFSandboxPolicy()),
307 proc_task_fd.Pass()); 307 proc_task_fd.Pass());
308 if (!sandbox_is_initialized) 308 if (!sandbox_is_initialized)
309 return false; 309 return false;
310 RunSandboxSanityChecks(); 310 RunSandboxSanityChecks();
311 return true; 311 return true;
312 } 312 }
313 313
314 } // namespace nonsfi 314 } // namespace nonsfi
315 } // namespace nacl 315 } // namespace nacl
OLDNEW
« no previous file with comments | « components/nacl/loader/nacl_ipc_adapter.cc ('k') | components/navigation_metrics/navigation_metrics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698