Skip to content

Commit

Permalink
Bug 1772599 - Set pref sanitizations prefs in the content process r=K…
Browse files Browse the repository at this point in the history
…risWright

Differential Revision: https://phabricator.services.mozilla.com/D148311
  • Loading branch information
tomrittervg committed Jun 22, 2022
1 parent d919f20 commit b05c0bc
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
5 changes: 5 additions & 0 deletions dom/ipc/ContentChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,11 @@ void ContentChild::InitXPCOM(
// channel.
RemoteDecoderManagerChild::Init();

Preferences::RegisterCallbackAndCall(&OnFissionBlocklistPrefChange,
kFissionEnforceBlockList);
Preferences::RegisterCallbackAndCall(&OnFissionBlocklistPrefChange,
kFissionOmitBlockListValues);

// Set the dynamic scalar definitions for this process.
TelemetryIPC::AddDynamicScalarDefinitions(aXPCOMInit.dynamicScalarDefs());
}
Expand Down
17 changes: 0 additions & 17 deletions dom/ipc/ContentParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,23 +645,6 @@ static const char* sObserverTopics[] = {
DEFAULT_TIMEZONE_CHANGED_OBSERVER_TOPIC,
};

static const char kFissionEnforceBlockList[] =
"fission.enforceBlocklistedPrefsInSubprocesses";
static const char kFissionOmitBlockListValues[] =
"fission.omitBlocklistedPrefsInSubprocesses";

static void OnFissionBlocklistPrefChange(const char* aPref, void* aData) {
if (strcmp(aPref, kFissionEnforceBlockList) == 0) {
sCrashOnBlocklistedPref =
StaticPrefs::fission_enforceBlocklistedPrefsInSubprocesses();
} else if (strcmp(aPref, kFissionOmitBlockListValues) == 0) {
sOmitBlocklistedPrefValues =
StaticPrefs::fission_omitBlocklistedPrefsInSubprocesses();
} else {
MOZ_CRASH("Unknown pref passed to callback");
}
}

// PreallocateProcess is called by the PreallocatedProcessManager.
// ContentParent then takes this process back within GetNewOrUsedBrowserProcess.
/*static*/ already_AddRefed<ContentParent>
Expand Down
12 changes: 12 additions & 0 deletions modules/libpref/Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5897,6 +5897,18 @@ bool ShouldSanitizePreference(const char* aPrefName,
Atomic<bool, Relaxed> sOmitBlocklistedPrefValues(false);
Atomic<bool, Relaxed> sCrashOnBlocklistedPref(false);

void OnFissionBlocklistPrefChange(const char* aPref, void* aData) {
if (strcmp(aPref, kFissionEnforceBlockList) == 0) {
sCrashOnBlocklistedPref =
StaticPrefs::fission_enforceBlocklistedPrefsInSubprocesses();
} else if (strcmp(aPref, kFissionOmitBlockListValues) == 0) {
sOmitBlocklistedPrefValues =
StaticPrefs::fission_omitBlocklistedPrefsInSubprocesses();
} else {
MOZ_CRASH("Unknown pref passed to callback");
}
}

} // namespace mozilla

// This file contains the C wrappers for the C++ static pref getters, as used
Expand Down
7 changes: 7 additions & 0 deletions modules/libpref/Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,13 @@ extern Atomic<bool, Relaxed> sCrashOnBlocklistedPref;

bool ShouldSanitizePreference(const char* aPref, bool aIsDestWebContentProcess);

const char kFissionEnforceBlockList[] =
"fission.enforceBlocklistedPrefsInSubprocesses";
const char kFissionOmitBlockListValues[] =
"fission.omitBlocklistedPrefsInSubprocesses";

void OnFissionBlocklistPrefChange(const char* aPref, void* aData);

} // namespace mozilla

#endif // mozilla_Preferences_h

0 comments on commit b05c0bc

Please sign in to comment.