Bug 1460433: Part 1 - Change BasicDllServices to not do any dll notification callbacks; r=mhowell

BasicDllServices is used to gain access to the authenticode APIs in non-Gecko
contexts. One feature that WinDllServices provides is the ability to register
a callback interface to be notified when a DLL has been loaded.

This is not particularly useful in the BasicDllServices use case, and in the
"handle a launcher process failure on a background thread" use case, would
actually be harmful.

This patch modifies the DLLServices backend to offer a "basic" option that
omits the callback stuff.

Differential Revision: https://phabricator.services.mozilla.com/D19696

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Aaron Klotz 2019-02-20 06:18:45 +00:00
Родитель 342d109220
Коммит 28466cb97e
6 изменённых файлов: 30 добавлений и 15 удалений

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

@ -1321,7 +1321,7 @@ int XRE_XPCShellMain(int argc, char** argv, char** envp,
// Ensure that DLL Services are running
RefPtr<DllServices> dllSvc(DllServices::Get());
auto dllServicesDisable = MakeScopeExit([&dllSvc]() { dllSvc->Disable(); });
auto dllServicesDisable = MakeScopeExit([&dllSvc]() { dllSvc->DisableFull(); });
# if defined(MOZ_SANDBOX)
// Required for sandboxed child processes.

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

@ -994,7 +994,7 @@ namespace mozilla {
Authenticode* GetAuthenticode();
} // namespace mozilla
MFBT_API void DllBlocklist_SetDllServices(
MFBT_API void DllBlocklist_SetFullDllServices(
mozilla::glue::detail::DllServicesBase* aSvc) {
glue::AutoExclusiveLock lock(gDllServicesLock);
if (aSvc) {
@ -1023,3 +1023,12 @@ MFBT_API void DllBlocklist_SetDllServices(
}
}
}
MFBT_API void DllBlocklist_SetBasicDllServices(
mozilla::glue::detail::DllServicesBase* aSvc) {
if (!aSvc) {
return;
}
aSvc->SetAuthenticodeImpl(GetAuthenticode());
}

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

@ -54,7 +54,9 @@ class DllServicesBase;
} // namespace glue
} // namespace mozilla
MFBT_API void DllBlocklist_SetDllServices(
MFBT_API void DllBlocklist_SetFullDllServices(
mozilla::glue::detail::DllServicesBase* aSvc);
MFBT_API void DllBlocklist_SetBasicDllServices(
mozilla::glue::detail::DllServicesBase* aSvc);
#endif // defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))

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

@ -110,7 +110,7 @@ class DllServicesBase : public Authenticode {
return mAuthenticode->GetBinaryOrgName(aFilePath);
}
void Disable() { DllBlocklist_SetDllServices(nullptr); }
void DisableFull() { DllBlocklist_SetFullDllServices(nullptr); }
DllServicesBase(const DllServicesBase&) = delete;
DllServicesBase(DllServicesBase&&) = delete;
@ -122,7 +122,8 @@ class DllServicesBase : public Authenticode {
virtual ~DllServicesBase() = default;
void Enable() { DllBlocklist_SetDllServices(this); }
void EnableFull() { DllBlocklist_SetFullDllServices(this); }
void EnableBasic() { DllBlocklist_SetBasicDllServices(this); }
private:
Authenticode* mAuthenticode;
@ -166,15 +167,18 @@ class DllServices : public detail::DllServicesBase {
#else
class BasicDllServices : public detail::DllServicesBase {
class BasicDllServices final : public detail::DllServicesBase {
public:
BasicDllServices() { Enable(); }
~BasicDllServices() { Disable(); }
virtual void DispatchDllLoadNotification(PCUNICODE_STRING aDllName) override {
BasicDllServices() {
EnableBasic();
}
~BasicDllServices() = default;
// Not useful in this class, so provide a default implementation
virtual void DispatchDllLoadNotification(PCUNICODE_STRING aDllName) override
{}
virtual void NotifyUntrustedModuleLoads(
const Vector<glue::ModuleLoadEvent, 0, InfallibleAllocPolicy>& aEvents)
override {}

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

@ -396,10 +396,10 @@ DllServices* DllServices::Get() {
sInstance = new DllServices();
sDllServicesHasBeenSet = true;
// Enable() winds up calling NotifyUntrustedModuleLoads which requires
// sInstance to be valid. So we must call Enable() here rather than the
// EnableFull() winds up calling NotifyUntrustedModuleLoads which requires
// sInstance to be valid. So we must call EnableFull() here rather than the
// DllServices constructor.
sInstance->Enable();
sInstance->EnableFull();
ClearOnShutdown(&sInstance);
return sInstance;
}

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

@ -4389,7 +4389,7 @@ nsresult XREMain::XRE_mainRun() {
#if defined(XP_WIN)
RefPtr<mozilla::DllServices> dllServices(mozilla::DllServices::Get());
auto dllServicesDisable =
MakeScopeExit([&dllServices]() { dllServices->Disable(); });
MakeScopeExit([&dllServices]() { dllServices->DisableFull(); });
#endif // defined(XP_WIN)
#ifdef NS_FUNCTION_TIMER