mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1335163 - Remove the now-unused XPCOM ASLR checks in the DLL blocklist. r=bsmedberg
MozReview-Commit-ID: 2iY5g72d4xg --HG-- extra : rebase_source : 309eb59fe0a98f0a4dfd384b3028a0ec107220c5
This commit is contained in:
parent
3a2daab431
commit
850b25389e
@ -244,7 +244,6 @@ static const char kUser32BeforeBlocklistParameter[] = "User32BeforeBlocklist=1\n
|
|||||||
static const int kUser32BeforeBlocklistParameterLen =
|
static const int kUser32BeforeBlocklistParameterLen =
|
||||||
sizeof(kUser32BeforeBlocklistParameter) - 1;
|
sizeof(kUser32BeforeBlocklistParameter) - 1;
|
||||||
|
|
||||||
static DWORD sThreadLoadingXPCOMModule;
|
|
||||||
static bool sBlocklistInitAttempted;
|
static bool sBlocklistInitAttempted;
|
||||||
static bool sBlocklistInitFailed;
|
static bool sBlocklistInitFailed;
|
||||||
static bool sUser32BeforeBlocklist;
|
static bool sUser32BeforeBlocklist;
|
||||||
@ -309,41 +308,6 @@ private:
|
|||||||
void* mRealView;
|
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<IMAGE_DOS_HEADER> peHeader(map, 0);
|
|
||||||
if (peHeader) {
|
|
||||||
RVAMap<IMAGE_NT_HEADERS> 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
|
DWORD
|
||||||
GetTimestamp(const wchar_t* path)
|
GetTimestamp(const wchar_t* path)
|
||||||
{
|
{
|
||||||
@ -727,21 +691,6 @@ continue_loading:
|
|||||||
printf_stderr("LdrLoadDll: continuing load... ('%S')\n", moduleFileName->Buffer);
|
printf_stderr("LdrLoadDll: continuing load... ('%S')\n", moduleFileName->Buffer);
|
||||||
#endif
|
#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);
|
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
|
MFBT_API void
|
||||||
DllBlocklist_WriteNotes(HANDLE file)
|
DllBlocklist_WriteNotes(HANDLE file)
|
||||||
{
|
{
|
||||||
|
@ -9,31 +9,14 @@
|
|||||||
#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
|
#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "mozilla/GuardObjects.h"
|
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
|
#include "mozilla/Types.h"
|
||||||
|
|
||||||
#define HAS_DLL_BLOCKLIST
|
#define HAS_DLL_BLOCKLIST
|
||||||
|
|
||||||
MFBT_API void DllBlocklist_Initialize();
|
MFBT_API void DllBlocklist_Initialize();
|
||||||
MFBT_API void DllBlocklist_SetInXPCOMLoadOnMainThread(bool inXPCOMLoadOnMainThread);
|
|
||||||
MFBT_API void DllBlocklist_WriteNotes(HANDLE file);
|
MFBT_API void DllBlocklist_WriteNotes(HANDLE file);
|
||||||
MFBT_API bool DllBlocklist_CheckStatus();
|
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 // defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
|
||||||
#endif // mozilla_windowsdllblocklist_h
|
#endif // mozilla_windowsdllblocklist_h
|
||||||
|
Loading…
Reference in New Issue
Block a user