зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
1c5879a78a
Коммит
d5b11331f3
|
@ -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();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче