| OLD | NEW |
| 1 // Copyright 2014 Google Inc. All Rights Reserved. | 1 // Copyright 2014 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "syzygy/common/assertions.h" | 29 #include "syzygy/common/assertions.h" |
| 30 | 30 |
| 31 namespace common { | 31 namespace common { |
| 32 | 32 |
| 33 #pragma pack(push, 1) | 33 #pragma pack(push, 1) |
| 34 | 34 |
| 35 // The type used by stack IDs. This must be compatible with that used by | 35 // The type used by stack IDs. This must be compatible with that used by |
| 36 // the StackCaptureCache. | 36 // the StackCaptureCache. |
| 37 typedef uint32_t AsanStackId; | 37 typedef uint32_t AsanStackId; |
| 38 | 38 |
| 39 static const size_t kAsanParametersReserved1Bits = 20; | 39 static const size_t kAsanParametersReserved1Bits = 19; |
| 40 | 40 |
| 41 // This data structure is injected into an instrumented image in a read-only | 41 // This data structure is injected into an instrumented image in a read-only |
| 42 // section. It is initialized by the instrumenter, and will be looked up at | 42 // section. It is initialized by the instrumenter, and will be looked up at |
| 43 // runtime by the SyzyAsan RTL. Values in this structure (if present) will | 43 // runtime by the SyzyAsan RTL. Values in this structure (if present) will |
| 44 // override hard-coded default values. Values in this structure may be | 44 // override hard-coded default values. Values in this structure may be |
| 45 // superceded by environment variable parameter settings. | 45 // superceded by environment variable parameter settings. |
| 46 struct AsanParameters { | 46 struct AsanParameters { |
| 47 // The first two members of this structure are fixed, and must always be | 47 // The first two members of this structure are fixed, and must always be |
| 48 // present. This allows for the detection of version shear between RTLs and | 48 // present. This allows for the detection of version shear between RTLs and |
| 49 // instrumented code. | 49 // instrumented code. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // BlockHeapManager: Indicates if the allocation filtering is enabled. If | 109 // BlockHeapManager: Indicates if the allocation filtering is enabled. If |
| 110 // so, only blocks from filtered sites can make it into the zebra heap. | 110 // so, only blocks from filtered sites can make it into the zebra heap. |
| 111 unsigned enable_allocation_filter : 1; | 111 unsigned enable_allocation_filter : 1; |
| 112 // Runtime: Indicates if the feature randomization is enabled. | 112 // Runtime: Indicates if the feature randomization is enabled. |
| 113 unsigned feature_randomization : 1; | 113 unsigned feature_randomization : 1; |
| 114 // BlockHeapManager: Indicates if we shouldn't report a crash for the same | 114 // BlockHeapManager: Indicates if we shouldn't report a crash for the same |
| 115 // corrupt block twice. | 115 // corrupt block twice. |
| 116 unsigned prevent_duplicate_corruption_crashes : 1; | 116 unsigned prevent_duplicate_corruption_crashes : 1; |
| 117 // Runtime: Indicates if the invalid accesses should be reported. | 117 // Runtime: Indicates if the invalid accesses should be reported. |
| 118 unsigned report_invalid_accesses : 1; | 118 unsigned report_invalid_accesses : 1; |
| 119 // Runtime: Defer the crash reporter initialization, the client has to |
| 120 // manually call the crash reporter initialization function. |
| 121 unsigned defer_crash_reporter_initialization : 1; |
| 119 | 122 |
| 120 // Add new flags here! | 123 // Add new flags here! |
| 121 | 124 |
| 122 unsigned reserved1 : kAsanParametersReserved1Bits; | 125 unsigned reserved1 : kAsanParametersReserved1Bits; |
| 123 }; | 126 }; |
| 124 }; | 127 }; |
| 125 | 128 |
| 126 // HeapProxy: The rate at which allocations are instrumented with header and | 129 // HeapProxy: The rate at which allocations are instrumented with header and |
| 127 // footer guards. This happens for each allocation via a runtime cointoss. | 130 // footer guards. This happens for each allocation via a runtime cointoss. |
| 128 // A value in the range 0.0 to 1.0, inclusive. | 131 // A value in the range 0.0 to 1.0, inclusive. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 152 }; | 155 }; |
| 153 #ifndef _WIN64 | 156 #ifndef _WIN64 |
| 154 COMPILE_ASSERT_IS_POD_OF_SIZE(AsanParameters, 60); | 157 COMPILE_ASSERT_IS_POD_OF_SIZE(AsanParameters, 60); |
| 155 #else | 158 #else |
| 156 COMPILE_ASSERT_IS_POD_OF_SIZE(AsanParameters, 64); | 159 COMPILE_ASSERT_IS_POD_OF_SIZE(AsanParameters, 64); |
| 157 #endif | 160 #endif |
| 158 | 161 |
| 159 // The current version of the Asan parameters structure. This must be updated | 162 // The current version of the Asan parameters structure. This must be updated |
| 160 // if any changes are made to the above structure! This is defined in the header | 163 // if any changes are made to the above structure! This is defined in the header |
| 161 // file to allow compile time assertions against this version number. | 164 // file to allow compile time assertions against this version number. |
| 162 const uint32_t kAsanParametersVersion = 14; | 165 const uint32_t kAsanParametersVersion = 15; |
| 163 | 166 |
| 164 // If the number of free bits in the parameters struct changes, then the | 167 // If the number of free bits in the parameters struct changes, then the |
| 165 // version has to change as well. This is simply here to make sure that | 168 // version has to change as well. This is simply here to make sure that |
| 166 // everything changes in lockstep. | 169 // everything changes in lockstep. |
| 167 static_assert(kAsanParametersReserved1Bits == 20 && | 170 static_assert(kAsanParametersReserved1Bits == 19 && |
| 168 kAsanParametersVersion == 14, | 171 kAsanParametersVersion == 15, |
| 169 "Version must change if reserved bits changes."); | 172 "Version must change if reserved bits changes."); |
| 170 | 173 |
| 171 // The name of the section that will be injected into an instrumented image, | 174 // The name of the section that will be injected into an instrumented image, |
| 172 // and contain the AsanParameters structure. Asan can't use your typical entry | 175 // and contain the AsanParameters structure. Asan can't use your typical entry |
| 173 // hook because the entry hook is called after the RTL has initialized itself. | 176 // hook because the entry hook is called after the RTL has initialized itself. |
| 174 // Instead the RTL scans through libraries in its memory and looks for a | 177 // Instead the RTL scans through libraries in its memory and looks for a |
| 175 // telltale section containing parameters. The first set of parameters it | 178 // telltale section containing parameters. The first set of parameters it |
| 176 // encounters are used. After that it may override some of them with environment | 179 // encounters are used. After that it may override some of them with environment |
| 177 // variable configuration. | 180 // variable configuration. |
| 178 extern const char kAsanParametersSectionName[]; | 181 extern const char kAsanParametersSectionName[]; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 extern const uint32_t kDefaultReportingPeriod; | 233 extern const uint32_t kDefaultReportingPeriod; |
| 231 extern const uint32_t kDefaultMaxNumFrames; | 234 extern const uint32_t kDefaultMaxNumFrames; |
| 232 // Default values of StackCapture parameters. | 235 // Default values of StackCapture parameters. |
| 233 extern const uint32_t kDefaultBottomFramesToSkip; | 236 extern const uint32_t kDefaultBottomFramesToSkip; |
| 234 // Default values of AsanRuntime parameters. | 237 // Default values of AsanRuntime parameters. |
| 235 extern const bool kDefaultExitOnFailure; | 238 extern const bool kDefaultExitOnFailure; |
| 236 extern const bool kDefaultCheckHeapOnFailure; | 239 extern const bool kDefaultCheckHeapOnFailure; |
| 237 extern const bool kDefaultDisableBreakpadReporting; | 240 extern const bool kDefaultDisableBreakpadReporting; |
| 238 extern const bool kDefaultFeatureRandomization; | 241 extern const bool kDefaultFeatureRandomization; |
| 239 extern const bool kDefaultReportInvalidAccesses; | 242 extern const bool kDefaultReportInvalidAccesses; |
| 243 extern const bool kDefaultDeferCrashReporterInitialization; |
| 240 // Default values of AsanLogger parameters. | 244 // Default values of AsanLogger parameters. |
| 241 extern const bool kDefaultMiniDumpOnFailure; | 245 extern const bool kDefaultMiniDumpOnFailure; |
| 242 extern const bool kDefaultLogAsText; | 246 extern const bool kDefaultLogAsText; |
| 243 // Default values of ZebraBlockHeap parameters. | 247 // Default values of ZebraBlockHeap parameters. |
| 244 extern const uint32_t kDefaultZebraBlockHeapSize; | 248 extern const uint32_t kDefaultZebraBlockHeapSize; |
| 245 extern const float kDefaultZebraBlockHeapQuarantineRatio; | 249 extern const float kDefaultZebraBlockHeapQuarantineRatio; |
| 246 // Default values of the BlockHeapManager parameters. | 250 // Default values of the BlockHeapManager parameters. |
| 247 extern const bool kDefaultEnableZebraBlockHeap; | 251 extern const bool kDefaultEnableZebraBlockHeap; |
| 248 extern const bool kDefaultEnableAllocationFilter; | 252 extern const bool kDefaultEnableAllocationFilter; |
| 249 extern const float kDefaultQuarantineFloodFillRate; | 253 extern const float kDefaultQuarantineFloodFillRate; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 265 extern const char kParamReportingPeriod[]; | 269 extern const char kParamReportingPeriod[]; |
| 266 extern const char kParamBottomFramesToSkip[]; | 270 extern const char kParamBottomFramesToSkip[]; |
| 267 // String names of StackCapture parameters. | 271 // String names of StackCapture parameters. |
| 268 extern const char kParamMaxNumFrames[]; | 272 extern const char kParamMaxNumFrames[]; |
| 269 // String names of AsanRuntime parameters. | 273 // String names of AsanRuntime parameters. |
| 270 extern const char kParamIgnoredStackIds[]; | 274 extern const char kParamIgnoredStackIds[]; |
| 271 extern const char kParamExitOnFailure[]; | 275 extern const char kParamExitOnFailure[]; |
| 272 extern const char kParamDisableBreakpadReporting[]; | 276 extern const char kParamDisableBreakpadReporting[]; |
| 273 extern const char kParamFeatureRandomization[]; | 277 extern const char kParamFeatureRandomization[]; |
| 274 extern const char kParamReportInvalidAccesses[]; | 278 extern const char kParamReportInvalidAccesses[]; |
| 279 extern const char kParamDeferCrashReporterInitialization[]; |
| 275 // String names of AsanLogger parameters. | 280 // String names of AsanLogger parameters. |
| 276 extern const char kParamMiniDumpOnFailure[]; | 281 extern const char kParamMiniDumpOnFailure[]; |
| 277 extern const char kParamLogAsText[]; | 282 extern const char kParamLogAsText[]; |
| 278 // String names of ZebraBlockHeap parameters. | 283 // String names of ZebraBlockHeap parameters. |
| 279 extern const char kParamZebraBlockHeapSize[]; | 284 extern const char kParamZebraBlockHeapSize[]; |
| 280 extern const char kParamZebraBlockHeapQuarantineRatio[]; | 285 extern const char kParamZebraBlockHeapQuarantineRatio[]; |
| 281 // String names of BlockHeapManager parameters. | 286 // String names of BlockHeapManager parameters. |
| 282 extern const char kParamDisableSizeTargetedHeaps[]; | 287 extern const char kParamDisableSizeTargetedHeaps[]; |
| 283 extern const char kParamEnableZebraBlockHeap[]; | 288 extern const char kParamEnableZebraBlockHeap[]; |
| 284 extern const char kParamEnableAllocationFilter[]; | 289 extern const char kParamEnableAllocationFilter[]; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 301 // Parses parameters from a string, and updates the provided structure. | 306 // Parses parameters from a string, and updates the provided structure. |
| 302 // @param param_string the string of parameters to be parsed. | 307 // @param param_string the string of parameters to be parsed. |
| 303 // @param asan_parameters The AsanParameters struct to be updated. | 308 // @param asan_parameters The AsanParameters struct to be updated. |
| 304 // @returns true on success, false otherwise. Logs verbosely on failure. | 309 // @returns true on success, false otherwise. Logs verbosely on failure. |
| 305 bool ParseAsanParameters(const base::StringPiece16& param_string, | 310 bool ParseAsanParameters(const base::StringPiece16& param_string, |
| 306 InflatedAsanParameters* asan_parameters); | 311 InflatedAsanParameters* asan_parameters); |
| 307 | 312 |
| 308 } // namespace common | 313 } // namespace common |
| 309 | 314 |
| 310 #endif // SYZYGY_COMMON_ASAN_PARAMETERS_H_ | 315 #endif // SYZYGY_COMMON_ASAN_PARAMETERS_H_ |
| OLD | NEW |