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 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1241 #if defined(__arm__) | 1241 #if defined(__arm__) |
1242 IsArmPciConfig(sysno) || | 1242 IsArmPciConfig(sysno) || |
1243 #endif | 1243 #endif |
1244 IsTimer(sysno)) { | 1244 IsTimer(sysno)) { |
1245 return true; | 1245 return true; |
1246 } else { | 1246 } else { |
1247 return false; | 1247 return false; |
1248 } | 1248 } |
1249 } | 1249 } |
1250 | 1250 |
1251 ErrorCode RestrictMmapFlags(Sandbox *sandbox) { | 1251 ErrorCode RestrictMmapFlags(Sandbox* sandbox) { |
Chris Evans
2013/05/29 19:54:13
There's quite a bit of style cleanup in this patch
| |
1252 // The flags you see are actually the allowed ones, and the variable is a | 1252 // The flags you see are actually the allowed ones, and the variable is a |
1253 // "denied" mask because of the negation operator. | 1253 // "denied" mask because of the negation operator. |
1254 // Significantly, we don't permit MAP_HUGETLB, or the newer flags such as | 1254 // Significantly, we don't permit MAP_HUGETLB, or the newer flags such as |
1255 // MAP_POPULATE. | 1255 // MAP_POPULATE. |
1256 uint32_t denied_mask = ~(MAP_SHARED | MAP_PRIVATE | MAP_ANONYMOUS | | 1256 uint32_t denied_mask = ~(MAP_SHARED | MAP_PRIVATE | MAP_ANONYMOUS | |
1257 MAP_STACK | MAP_NORESERVE | MAP_FIXED); | 1257 MAP_STACK | MAP_NORESERVE | MAP_FIXED); |
1258 return sandbox->Cond(3, ErrorCode::TP_32BIT, ErrorCode::OP_HAS_ANY_BITS, | 1258 return sandbox->Cond(3, ErrorCode::TP_32BIT, ErrorCode::OP_HAS_ANY_BITS, |
1259 denied_mask, | 1259 denied_mask, |
1260 sandbox->Trap(CrashSIGSYS_Handler, NULL), | 1260 sandbox->Trap(CrashSIGSYS_Handler, NULL), |
1261 ErrorCode(ErrorCode::ERR_ALLOWED)); | 1261 ErrorCode(ErrorCode::ERR_ALLOWED)); |
1262 } | 1262 } |
1263 | 1263 |
1264 ErrorCode RestrictMprotectFlags(Sandbox *sandbox) { | 1264 ErrorCode RestrictMprotectFlags(Sandbox* sandbox) { |
1265 // The flags you see are actually the allowed ones, and the variable is a | 1265 // The flags you see are actually the allowed ones, and the variable is a |
1266 // "denied" mask because of the negation operator. | 1266 // "denied" mask because of the negation operator. |
1267 // Significantly, we don't permit weird undocumented flags such as | 1267 // Significantly, we don't permit weird undocumented flags such as |
1268 // PROT_GROWSDOWN. | 1268 // PROT_GROWSDOWN. |
1269 uint32_t denied_mask = ~(PROT_READ | PROT_WRITE | PROT_EXEC); | 1269 uint32_t denied_mask = ~(PROT_READ | PROT_WRITE | PROT_EXEC); |
1270 return sandbox->Cond(2, ErrorCode::TP_32BIT, ErrorCode::OP_HAS_ANY_BITS, | 1270 return sandbox->Cond(2, ErrorCode::TP_32BIT, ErrorCode::OP_HAS_ANY_BITS, |
1271 denied_mask, | 1271 denied_mask, |
1272 sandbox->Trap(CrashSIGSYS_Handler, NULL), | 1272 sandbox->Trap(CrashSIGSYS_Handler, NULL), |
1273 ErrorCode(ErrorCode::ERR_ALLOWED)); | 1273 ErrorCode(ErrorCode::ERR_ALLOWED)); |
1274 } | 1274 } |
1275 | 1275 |
1276 ErrorCode RestrictFcntlCommands(Sandbox *sandbox) { | 1276 ErrorCode RestrictFcntlCommands(Sandbox* sandbox) { |
1277 // For now, we're only sure this will work on x64. This is because of the | 1277 // For now, we're only sure this will work on x64. This is because of the |
1278 // use of TP_64BIT for a "long" argument. Ideally, the seccomp API would | 1278 // use of TP_64BIT for a "long" argument. Ideally, the seccomp API would |
1279 // have a TP_LONG or TP_SIZET type. | 1279 // have a TP_LONG or TP_SIZET type. |
1280 DCHECK(IsArchitectureX86_64()); | 1280 DCHECK(IsArchitectureX86_64()); |
1281 // We allow F_GETFL, F_SETFL, F_GETFD, F_SETFD, F_DUPFD, F_DUPFD_CLOEXEC, | 1281 // We allow F_GETFL, F_SETFL, F_GETFD, F_SETFD, F_DUPFD, F_DUPFD_CLOEXEC, |
1282 // F_SETLK, F_SETLKW and F_GETLK. | 1282 // F_SETLK, F_SETLKW and F_GETLK. |
1283 // We also restrict the flags in F_SETFL. We don't want to permit flags with | 1283 // We also restrict the flags in F_SETFL. We don't want to permit flags with |
1284 // a history of trouble such as O_DIRECT. The flags you see are actually the | 1284 // a history of trouble such as O_DIRECT. The flags you see are actually the |
1285 // allowed ones, and the variable is a "denied" mask because of the negation | 1285 // allowed ones, and the variable is a "denied" mask because of the negation |
1286 // operator. | 1286 // operator. |
(...skipping 30 matching lines...) Expand all Loading... | |
1317 ErrorCode(ErrorCode::ERR_ALLOWED), | 1317 ErrorCode(ErrorCode::ERR_ALLOWED), |
1318 sandbox->Cond(1, ErrorCode::TP_32BIT, | 1318 sandbox->Cond(1, ErrorCode::TP_32BIT, |
1319 ErrorCode::OP_EQUAL, F_GETLK, | 1319 ErrorCode::OP_EQUAL, F_GETLK, |
1320 ErrorCode(ErrorCode::ERR_ALLOWED), | 1320 ErrorCode(ErrorCode::ERR_ALLOWED), |
1321 sandbox->Cond(1, ErrorCode::TP_32BIT, | 1321 sandbox->Cond(1, ErrorCode::TP_32BIT, |
1322 ErrorCode::OP_EQUAL, F_DUPFD_CLOEXEC, | 1322 ErrorCode::OP_EQUAL, F_DUPFD_CLOEXEC, |
1323 ErrorCode(ErrorCode::ERR_ALLOWED), | 1323 ErrorCode(ErrorCode::ERR_ALLOWED), |
1324 sandbox->Trap(CrashSIGSYS_Handler, NULL)))))))))); | 1324 sandbox->Trap(CrashSIGSYS_Handler, NULL)))))))))); |
1325 } | 1325 } |
1326 | 1326 |
1327 ErrorCode BaselinePolicy(Sandbox *sandbox, int sysno) { | 1327 ErrorCode BaselinePolicy(Sandbox* sandbox, int sysno) { |
1328 if (IsBaselinePolicyAllowed(sysno)) { | 1328 if (IsBaselinePolicyAllowed(sysno)) { |
1329 return ErrorCode(ErrorCode::ERR_ALLOWED); | 1329 return ErrorCode(ErrorCode::ERR_ALLOWED); |
1330 } | 1330 } |
1331 | 1331 |
1332 #if defined(__i386__) | 1332 #if defined(__i386__) |
1333 // socketcall(2) should be tightened. | 1333 // socketcall(2) should be tightened. |
1334 if (IsSocketCall(sysno)) { | 1334 if (IsSocketCall(sysno)) { |
1335 return ErrorCode(ErrorCode::ERR_ALLOWED); | 1335 return ErrorCode(ErrorCode::ERR_ALLOWED); |
1336 } | 1336 } |
1337 #endif | 1337 #endif |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1401 if (IsBaselinePolicyWatched(sysno)) { | 1401 if (IsBaselinePolicyWatched(sysno)) { |
1402 // Previously unseen syscalls. TODO(jln): some of these should | 1402 // Previously unseen syscalls. TODO(jln): some of these should |
1403 // be denied gracefully right away. | 1403 // be denied gracefully right away. |
1404 return sandbox->Trap(CrashSIGSYS_Handler, NULL); | 1404 return sandbox->Trap(CrashSIGSYS_Handler, NULL); |
1405 } | 1405 } |
1406 // In any other case crash the program with our SIGSYS handler. | 1406 // In any other case crash the program with our SIGSYS handler. |
1407 return sandbox->Trap(CrashSIGSYS_Handler, NULL); | 1407 return sandbox->Trap(CrashSIGSYS_Handler, NULL); |
1408 } | 1408 } |
1409 | 1409 |
1410 // Main policy for x86_64/i386. Extended by ArmMaliGpuProcessPolicy. | 1410 // Main policy for x86_64/i386. Extended by ArmMaliGpuProcessPolicy. |
1411 ErrorCode GpuProcessPolicy(Sandbox *sandbox, int sysno, | 1411 ErrorCode GpuProcessPolicy(Sandbox* sandbox, int sysno, |
1412 void *broker_process) { | 1412 void* broker_process) { |
1413 switch(sysno) { | 1413 switch(sysno) { |
1414 case __NR_ioctl: | 1414 case __NR_ioctl: |
1415 #if defined(__i386__) || defined(__x86_64__) | 1415 #if defined(__i386__) || defined(__x86_64__) |
1416 // The Nvidia driver uses flags not in the baseline policy | 1416 // The Nvidia driver uses flags not in the baseline policy |
1417 // (MAP_LOCKED | MAP_EXECUTABLE | MAP_32BIT) | 1417 // (MAP_LOCKED | MAP_EXECUTABLE | MAP_32BIT) |
1418 case __NR_mmap: | 1418 case __NR_mmap: |
1419 #endif | 1419 #endif |
1420 // We also hit this on the linux_chromeos bot but don't yet know what | 1420 // We also hit this on the linux_chromeos bot but don't yet know what |
1421 // weird flags were involved. | 1421 // weird flags were involved. |
1422 case __NR_mprotect: | 1422 case __NR_mprotect: |
(...skipping 14 matching lines...) Expand all Loading... | |
1437 return ErrorCode(ErrorCode::ERR_ALLOWED); | 1437 return ErrorCode(ErrorCode::ERR_ALLOWED); |
1438 | 1438 |
1439 // Default on the baseline policy. | 1439 // Default on the baseline policy. |
1440 return BaselinePolicy(sandbox, sysno); | 1440 return BaselinePolicy(sandbox, sysno); |
1441 } | 1441 } |
1442 } | 1442 } |
1443 | 1443 |
1444 // x86_64/i386. | 1444 // x86_64/i386. |
1445 // A GPU broker policy is the same as a GPU policy with open and | 1445 // A GPU broker policy is the same as a GPU policy with open and |
1446 // openat allowed. | 1446 // openat allowed. |
1447 ErrorCode GpuBrokerProcessPolicy(Sandbox *sandbox, int sysno, void *aux) { | 1447 ErrorCode GpuBrokerProcessPolicy(Sandbox* sandbox, int sysno, void* aux) { |
1448 // "aux" would typically be NULL, when called from | 1448 // "aux" would typically be NULL, when called from |
1449 // "EnableGpuBrokerPolicyCallBack" | 1449 // "EnableGpuBrokerPolicyCallBack" |
1450 switch(sysno) { | 1450 switch(sysno) { |
1451 case __NR_access: | 1451 case __NR_access: |
1452 case __NR_open: | 1452 case __NR_open: |
1453 case __NR_openat: | 1453 case __NR_openat: |
1454 return ErrorCode(ErrorCode::ERR_ALLOWED); | 1454 return ErrorCode(ErrorCode::ERR_ALLOWED); |
1455 default: | 1455 default: |
1456 return GpuProcessPolicy(sandbox, sysno, aux); | 1456 return GpuProcessPolicy(sandbox, sysno, aux); |
1457 } | 1457 } |
1458 } | 1458 } |
1459 | 1459 |
1460 // ARM Mali GPU process sandbox, inheriting from GpuProcessPolicy. | 1460 // ARM Mali GPU process sandbox, inheriting from GpuProcessPolicy. |
1461 ErrorCode ArmMaliGpuProcessPolicy(Sandbox *sandbox, int sysno, | 1461 ErrorCode ArmMaliGpuProcessPolicy(Sandbox* sandbox, int sysno, |
1462 void *broker_process) { | 1462 void* broker_process) { |
1463 switch(sysno) { | 1463 switch(sysno) { |
1464 #if defined(__arm__) | 1464 #if defined(__arm__) |
1465 // ARM GPU sandbox is started earlier so we need to allow networking | 1465 // ARM GPU sandbox is started earlier so we need to allow networking |
1466 // in the sandbox. | 1466 // in the sandbox. |
1467 // TODO(jorgelo): tighten this (crbug.com/235609). | 1467 // TODO(jorgelo): tighten this (crbug.com/235609). |
1468 case __NR_connect: | 1468 case __NR_connect: |
1469 case __NR_getpeername: | 1469 case __NR_getpeername: |
1470 case __NR_getsockname: | 1470 case __NR_getsockname: |
1471 case __NR_socket: | 1471 case __NR_socket: |
1472 case __NR_socketpair: | 1472 case __NR_socketpair: |
1473 case __NR_sysinfo: | 1473 case __NR_sysinfo: |
1474 case __NR_uname: | 1474 case __NR_uname: |
1475 return ErrorCode(ErrorCode::ERR_ALLOWED); | 1475 return ErrorCode(ErrorCode::ERR_ALLOWED); |
1476 #endif // defined(__arm__) | 1476 #endif // defined(__arm__) |
1477 default: | 1477 default: |
1478 if (IsAdvancedScheduler(sysno)) | 1478 if (IsAdvancedScheduler(sysno)) |
1479 return ErrorCode(ErrorCode::ERR_ALLOWED); | 1479 return ErrorCode(ErrorCode::ERR_ALLOWED); |
1480 | 1480 |
1481 // Default to the generic GPU policy. | 1481 // Default to the generic GPU policy. |
1482 return GpuProcessPolicy(sandbox, sysno, broker_process); | 1482 return GpuProcessPolicy(sandbox, sysno, broker_process); |
1483 } | 1483 } |
1484 } | 1484 } |
1485 | 1485 |
1486 // A GPU broker policy is the same as a GPU policy with open and | 1486 // A GPU broker policy is the same as a GPU policy with open and |
1487 // openat allowed. | 1487 // openat allowed. |
1488 ErrorCode ArmMaliGpuBrokerProcessPolicy(Sandbox *sandbox, | 1488 ErrorCode ArmMaliGpuBrokerProcessPolicy(Sandbox* sandbox, |
1489 int sysno, void *aux) { | 1489 int sysno, void* aux) { |
1490 // "aux" would typically be NULL, when called from | 1490 // "aux" would typically be NULL, when called from |
1491 // "EnableGpuBrokerPolicyCallBack" | 1491 // "EnableGpuBrokerPolicyCallBack" |
1492 switch(sysno) { | 1492 switch(sysno) { |
1493 case __NR_access: | 1493 case __NR_access: |
1494 case __NR_open: | 1494 case __NR_open: |
1495 case __NR_openat: | 1495 case __NR_openat: |
1496 return ErrorCode(ErrorCode::ERR_ALLOWED); | 1496 return ErrorCode(ErrorCode::ERR_ALLOWED); |
1497 default: | 1497 default: |
1498 return ArmMaliGpuProcessPolicy(sandbox, sysno, aux); | 1498 return ArmMaliGpuProcessPolicy(sandbox, sysno, aux); |
1499 } | 1499 } |
1500 } | 1500 } |
1501 | 1501 |
1502 // Allow clone(2) for threads. | 1502 // Allow clone(2) for threads. |
1503 // Reject fork(2) attempts with EPERM. | 1503 // Reject fork(2) attempts with EPERM. |
1504 // Crash if anything else is attempted. | 1504 // Crash if anything else is attempted. |
1505 // Don't restrict on ASAN. | 1505 // Don't restrict on ASAN. |
1506 ErrorCode RestrictCloneToThreadsAndEPERMFork(Sandbox* sandbox) { | 1506 ErrorCode RestrictCloneToThreadsAndEPERMFork(Sandbox* sandbox) { |
1507 // Glibc's pthread. | 1507 // Glibc's pthread. |
1508 if (!RunningOnASAN()) { | 1508 if (!RunningOnASAN()) { |
1509 return sandbox->Cond(0, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, | 1509 return sandbox->Cond(0, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, |
1510 CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | | 1510 CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | |
1511 CLONE_THREAD | CLONE_SYSVSEM | CLONE_SETTLS | | 1511 CLONE_THREAD | CLONE_SYSVSEM | CLONE_SETTLS | |
1512 CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID, | 1512 CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID, |
1513 ErrorCode(ErrorCode::ERR_ALLOWED), | 1513 ErrorCode(ErrorCode::ERR_ALLOWED), |
1514 sandbox->Cond(0, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, | 1514 sandbox->Cond(0, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, |
1515 CLONE_PARENT_SETTID | SIGCHLD, | 1515 CLONE_PARENT_SETTID | SIGCHLD, |
1516 ErrorCode(EPERM), | 1516 ErrorCode(EPERM), |
1517 sandbox->Trap(SIGSYSCloneFailure, NULL))); | 1517 // ARM |
1518 sandbox->Cond(0, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, | |
1519 CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, | |
1520 ErrorCode(EPERM), | |
1521 sandbox->Trap(SIGSYSCloneFailure, NULL)))); | |
1518 } else { | 1522 } else { |
1519 return ErrorCode(ErrorCode::ERR_ALLOWED); | 1523 return ErrorCode(ErrorCode::ERR_ALLOWED); |
1520 } | 1524 } |
1521 } | 1525 } |
1522 | 1526 |
1523 ErrorCode RestrictPrctl(Sandbox *sandbox) { | 1527 ErrorCode RestrictPrctl(Sandbox* sandbox) { |
1524 // Allow PR_SET_NAME, PR_SET_DUMPABLE, PR_GET_DUMPABLE. Will need to add | 1528 // Allow PR_SET_NAME, PR_SET_DUMPABLE, PR_GET_DUMPABLE. Will need to add |
1525 // seccomp compositing in the future. | 1529 // seccomp compositing in the future. |
1526 // PR_SET_PTRACER is used by breakpad but not needed anymore. | 1530 // PR_SET_PTRACER is used by breakpad but not needed anymore. |
1527 return sandbox->Cond(0, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, | 1531 return sandbox->Cond(0, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, |
1528 PR_SET_NAME, ErrorCode(ErrorCode::ERR_ALLOWED), | 1532 PR_SET_NAME, ErrorCode(ErrorCode::ERR_ALLOWED), |
1529 sandbox->Cond(0, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, | 1533 sandbox->Cond(0, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, |
1530 PR_SET_DUMPABLE, ErrorCode(ErrorCode::ERR_ALLOWED), | 1534 PR_SET_DUMPABLE, ErrorCode(ErrorCode::ERR_ALLOWED), |
1531 sandbox->Cond(0, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, | 1535 sandbox->Cond(0, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, |
1532 PR_GET_DUMPABLE, ErrorCode(ErrorCode::ERR_ALLOWED), | 1536 PR_GET_DUMPABLE, ErrorCode(ErrorCode::ERR_ALLOWED), |
1533 sandbox->Trap(SIGSYSPrctlFailure, NULL)))); | 1537 sandbox->Trap(SIGSYSPrctlFailure, NULL)))); |
1534 } | 1538 } |
1535 | 1539 |
1536 ErrorCode RestrictIoctl(Sandbox *sandbox) { | 1540 ErrorCode RestrictIoctl(Sandbox* sandbox) { |
1537 // Allow TCGETS and FIONREAD, trap to SIGSYSIoctlFailure otherwise. | 1541 // Allow TCGETS and FIONREAD, trap to SIGSYSIoctlFailure otherwise. |
1538 return sandbox->Cond(1, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, TCGETS, | 1542 return sandbox->Cond(1, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, TCGETS, |
1539 ErrorCode(ErrorCode::ERR_ALLOWED), | 1543 ErrorCode(ErrorCode::ERR_ALLOWED), |
1540 sandbox->Cond(1, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, FIONREAD, | 1544 sandbox->Cond(1, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, FIONREAD, |
1541 ErrorCode(ErrorCode::ERR_ALLOWED), | 1545 ErrorCode(ErrorCode::ERR_ALLOWED), |
1542 sandbox->Trap(SIGSYSIoctlFailure, NULL))); | 1546 sandbox->Trap(SIGSYSIoctlFailure, NULL))); |
1543 } | 1547 } |
1544 | 1548 |
1545 ErrorCode RendererOrWorkerProcessPolicy(Sandbox *sandbox, int sysno, void *) { | 1549 ErrorCode RendererOrWorkerProcessPolicy(Sandbox* sandbox, int sysno, void*) { |
1546 switch (sysno) { | 1550 switch (sysno) { |
1547 case __NR_clone: | 1551 case __NR_clone: |
1548 return RestrictCloneToThreadsAndEPERMFork(sandbox); | 1552 return RestrictCloneToThreadsAndEPERMFork(sandbox); |
1549 case __NR_ioctl: | 1553 case __NR_ioctl: |
1550 return RestrictIoctl(sandbox); | 1554 return RestrictIoctl(sandbox); |
1551 case __NR_prctl: | 1555 case __NR_prctl: |
1552 return RestrictPrctl(sandbox); | 1556 return RestrictPrctl(sandbox); |
1553 // Allow the system calls below. | 1557 // Allow the system calls below. |
1554 case __NR_fdatasync: | 1558 case __NR_fdatasync: |
1555 case __NR_fsync: | 1559 case __NR_fsync: |
(...skipping 27 matching lines...) Expand all Loading... | |
1583 if (IsSystemVIpc(sysno)) | 1587 if (IsSystemVIpc(sysno)) |
1584 return ErrorCode(ErrorCode::ERR_ALLOWED); | 1588 return ErrorCode(ErrorCode::ERR_ALLOWED); |
1585 #endif | 1589 #endif |
1586 } | 1590 } |
1587 | 1591 |
1588 // Default on the baseline policy. | 1592 // Default on the baseline policy. |
1589 return BaselinePolicy(sandbox, sysno); | 1593 return BaselinePolicy(sandbox, sysno); |
1590 } | 1594 } |
1591 } | 1595 } |
1592 | 1596 |
1593 ErrorCode FlashProcessPolicy(Sandbox *sandbox, int sysno, void *) { | 1597 ErrorCode FlashProcessPolicy(Sandbox* sandbox, int sysno, void*) { |
1594 switch (sysno) { | 1598 switch (sysno) { |
1595 case __NR_clone: | 1599 case __NR_clone: |
Chris Evans
2013/05/29 19:54:13
Do you hapen to have a 32-bit Chrome OS build hand
Jorge Lucangeli Obes
2013/05/29 19:57:22
Yeah, I tested both x86 and ARM.
| |
1596 #if defined(__x86_64__) | |
1597 // TODO(jorgelo): enable this on other platforms. | |
1598 return RestrictCloneToThreadsAndEPERMFork(sandbox); | 1600 return RestrictCloneToThreadsAndEPERMFork(sandbox); |
1599 #endif | |
1600 case __NR_sched_get_priority_max: | 1601 case __NR_sched_get_priority_max: |
1601 case __NR_sched_get_priority_min: | 1602 case __NR_sched_get_priority_min: |
1602 case __NR_sched_getaffinity: | 1603 case __NR_sched_getaffinity: |
1603 case __NR_sched_getparam: | 1604 case __NR_sched_getparam: |
1604 case __NR_sched_getscheduler: | 1605 case __NR_sched_getscheduler: |
1605 case __NR_sched_setscheduler: | 1606 case __NR_sched_setscheduler: |
1606 case __NR_times: | 1607 case __NR_times: |
1607 return ErrorCode(ErrorCode::ERR_ALLOWED); | 1608 return ErrorCode(ErrorCode::ERR_ALLOWED); |
1608 case __NR_ioctl: | 1609 case __NR_ioctl: |
1609 return ErrorCode(ENOTTY); // Flash Access. | 1610 return ErrorCode(ENOTTY); // Flash Access. |
1610 default: | 1611 default: |
1611 if (IsUsingToolKitGtk()) { | 1612 if (IsUsingToolKitGtk()) { |
1612 #if defined(__x86_64__) || defined(__arm__) | 1613 #if defined(__x86_64__) || defined(__arm__) |
1613 if (IsSystemVSharedMemory(sysno)) | 1614 if (IsSystemVSharedMemory(sysno)) |
1614 return ErrorCode(ErrorCode::ERR_ALLOWED); | 1615 return ErrorCode(ErrorCode::ERR_ALLOWED); |
1615 #endif | 1616 #endif |
1616 #if defined(__i386__) | 1617 #if defined(__i386__) |
1617 if (IsSystemVIpc(sysno)) | 1618 if (IsSystemVIpc(sysno)) |
1618 return ErrorCode(ErrorCode::ERR_ALLOWED); | 1619 return ErrorCode(ErrorCode::ERR_ALLOWED); |
1619 #endif | 1620 #endif |
1620 } | 1621 } |
1621 | 1622 |
1622 // Default on the baseline policy. | 1623 // Default on the baseline policy. |
1623 return BaselinePolicy(sandbox, sysno); | 1624 return BaselinePolicy(sandbox, sysno); |
1624 } | 1625 } |
1625 } | 1626 } |
1626 | 1627 |
1627 ErrorCode BlacklistDebugAndNumaPolicy(Sandbox *sandbox, int sysno, void *) { | 1628 ErrorCode BlacklistDebugAndNumaPolicy(Sandbox* sandbox, int sysno, void*) { |
1628 if (!Sandbox::IsValidSyscallNumber(sysno)) { | 1629 if (!Sandbox::IsValidSyscallNumber(sysno)) { |
1629 // TODO(jln) we should not have to do that in a trivial policy. | 1630 // TODO(jln) we should not have to do that in a trivial policy. |
1630 return ErrorCode(ENOSYS); | 1631 return ErrorCode(ENOSYS); |
1631 } | 1632 } |
1632 | 1633 |
1633 if (IsDebug(sysno) || IsNuma(sysno)) | 1634 if (IsDebug(sysno) || IsNuma(sysno)) |
1634 return sandbox->Trap(CrashSIGSYS_Handler, NULL); | 1635 return sandbox->Trap(CrashSIGSYS_Handler, NULL); |
1635 | 1636 |
1636 return ErrorCode(ErrorCode::ERR_ALLOWED); | 1637 return ErrorCode(ErrorCode::ERR_ALLOWED); |
1637 } | 1638 } |
1638 | 1639 |
1639 // Allow all syscalls. | 1640 // Allow all syscalls. |
1640 // This will still deny x32 or IA32 calls in 64 bits mode or | 1641 // This will still deny x32 or IA32 calls in 64 bits mode or |
1641 // 64 bits system calls in compatibility mode. | 1642 // 64 bits system calls in compatibility mode. |
1642 ErrorCode AllowAllPolicy(Sandbox *, int sysno, void *) { | 1643 ErrorCode AllowAllPolicy(Sandbox*, int sysno, void*) { |
1643 if (!Sandbox::IsValidSyscallNumber(sysno)) { | 1644 if (!Sandbox::IsValidSyscallNumber(sysno)) { |
1644 // TODO(jln) we should not have to do that in a trivial policy. | 1645 // TODO(jln) we should not have to do that in a trivial policy. |
1645 return ErrorCode(ENOSYS); | 1646 return ErrorCode(ENOSYS); |
1646 } else { | 1647 } else { |
1647 return ErrorCode(ErrorCode::ERR_ALLOWED); | 1648 return ErrorCode(ErrorCode::ERR_ALLOWED); |
1648 } | 1649 } |
1649 } | 1650 } |
1650 | 1651 |
1651 bool EnableGpuBrokerPolicyCallback() { | 1652 bool EnableGpuBrokerPolicyCallback() { |
1652 StartSandboxWithPolicy(GpuBrokerProcessPolicy, NULL); | 1653 StartSandboxWithPolicy(GpuBrokerProcessPolicy, NULL); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1869 // should enable it, enable it or die. | 1870 // should enable it, enable it or die. |
1870 bool started_sandbox = StartBpfSandbox(command_line, process_type); | 1871 bool started_sandbox = StartBpfSandbox(command_line, process_type); |
1871 CHECK(started_sandbox); | 1872 CHECK(started_sandbox); |
1872 return true; | 1873 return true; |
1873 } | 1874 } |
1874 #endif | 1875 #endif |
1875 return false; | 1876 return false; |
1876 } | 1877 } |
1877 | 1878 |
1878 } // namespace content | 1879 } // namespace content |
OLD | NEW |