Bug 1682609 - Do not enable neither pre-spawn CIG or automatic DLL injection in non-Nightly r=bobowen

IBM Security Trusteer Rapport does not only inject a module via Import Table
but also apply a window hook.  Bug 1682304 revealed blocking their module with
RedirectToNoOpEntryPoint crashes a process because their hook function assumes
injection was succceeded by default.

In non-Nightly, therefore, we enable neither automatic DLL blocking nor pre-spawn CIG.

Differential Revision: https://phabricator.services.mozilla.com/D99966
This commit is contained in:
Toshihito Kikuchi 2020-12-18 21:39:10 +00:00
Родитель 9b230b2b7b
Коммит 9a0d1a6973
1 изменённых файлов: 18 добавлений и 9 удалений

Просмотреть файл

@ -147,15 +147,19 @@ static void PackOffsetVector(const Vector<nt::MemorySectionNameOnHeap>& aSource,
LauncherVoidResult SharedSection::Init(const nt::PEHeaders& aPEHeaders) {
size_t stringBufferSize = 0;
Vector<nt::MemorySectionNameOnHeap> modules;
// We enable automatic DLL blocking only in Nightly for now because it caused
// a compat issue (bug 1682304).
#if defined(NIGHTLY_BUILD)
aPEHeaders.EnumImportChunks(
[&stringBufferSize, &modules, &aPEHeaders](const char* aModule) {
#if defined(DONT_SKIP_DEFAULT_DEPENDENT_MODULES)
# if defined(DONT_SKIP_DEFAULT_DEPENDENT_MODULES)
Unused << aPEHeaders;
#else
# else
if (aPEHeaders.IsWithinImage(aModule)) {
return;
}
#endif
# endif
HMODULE module = ::GetModuleHandleA(aModule);
nt::MemorySectionNameOnHeap ntPath =
nt::MemorySectionNameOnHeap::GetBackingFilePath(nt::kCurrentProcess,
@ -163,6 +167,7 @@ LauncherVoidResult SharedSection::Init(const nt::PEHeaders& aPEHeaders) {
stringBufferSize += (ntPath.AsUnicodeString()->Length + sizeof(WCHAR));
Unused << modules.emplaceBack(std::move(ntPath));
});
#endif
size_t arraySize = modules.length() * sizeof(Layout::mModulePathArray[0]);
size_t totalSize =
@ -216,20 +221,21 @@ LauncherVoidResult SharedSection::TransferHandle(
}
extern "C" MOZ_EXPORT uint32_t GetDependentModulePaths(uint32_t** aOutArray) {
if (aOutArray) {
*aOutArray = nullptr;
}
// We enable pre-spawn CIG only in Nightly for now because it caused
// a compat issue (bug 1682304).
#if defined(NIGHTLY_BUILD)
const bool isCallerXul = CheckForAddress(RETURN_ADDRESS(), L"xul.dll");
MOZ_ASSERT(isCallerXul);
if (!isCallerXul) {
if (aOutArray) {
*aOutArray = nullptr;
}
return 0;
}
LauncherResult<SharedSection::Layout*> resultView = gSharedSection.GetView();
if (resultView.isErr()) {
if (aOutArray) {
*aOutArray = nullptr;
}
return 0;
}
@ -239,6 +245,9 @@ extern "C" MOZ_EXPORT uint32_t GetDependentModulePaths(uint32_t** aOutArray) {
*aOutArray = resultView.inspect()->mModulePathArray;
}
return resultView.inspect()->mModulePathArrayLength;
#else
return 0;
#endif
}
} // namespace freestanding