From 850b25389efc84722289cac5c385c833a723b847 Mon Sep 17 00:00:00 2001 From: David Major Date: Wed, 1 Feb 2017 10:52:13 +1300 Subject: [PATCH] Bug 1335163 - Remove the now-unused XPCOM ASLR checks in the DLL blocklist. r=bsmedberg MozReview-Commit-ID: 2iY5g72d4xg --HG-- extra : rebase_source : 309eb59fe0a98f0a4dfd384b3028a0ec107220c5 --- mozglue/build/WindowsDllBlocklist.cpp | 62 --------------------------- mozglue/build/WindowsDllBlocklist.h | 19 +------- 2 files changed, 1 insertion(+), 80 deletions(-) diff --git a/mozglue/build/WindowsDllBlocklist.cpp b/mozglue/build/WindowsDllBlocklist.cpp index 01ad2654e070..41ee87f7fe01 100644 --- a/mozglue/build/WindowsDllBlocklist.cpp +++ b/mozglue/build/WindowsDllBlocklist.cpp @@ -244,7 +244,6 @@ static const char kUser32BeforeBlocklistParameter[] = "User32BeforeBlocklist=1\n static const int kUser32BeforeBlocklistParameterLen = sizeof(kUser32BeforeBlocklistParameter) - 1; -static DWORD sThreadLoadingXPCOMModule; static bool sBlocklistInitAttempted; static bool sBlocklistInitFailed; static bool sUser32BeforeBlocklist; @@ -309,41 +308,6 @@ private: void* mRealView; }; -bool -CheckASLR(const wchar_t* path) -{ - bool retval = false; - - HANDLE file = ::CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, - nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, - nullptr); - if (file != INVALID_HANDLE_VALUE) { - HANDLE map = ::CreateFileMappingW(file, nullptr, PAGE_READONLY, 0, 0, - nullptr); - if (map) { - RVAMap peHeader(map, 0); - if (peHeader) { - RVAMap ntHeader(map, peHeader->e_lfanew); - if (ntHeader) { - // If the DLL has no code, permit it regardless of ASLR status. - if (ntHeader->OptionalHeader.SizeOfCode == 0) { - retval = true; - } - // Check to see if the DLL supports ASLR - else if ((ntHeader->OptionalHeader.DllCharacteristics & - IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE) != 0) { - retval = true; - } - } - } - ::CloseHandle(map); - } - ::CloseHandle(file); - } - - return retval; -} - DWORD GetTimestamp(const wchar_t* path) { @@ -727,21 +691,6 @@ continue_loading: printf_stderr("LdrLoadDll: continuing load... ('%S')\n", moduleFileName->Buffer); #endif - if (GetCurrentThreadId() == sThreadLoadingXPCOMModule) { - // Check to ensure that the DLL has ASLR. - full_fname = getFullPath(filePath, fname); - if (!full_fname) { - // uh, we couldn't find the DLL at all, so... - printf_stderr("LdrLoadDll: Blocking load of '%s' (SearchPathW didn't find it?)\n", dllName); - return STATUS_DLL_NOT_FOUND; - } - - if (!CheckASLR(full_fname.get())) { - printf_stderr("LdrLoadDll: Blocking load of '%s'. XPCOM components must support ASLR.\n", dllName); - return STATUS_DLL_NOT_FOUND; - } - } - return stub_LdrLoadDll(filePath, flags, moduleFileName, handle); } @@ -783,17 +732,6 @@ DllBlocklist_Initialize() } } -MFBT_API void -DllBlocklist_SetInXPCOMLoadOnMainThread(bool inXPCOMLoadOnMainThread) -{ - if (inXPCOMLoadOnMainThread) { - MOZ_ASSERT(sThreadLoadingXPCOMModule == 0, "Only one thread should be doing this"); - sThreadLoadingXPCOMModule = GetCurrentThreadId(); - } else { - sThreadLoadingXPCOMModule = 0; - } -} - MFBT_API void DllBlocklist_WriteNotes(HANDLE file) { diff --git a/mozglue/build/WindowsDllBlocklist.h b/mozglue/build/WindowsDllBlocklist.h index 2e6686cbd747..ad8944dcc278 100644 --- a/mozglue/build/WindowsDllBlocklist.h +++ b/mozglue/build/WindowsDllBlocklist.h @@ -9,31 +9,14 @@ #if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) #include -#include "mozilla/GuardObjects.h" #include "mozilla/Attributes.h" +#include "mozilla/Types.h" #define HAS_DLL_BLOCKLIST MFBT_API void DllBlocklist_Initialize(); -MFBT_API void DllBlocklist_SetInXPCOMLoadOnMainThread(bool inXPCOMLoadOnMainThread); MFBT_API void DllBlocklist_WriteNotes(HANDLE file); MFBT_API bool DllBlocklist_CheckStatus(); -class MOZ_RAII AutoSetXPCOMLoadOnMainThread -{ - public: - explicit AutoSetXPCOMLoadOnMainThread(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM) { - MOZ_GUARD_OBJECT_NOTIFIER_INIT; - DllBlocklist_SetInXPCOMLoadOnMainThread(true); - } - - ~AutoSetXPCOMLoadOnMainThread() { - DllBlocklist_SetInXPCOMLoadOnMainThread(false); - } - - private: - MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER -}; - #endif // defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) #endif // mozilla_windowsdllblocklist_h