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

Side by Side Diff: src/trusted/service_runtime/nacl_syscall_common.c

Issue 15039022: Enable meta-based validation for shared libraries. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Style Created 7 years, 7 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 | « src/trusted/sel_universal/reverse_emulate.cc ('k') | src/trusted/validator/rich_file_info.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /* 7 /*
8 * NaCl service run-time, non-platform specific system call helper routines. 8 * NaCl service run-time, non-platform specific system call helper routines.
9 */ 9 */
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 * For eventual munmap, stopping threads also involve looking at 1511 * For eventual munmap, stopping threads also involve looking at
1512 * their registers to make sure their %rip/%eip/%ip are not 1512 * their registers to make sure their %rip/%eip/%ip are not
1513 * inside the region being modified (impossible for initial 1513 * inside the region being modified (impossible for initial
1514 * insertion). This is needed because mmap->munmap->mmap could 1514 * insertion). This is needed because mmap->munmap->mmap could
1515 * cause problems due to scheduler races. 1515 * cause problems due to scheduler races.
1516 * 1516 *
1517 * Use NaClDynamicRegionCreate to mark region as allocated. 1517 * Use NaClDynamicRegionCreate to mark region as allocated.
1518 */ 1518 */
1519 uintptr_t image_sys_addr; 1519 uintptr_t image_sys_addr;
1520 NaClValidationStatus validator_status = NaClValidationFailed; 1520 NaClValidationStatus validator_status = NaClValidationFailed;
1521 struct NaClValidationMetadata metadata;
1521 int sys_ret; /* syscall return convention */ 1522 int sys_ret; /* syscall return convention */
1522 int ret; 1523 int ret;
1523 1524
1524 NaClLog(4, "NaClSysMmap: checking descriptor type\n"); 1525 NaClLog(4, "NaClSysMmap: checking descriptor type\n");
1525 if (NACL_VTBL(NaClDesc, ndp)->typeTag != NACL_DESC_HOST_IO) { 1526 if (NACL_VTBL(NaClDesc, ndp)->typeTag != NACL_DESC_HOST_IO) {
1526 NaClLog(4, "NaClSysMmap: not supported type, got %d\n", 1527 NaClLog(4, "NaClSysMmap: not supported type, got %d\n",
1527 NACL_VTBL(NaClDesc, ndp)->typeTag); 1528 NACL_VTBL(NaClDesc, ndp)->typeTag);
1528 map_result = -NACL_ABI_EINVAL; 1529 map_result = -NACL_ABI_EINVAL;
1529 goto cleanup; 1530 goto cleanup;
1530 } 1531 }
(...skipping 16 matching lines...) Expand all
1547 (void *) NULL, 1548 (void *) NULL,
1548 length, 1549 length,
1549 NACL_ABI_PROT_READ | NACL_ABI_PROT_WRITE, 1550 NACL_ABI_PROT_READ | NACL_ABI_PROT_WRITE,
1550 NACL_ABI_MAP_PRIVATE, 1551 NACL_ABI_MAP_PRIVATE,
1551 offset); 1552 offset);
1552 if (NaClPtrIsNegErrno(&image_sys_addr)) { 1553 if (NaClPtrIsNegErrno(&image_sys_addr)) {
1553 map_result = image_sys_addr; 1554 map_result = image_sys_addr;
1554 goto cleanup; 1555 goto cleanup;
1555 } 1556 }
1556 1557
1557 /*
1558 * TODO(bsy): when ncbray provides validation cache metadata
1559 * interface, plumb this through here. We need to extract the
1560 * descriptor metadata as a bag of bits via NACL_VTBL(NaClDesc,
1561 * ndp)->GetMetadata(...), possibly deserialize its contents
1562 * using a validation cache provided function into a struct
1563 * NaClValidationMetadata object, and pass it through here, as
1564 * well as destroying the metadata object etc.
1565 */
1566
1567 /* Ask validator / validation cache */ 1558 /* Ask validator / validation cache */
1559 MetadataFromNaClDescCtor(&metadata, ndp);
1568 validator_status = NACL_FI("MMAP_FORCE_MMAP_VALIDATION_FAIL", 1560 validator_status = NACL_FI("MMAP_FORCE_MMAP_VALIDATION_FAIL",
1569 (*nap->validator-> 1561 (*nap->validator->
1570 Validate)(usraddr, 1562 Validate)(usraddr,
1571 (uint8_t *) image_sys_addr, 1563 (uint8_t *) image_sys_addr,
1572 length, 1564 length,
1573 0, /* stubout_mode: no */ 1565 0, /* stubout_mode: no */
1574 1, /* readonly_text: yes */ 1566 1, /* readonly_text: yes */
1575 nap->cpu_features, 1567 nap->cpu_features,
1576 NULL, /* metadata */ 1568 &metadata,
1577 nap->validation_cache), 1569 nap->validation_cache),
1578 NaClValidationFailed); 1570 NaClValidationFailed);
1579 NaClLog(3, "NaClSysMmap: prot_exec, validator_status %d\n", 1571 NaClLog(3, "NaClSysMmap: prot_exec, validator_status %d\n",
1580 validator_status); 1572 validator_status);
1573 MetadataDtor(&metadata);
1581 1574
1582 if (NaClValidationSucceeded == validator_status) { 1575 if (NaClValidationSucceeded == validator_status) {
1583 /* 1576 /*
1584 * Check if target address range is actually available. It 1577 * Check if target address range is actually available. It
1585 * must be neither in use by NaClText interface, nor used by 1578 * must be neither in use by NaClText interface, nor used by
1586 * previous mmap'd code. We record mmap'd code regions in the 1579 * previous mmap'd code. We record mmap'd code regions in the
1587 * NaClText's data structures to avoid lo both having to deal 1580 * NaClText's data structures to avoid lo both having to deal
1588 * with looking in two data structures. We could do this 1581 * with looking in two data structures. We could do this
1589 * first since this is a cheaper check, but it shouldn't 1582 * first since this is a cheaper check, but it shouldn't
1590 * matter since application errors ought to be rare and we 1583 * matter since application errors ought to be rare and we
(...skipping 1952 matching lines...) Expand 10 before | Expand all | Expand 10 after
3543 return NaClSysClockGetCommon(natp, clk_id, (uintptr_t) tsp, 3536 return NaClSysClockGetCommon(natp, clk_id, (uintptr_t) tsp,
3544 NaClClockGetRes); 3537 NaClClockGetRes);
3545 } 3538 }
3546 3539
3547 int32_t NaClSysClockGetTime(struct NaClAppThread *natp, 3540 int32_t NaClSysClockGetTime(struct NaClAppThread *natp,
3548 int clk_id, 3541 int clk_id,
3549 uint32_t tsp) { 3542 uint32_t tsp) {
3550 return NaClSysClockGetCommon(natp, clk_id, (uintptr_t) tsp, 3543 return NaClSysClockGetCommon(natp, clk_id, (uintptr_t) tsp,
3551 NaClClockGetTime); 3544 NaClClockGetTime);
3552 } 3545 }
OLDNEW
« no previous file with comments | « src/trusted/sel_universal/reverse_emulate.cc ('k') | src/trusted/validator/rich_file_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698