Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "native_client/src/shared/platform/nacl_log.h" | 7 #include "native_client/src/shared/platform/nacl_log.h" |
| 8 #include "native_client/src/trusted/service_runtime/sel_ldr.h" | 8 #include "native_client/src/trusted/service_runtime/sel_ldr.h" |
| 9 #include "native_client/src/trusted/validator/ncvalidate.h" | 9 #include "native_client/src/trusted/validator/ncvalidate.h" |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 case NaClValidationFailedSegmentationIssue: | 22 case NaClValidationFailedSegmentationIssue: |
| 23 default: | 23 default: |
| 24 return LOAD_VALIDATION_FAILED; | 24 return LOAD_VALIDATION_FAILED; |
| 25 } | 25 } |
| 26 } | 26 } |
| 27 | 27 |
| 28 int NaClValidateCode(struct NaClApp *nap, uintptr_t guest_addr, | 28 int NaClValidateCode(struct NaClApp *nap, uintptr_t guest_addr, |
| 29 uint8_t *data, size_t size) { | 29 uint8_t *data, size_t size) { |
| 30 NaClValidationStatus status = NaClValidationSucceeded; | 30 NaClValidationStatus status = NaClValidationSucceeded; |
| 31 enum NaClSBKind sb_kind = NACL_SB_DEFAULT; | 31 enum NaClSBKind sb_kind = NACL_SB_DEFAULT; |
| 32 | |
| 33 NaClValidationCache *cache = nap->validation_cache; | |
| 34 | |
| 32 if (nap->validator_stub_out_mode) { | 35 if (nap->validator_stub_out_mode) { |
| 36 /* Validation caching is currently incompatible with stubout. */ | |
|
Mark Seaborn
2012/03/01 00:26:20
Technically, the second pass is not incompatible.
Nick Bray (chromium)
2012/03/01 01:25:16
Based on future plans, validating code twice witho
| |
| 37 cache = NULL; | |
| 33 /* In stub out mode, we do two passes. The second pass acts as a | 38 /* In stub out mode, we do two passes. The second pass acts as a |
| 34 sanity check that bad instructions were indeed overwritten with | 39 sanity check that bad instructions were indeed overwritten with |
| 35 allowable HLTs. */ | 40 allowable HLTs. */ |
| 36 status = NACL_SUBARCH_NAME(ApplyValidator, | 41 status = NACL_SUBARCH_NAME(ApplyValidator, |
| 37 NACL_TARGET_ARCH, | 42 NACL_TARGET_ARCH, |
| 38 NACL_TARGET_SUBARCH)( | 43 NACL_TARGET_SUBARCH)( |
| 39 sb_kind, | 44 sb_kind, |
| 40 NaClApplyValidationDoStubout, | 45 NaClApplyValidationDoStubout, |
| 41 guest_addr, data, size, | 46 guest_addr, data, size, |
| 42 nap->bundle_size, &nap->cpu_features); | 47 nap->bundle_size, &nap->cpu_features, |
| 48 cache); | |
| 43 } | 49 } |
| 44 if (status == NaClValidationSucceeded) { | 50 if (status == NaClValidationSucceeded) { |
| 45 status = NACL_SUBARCH_NAME(ApplyValidator, | 51 status = NACL_SUBARCH_NAME(ApplyValidator, |
| 46 NACL_TARGET_ARCH, | 52 NACL_TARGET_ARCH, |
| 47 NACL_TARGET_SUBARCH)( | 53 NACL_TARGET_SUBARCH)( |
| 48 sb_kind, | 54 sb_kind, |
| 49 NaClApplyCodeValidation, | 55 NaClApplyCodeValidation, |
| 50 guest_addr, data, size, | 56 guest_addr, data, size, |
| 51 nap->bundle_size, &nap->cpu_features); | 57 nap->bundle_size, &nap->cpu_features, |
| 58 cache); | |
| 52 } | 59 } |
| 53 return NaClValidateStatus(status); | 60 return NaClValidateStatus(status); |
| 54 } | 61 } |
| 55 | 62 |
| 56 int NaClValidateCodeReplacement(struct NaClApp *nap, uintptr_t guest_addr, | 63 int NaClValidateCodeReplacement(struct NaClApp *nap, uintptr_t guest_addr, |
| 57 uint8_t *data_old, uint8_t *data_new, | 64 uint8_t *data_old, uint8_t *data_new, |
| 58 size_t size) { | 65 size_t size) { |
| 59 enum NaClSBKind sb_kind = NACL_SB_DEFAULT; | 66 enum NaClSBKind sb_kind = NACL_SB_DEFAULT; |
| 60 if (nap->validator_stub_out_mode) return LOAD_BAD_FILE; | 67 if (nap->validator_stub_out_mode) return LOAD_BAD_FILE; |
| 61 | 68 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 NaClLog(LOG_ERROR, | 119 NaClLog(LOG_ERROR, |
| 113 "Run sel_ldr in debug mode to ignore validation failure.\n"); | 120 "Run sel_ldr in debug mode to ignore validation failure.\n"); |
| 114 NaClLog(LOG_ERROR, | 121 NaClLog(LOG_ERROR, |
| 115 "Run ncval <module-name> for validation error details.\n"); | 122 "Run ncval <module-name> for validation error details.\n"); |
| 116 rcode = LOAD_VALIDATION_FAILED; | 123 rcode = LOAD_VALIDATION_FAILED; |
| 117 } | 124 } |
| 118 } | 125 } |
| 119 } | 126 } |
| 120 return rcode; | 127 return rcode; |
| 121 } | 128 } |
| OLD | NEW |