Bug 1783242 - Part 2: Relax structured clone payload size limits, r=ipc-reviewers,mccr8

Differential Revision: https://phabricator.services.mozilla.com/D153805
This commit is contained in:
Nika Layzell 2022-09-28 19:25:13 +00:00
Родитель 1c5879a78a
Коммит d5b11331f3
7 изменённых файлов: 0 добавлений и 101 удалений

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

@ -469,15 +469,6 @@ bool nsFrameMessageManager::GetParamsForMessage(JSContext* aCx,
static bool sSendingSyncMessage = false; static bool sSendingSyncMessage = false;
static bool AllowMessage(size_t aDataLength, const nsAString& aMessageName) {
// A message includes more than structured clone data, so subtract
// 20KB to make it more likely that a message within this bound won't
// result in an overly large IPC message.
static const size_t kMaxMessageSize =
IPC::Channel::kMaximumMessageSize - 20 * 1024;
return aDataLength < kMaxMessageSize;
}
void nsFrameMessageManager::SendSyncMessage(JSContext* aCx, void nsFrameMessageManager::SendSyncMessage(JSContext* aCx,
const nsAString& aMessageName, const nsAString& aMessageName,
JS::Handle<JS::Value> aObj, JS::Handle<JS::Value> aObj,
@ -511,11 +502,6 @@ void nsFrameMessageManager::SendSyncMessage(JSContext* aCx,
} }
#endif #endif
if (!AllowMessage(data.DataLength(), aMessageName)) {
aError.Throw(NS_ERROR_FAILURE);
return;
}
if (!mCallback) { if (!mCallback) {
aError.Throw(NS_ERROR_NOT_INITIALIZED); aError.Throw(NS_ERROR_NOT_INITIALIZED);
return; return;
@ -593,11 +579,6 @@ void nsFrameMessageManager::DispatchAsyncMessage(
} }
#endif #endif
if (!AllowMessage(data.DataLength(), aMessageName)) {
aError.Throw(NS_ERROR_FAILURE);
return;
}
aError = DispatchAsyncMessageInternal(aCx, aMessageName, data); aError = DispatchAsyncMessageInternal(aCx, aMessageName, data);
} }

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

@ -129,21 +129,6 @@ nsresult JSActor::QueryInterfaceActor(const nsIID& aIID, void** aPtr) {
return mWrappedJS->QueryInterface(aIID, aPtr); return mWrappedJS->QueryInterface(aIID, aPtr);
} }
/* static */
bool JSActor::AllowMessage(const JSActorMessageMeta& aMetadata,
size_t aDataLength) {
// A message includes more than structured clone data, so subtract
// 20KB to make it more likely that a message within this bound won't
// result in an overly large IPC message.
static const size_t kMaxMessageSize =
IPC::Channel::kMaximumMessageSize - 20 * 1024;
if (aDataLength < kMaxMessageSize) {
return true;
}
return false;
}
void JSActor::SetName(const nsACString& aName) { void JSActor::SetName(const nsACString& aName) {
MOZ_ASSERT(mName.IsEmpty(), "Cannot set name twice!"); MOZ_ASSERT(mName.IsEmpty(), "Cannot set name twice!");
mName = aName; mName = aName;

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

@ -69,11 +69,6 @@ class JSActor : public nsISupports, public nsWrapperCache {
Maybe<ipc::StructuredCloneData>&& aStack, Maybe<ipc::StructuredCloneData>&& aStack,
ErrorResult& aRv) = 0; ErrorResult& aRv) = 0;
// Check if a message is so large that IPC will probably crash if we try to
// send it. If it is too large, record telemetry about the message.
static bool AllowMessage(const JSActorMessageMeta& aMetadata,
size_t aDataLength);
// Helper method to send an in-process raw message. // Helper method to send an in-process raw message.
using OtherSideCallback = std::function<already_AddRefed<JSActorManager>()>; using OtherSideCallback = std::function<already_AddRefed<JSActorManager>()>;
static void SendRawMessageInProcess(const JSActorMessageMeta& aMeta, static void SendRawMessageInProcess(const JSActorMessageMeta& aMeta,

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

@ -33,21 +33,6 @@ void JSProcessActorChild::SendRawMessage(
return; return;
} }
size_t length = 0;
if (aData) {
length += aData->DataLength();
}
if (aStack) {
length += aStack->DataLength();
}
if (NS_WARN_IF(!AllowMessage(aMeta, length))) {
aRv.ThrowDataCloneError(
nsPrintfCString("JSProcessActorChild serialization error: data too "
"large, in actor '%s'",
PromiseFlatCString(aMeta.actorName()).get()));
return;
}
// If the parent side is in the same process, we have a PInProcess manager, // If the parent side is in the same process, we have a PInProcess manager,
// and can dispatch the message directly to the event loop. // and can dispatch the message directly to the event loop.
ContentChild* contentChild = mManager->AsContentChild(); ContentChild* contentChild = mManager->AsContentChild();

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

@ -46,21 +46,6 @@ void JSProcessActorParent::SendRawMessage(
return; return;
} }
size_t length = 0;
if (aData) {
length += aData->DataLength();
}
if (aStack) {
length += aStack->DataLength();
}
if (NS_WARN_IF(!AllowMessage(aMeta, length))) {
aRv.ThrowDataError(nsPrintfCString(
"Actor '%s' cannot send message '%s': message too long.",
PromiseFlatCString(aMeta.actorName()).get(),
NS_ConvertUTF16toUTF8(aMeta.messageName()).get()));
return;
}
// If the parent side is in the same process, we have a PInProcess manager, // If the parent side is in the same process, we have a PInProcess manager,
// and can dispatch the message directly to the event loop. // and can dispatch the message directly to the event loop.
ContentParent* contentParent = mManager->AsContentParent(); ContentParent* contentParent = mManager->AsContentParent();

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

@ -53,22 +53,6 @@ void JSWindowActorChild::SendRawMessage(
return; return;
} }
size_t length = 0;
if (aData) {
length += aData->DataLength();
}
if (aStack) {
length += aStack->DataLength();
}
if (NS_WARN_IF(!AllowMessage(aMeta, length))) {
aRv.ThrowDataCloneError(
nsPrintfCString("JSWindowActorChild serialization error: data too "
"large, in actor '%s'",
PromiseFlatCString(aMeta.actorName()).get()));
return;
}
// Cross-process case - send data over WindowGlobalChild to other side. // Cross-process case - send data over WindowGlobalChild to other side.
Maybe<ClonedMessageData> msgData; Maybe<ClonedMessageData> msgData;
if (aData) { if (aData) {

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

@ -51,22 +51,6 @@ void JSWindowActorParent::SendRawMessage(
return; return;
} }
size_t length = 0;
if (aData) {
length += aData->DataLength();
}
if (aStack) {
length += aStack->DataLength();
}
if (NS_WARN_IF(!AllowMessage(aMeta, length))) {
aRv.ThrowDataCloneError(
nsPrintfCString("JSWindowActorParent serialization error: data too "
"large, in actor '%s'",
PromiseFlatCString(aMeta.actorName()).get()));
return;
}
Maybe<ClonedMessageData> msgData; Maybe<ClonedMessageData> msgData;
if (aData) { if (aData) {
msgData.emplace(); msgData.emplace();