OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <asm/unistd.h> | 5 #include <asm/unistd.h> |
6 #include <dlfcn.h> | 6 #include <dlfcn.h> |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <linux/audit.h> | 9 #include <linux/audit.h> |
10 #include <linux/filter.h> | 10 #include <linux/filter.h> |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 *addr = '\0'; | 94 *addr = '\0'; |
95 // In case we hit a mapped address, hit the null page with just the syscall, | 95 // In case we hit a mapped address, hit the null page with just the syscall, |
96 // for paranoia. | 96 // for paranoia. |
97 syscall &= 0xfffUL; | 97 syscall &= 0xfffUL; |
98 addr = reinterpret_cast<volatile char*>(syscall); | 98 addr = reinterpret_cast<volatile char*>(syscall); |
99 *addr = '\0'; | 99 *addr = '\0'; |
100 for (;;) | 100 for (;;) |
101 _exit(1); | 101 _exit(1); |
102 } | 102 } |
103 | 103 |
104 // TODO(jln): rewrite reporting functions. | |
105 intptr_t ReportCloneFailure(const struct arch_seccomp_data& args, void* aux) { | |
106 // "flags" in the first argument in the kernel's clone(). | |
107 // Mark as volatile to be able to find the value on the stack in a minidump. | |
108 volatile uint64_t clone_flags = args.args[0]; | |
109 volatile char* addr = | |
110 reinterpret_cast<volatile char*>(clone_flags & 0xFFFFFF); | |
111 *addr = '\0'; | |
112 // Hit the NULL page if this fails. | |
Chris Evans
2013/02/06 03:44:54
Nit: "fails to fault"?
jln (very slow on Chromium)
2013/02/06 04:00:51
Done.
| |
113 addr = reinterpret_cast<volatile char*>(clone_flags & 0xFFF); | |
114 *addr = '\0'; | |
115 for (;;) | |
116 _exit(1); | |
117 } | |
118 | |
104 bool IsAcceleratedVideoDecodeEnabled() { | 119 bool IsAcceleratedVideoDecodeEnabled() { |
105 // Accelerated video decode is currently enabled on Chrome OS, | 120 // Accelerated video decode is currently enabled on Chrome OS, |
106 // but not on Linux: crbug.com/137247. | 121 // but not on Linux: crbug.com/137247. |
107 bool is_enabled = IsChromeOS(); | 122 bool is_enabled = IsChromeOS(); |
108 | 123 |
109 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 124 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
110 is_enabled = is_enabled && | 125 is_enabled = is_enabled && |
111 !command_line.HasSwitch(switches::kDisableAcceleratedVideoDecode); | 126 !command_line.HasSwitch(switches::kDisableAcceleratedVideoDecode); |
112 | 127 |
113 return is_enabled; | 128 return is_enabled; |
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1229 ErrorCode GpuBrokerProcessPolicy(int sysno, void*) { | 1244 ErrorCode GpuBrokerProcessPolicy(int sysno, void*) { |
1230 switch(sysno) { | 1245 switch(sysno) { |
1231 case __NR_open: | 1246 case __NR_open: |
1232 case __NR_openat: | 1247 case __NR_openat: |
1233 return ErrorCode(ErrorCode::ERR_ALLOWED); | 1248 return ErrorCode(ErrorCode::ERR_ALLOWED); |
1234 default: | 1249 default: |
1235 return GpuProcessPolicy(sysno, NULL); | 1250 return GpuProcessPolicy(sysno, NULL); |
1236 } | 1251 } |
1237 } | 1252 } |
1238 | 1253 |
1254 // Allow clone for threads, crash if anything else is attempted. | |
1255 ErrorCode RestrictCloneToThreads() { | |
1256 // Glibc's pthread. | |
1257 return Sandbox::Cond(0, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, | |
1258 CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | | |
1259 CLONE_THREAD | CLONE_SYSVSEM | CLONE_SETTLS | | |
1260 CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID, | |
1261 ErrorCode(ErrorCode::ERR_ALLOWED), | |
1262 Sandbox::Trap(ReportCloneFailure, NULL)); | |
1263 } | |
1264 | |
1239 ErrorCode RendererOrWorkerProcessPolicy(int sysno, void *) { | 1265 ErrorCode RendererOrWorkerProcessPolicy(int sysno, void *) { |
1240 switch (sysno) { | 1266 switch (sysno) { |
1267 case __NR_clone: | |
1268 #if defined(__x86_64__) | |
Chris Evans
2013/02/06 03:44:54
Nit: add TODO(jln) for other platforms?
| |
1269 return RestrictCloneToThreads(); | |
1270 #endif | |
1241 case __NR_ioctl: // TODO(jln) investigate legitimate use in the renderer | 1271 case __NR_ioctl: // TODO(jln) investigate legitimate use in the renderer |
1242 // and see if alternatives can be used. | 1272 // and see if alternatives can be used. |
1243 case __NR_fdatasync: | 1273 case __NR_fdatasync: |
1244 case __NR_fsync: | 1274 case __NR_fsync: |
1245 #if defined(__i386__) || defined(__x86_64__) | 1275 #if defined(__i386__) || defined(__x86_64__) |
1246 case __NR_getrlimit: | 1276 case __NR_getrlimit: |
1247 #endif | 1277 #endif |
1248 case __NR_mremap: // See crbug.com/149834. | 1278 case __NR_mremap: // See crbug.com/149834. |
1249 case __NR_pread64: | 1279 case __NR_pread64: |
1250 case __NR_pwrite64: | 1280 case __NR_pwrite64: |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1493 // should enable it, enable it or die. | 1523 // should enable it, enable it or die. |
1494 bool started_sandbox = StartBpfSandbox(command_line, process_type); | 1524 bool started_sandbox = StartBpfSandbox(command_line, process_type); |
1495 CHECK(started_sandbox); | 1525 CHECK(started_sandbox); |
1496 return true; | 1526 return true; |
1497 } | 1527 } |
1498 #endif | 1528 #endif |
1499 return false; | 1529 return false; |
1500 } | 1530 } |
1501 | 1531 |
1502 } // namespace content | 1532 } // namespace content |
OLD | NEW |