diff options
author | Peter Sollich <petersol@microsoft.com> | 2017-05-17 15:10:54 +0300 |
---|---|---|
committer | Peter Sollich <petersol@microsoft.com> | 2017-05-17 15:10:54 +0300 |
commit | 6bff3d83e5592b6d4f9c0e4bf2759b705fbc27c8 (patch) | |
tree | 7fd1b23585778f8782587e3054f79382c50e17b4 /src | |
parent | 0fb20786300a52505a011d84b44ff6ebc5475556 (diff) |
Address issue 432987 - I looked at a handful of Watson reports, and apparently in the failing cases, the IAT table has been corrupted.
It seems better to fail fast in these cases rather than to AV, or, even worse, crash later in even more confusing ways.
As there are already a bunch of ASSERTs in this code to sanity-check the IAT, it seems safest to turn the ASSERTs into conditional fail fast calls that are active in release build as well.
[tfs-changeset: 1658735]
Diffstat (limited to 'src')
-rw-r--r-- | src/Native/Runtime/module.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/Native/Runtime/module.cpp b/src/Native/Runtime/module.cpp index a237c546f..e8e9f7ed0 100644 --- a/src/Native/Runtime/module.cpp +++ b/src/Native/Runtime/module.cpp @@ -1145,6 +1145,10 @@ BlobHeader * Module::GetReadOnlyBlobs(UInt32 * pcbBlobs) /*static*/ void Module::DoCustomImports(ModuleHeader * pModuleHeader) { +// Address issue 432987: rather than AV on invalid ordinals, it's better to fail fast, so turn the +// asserts below into conditional failfast calls +#define ASSERT_FAILFAST(cond) if (!(cond)) RhFailFast() + CustomImportDescriptor *customImportTable = (CustomImportDescriptor *)pModuleHeader->GetCustomImportDescriptors(); UInt32 countCustomImports = pModuleHeader->CountCustomImportDescriptors; @@ -1175,10 +1179,10 @@ void Module::DoCustomImports(ModuleHeader * pModuleHeader) UInt32 *pFlag = (UInt32 *)ptrIAT; // the ptr to the EAT indirection cell also points to the flag - ASSERT((UInt32 *)ptrPtrEAT == pFlag); + ASSERT_FAILFAST((UInt32 *)ptrPtrEAT == pFlag); // the number of IAT entries should be zero - ASSERT(countIAT == 0); + ASSERT_FAILFAST(countIAT == 0); // if the flag is set, it means we have fixed up this module already // this is our check against infinite recursion @@ -1186,7 +1190,7 @@ void Module::DoCustomImports(ModuleHeader * pModuleHeader) return; // if the flag is not set, it must be clear - ASSERT(*pFlag == FALSE); + ASSERT_FAILFAST(*pFlag == FALSE); // set the flag *pFlag = TRUE; @@ -1200,15 +1204,15 @@ void Module::DoCustomImports(ModuleHeader * pModuleHeader) UIntTarget ordinal = ptrIAT[j]; // the ordinals should have the high bit set - ASSERT((ordinal & TARGET_IMAGE_ORDINAL_FLAG) != 0); + ASSERT_FAILFAST((ordinal & TARGET_IMAGE_ORDINAL_FLAG) != 0); // the ordinals should be in increasing order, for perf reasons - ASSERT(j+1 == countIAT || ordinal < ptrIAT[j+1]); + ASSERT_FAILFAST(j+1 == countIAT || ordinal < ptrIAT[j+1]); ordinal &= ~TARGET_IMAGE_ORDINAL_FLAG; // sanity check: limit ordinals to < 1 Million - ASSERT(ordinal < 1024 * 1024); + ASSERT_FAILFAST(ordinal < 1024 * 1024); // obtain the target RVA UInt32 targetRVA = ptrEAT[ordinal]; @@ -1230,7 +1234,9 @@ void Module::DoCustomImports(ModuleHeader * pModuleHeader) DoCustomImports(pTargetModuleHeader); } } +#undef ASSERT_FAILFAST } + #endif // FEATURE_CUSTOM_IMPORTS #endif // DACCESS_COMPILE |