Title: [250220] releases/WebKitGTK/webkit-2.26/Source/WebCore
- Revision
- 250220
- Author
- [email protected]
- Date
- 2019-09-23 03:14:26 -0700 (Mon, 23 Sep 2019)
Log Message
Merge r249762 - Prevent reentrancy FrameLoader::dispatchUnloadEvents()
https://bugs.webkit.org/show_bug.cgi?id=200738
Reviewed by Brady Eidson.
Reentrancy causes m_pageDismissalEventBeingDispatched to be incorrectly
updated, so don't allow reentrancy.
Since this prevents m_pageDismissalEventBeingDispatched from being reset
inside a reentrant call, it can have the unintended effect of causing
FrameLoader::stopAllLoaders to early-out when called from
FrameLoader::detachFromParent while a frame's unload event handler
calls document.open() on a parent frame and causes itself to become
detached. Allowing a load to continue in a detached frame will lead to
a crash. To prevent this, add a new argument to FrameLoader::stopAllLoaders
that FrameLoader::detachFromParent can use to prevent an early-out.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::stopAllLoaders):
(WebCore::FrameLoader::detachFromParent):
(WebCore::FrameLoader::dispatchUnloadEvents):
(WebCore::FrameLoader::dispatchBeforeUnloadEvent):
Ensure that m_pageDismissalEventBeingDispatched is reset to its previous value, even if this is not None.
* loader/FrameLoader.h:
* loader/FrameLoaderTypes.h:
Add a StopLoadingPolicy enum.
Modified Paths
Diff
Modified: releases/WebKitGTK/webkit-2.26/Source/WebCore/ChangeLog (250219 => 250220)
--- releases/WebKitGTK/webkit-2.26/Source/WebCore/ChangeLog 2019-09-23 10:14:22 UTC (rev 250219)
+++ releases/WebKitGTK/webkit-2.26/Source/WebCore/ChangeLog 2019-09-23 10:14:26 UTC (rev 250220)
@@ -1,3 +1,32 @@
+2019-09-11 Ali Juma <[email protected]>
+
+ Prevent reentrancy FrameLoader::dispatchUnloadEvents()
+ https://bugs.webkit.org/show_bug.cgi?id=200738
+
+ Reviewed by Brady Eidson.
+
+ Reentrancy causes m_pageDismissalEventBeingDispatched to be incorrectly
+ updated, so don't allow reentrancy.
+
+ Since this prevents m_pageDismissalEventBeingDispatched from being reset
+ inside a reentrant call, it can have the unintended effect of causing
+ FrameLoader::stopAllLoaders to early-out when called from
+ FrameLoader::detachFromParent while a frame's unload event handler
+ calls document.open() on a parent frame and causes itself to become
+ detached. Allowing a load to continue in a detached frame will lead to
+ a crash. To prevent this, add a new argument to FrameLoader::stopAllLoaders
+ that FrameLoader::detachFromParent can use to prevent an early-out.
+
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::stopAllLoaders):
+ (WebCore::FrameLoader::detachFromParent):
+ (WebCore::FrameLoader::dispatchUnloadEvents):
+ (WebCore::FrameLoader::dispatchBeforeUnloadEvent):
+ Ensure that m_pageDismissalEventBeingDispatched is reset to its previous value, even if this is not None.
+ * loader/FrameLoader.h:
+ * loader/FrameLoaderTypes.h:
+ Add a StopLoadingPolicy enum.
+
2019-09-03 Devin Rousso <[email protected]>
REGRESSION (r249078): Flaky crash in com.apple._javascript_Core: Inspector::InjectedScriptModule::ensureInjected
Modified: releases/WebKitGTK/webkit-2.26/Source/WebCore/loader/FrameLoader.cpp (250219 => 250220)
--- releases/WebKitGTK/webkit-2.26/Source/WebCore/loader/FrameLoader.cpp 2019-09-23 10:14:22 UTC (rev 250219)
+++ releases/WebKitGTK/webkit-2.26/Source/WebCore/loader/FrameLoader.cpp 2019-09-23 10:14:26 UTC (rev 250220)
@@ -1808,12 +1808,12 @@
loadWithDocumentLoader(loader.ptr(), frameLoadTypeForReloadOptions(options), { }, AllowNavigationToInvalidURL::Yes, ShouldTreatAsContinuingLoad::No);
}
-void FrameLoader::stopAllLoaders(ClearProvisionalItemPolicy clearProvisionalItemPolicy)
+void FrameLoader::stopAllLoaders(ClearProvisionalItemPolicy clearProvisionalItemPolicy, StopLoadingPolicy stopLoadingPolicy)
{
if (m_frame.document() && m_frame.document()->pageCacheState() == Document::InPageCache)
return;
- if (!isStopLoadingAllowed())
+ if (stopLoadingPolicy == StopLoadingPolicy::PreventDuringUnloadEvents && !isStopLoadingAllowed())
return;
// If this method is called from within this method, infinite recursion can occur (3442218). Avoid this.
@@ -2822,7 +2822,7 @@
// stopAllLoaders() needs to be called after detachChildren() if the document is not in the page cache,
// because detachedChildren() will trigger the unload event handlers of any child frames, and those event
// handlers might start a new subresource load in this frame.
- stopAllLoaders();
+ stopAllLoaders(ShouldClearProvisionalItem, StopLoadingPolicy::AlwaysStopLoading);
}
InspectorInstrumentation::frameDetachedFromParent(m_frame);
@@ -3275,6 +3275,9 @@
if (!m_frame.document())
return;
+ if (m_pageDismissalEventBeingDispatched != PageDismissalType::None)
+ return;
+
// We store the frame's page in a local variable because the frame might get detached inside dispatchEvent.
ForbidPromptsScope forbidPrompts(m_frame.page());
IgnoreOpensDuringUnloadCountIncrementer ignoreOpensDuringUnloadCountIncrementer(m_frame.document());
@@ -3353,15 +3356,13 @@
return true;
Ref<BeforeUnloadEvent> beforeUnloadEvent = BeforeUnloadEvent::create();
- m_pageDismissalEventBeingDispatched = PageDismissalType::BeforeUnload;
{
+ SetForScope<PageDismissalType> change(m_pageDismissalEventBeingDispatched, PageDismissalType::BeforeUnload);
ForbidPromptsScope forbidPrompts(m_frame.page());
domWindow->dispatchEvent(beforeUnloadEvent, domWindow->document());
}
- m_pageDismissalEventBeingDispatched = PageDismissalType::None;
-
if (!beforeUnloadEvent->defaultPrevented())
document->defaultEventHandler(beforeUnloadEvent.get());
Modified: releases/WebKitGTK/webkit-2.26/Source/WebCore/loader/FrameLoader.h (250219 => 250220)
--- releases/WebKitGTK/webkit-2.26/Source/WebCore/loader/FrameLoader.h 2019-09-23 10:14:22 UTC (rev 250219)
+++ releases/WebKitGTK/webkit-2.26/Source/WebCore/loader/FrameLoader.h 2019-09-23 10:14:26 UTC (rev 250220)
@@ -145,7 +145,7 @@
// FIXME: These are all functions which stop loads. We have too many.
void stopAllLoadersAndCheckCompleteness();
- WEBCORE_EXPORT void stopAllLoaders(ClearProvisionalItemPolicy = ShouldClearProvisionalItem);
+ WEBCORE_EXPORT void stopAllLoaders(ClearProvisionalItemPolicy = ShouldClearProvisionalItem, StopLoadingPolicy = StopLoadingPolicy::PreventDuringUnloadEvents);
WEBCORE_EXPORT void stopForUserCancel(bool deferCheckLoadComplete = false);
void stop();
void stopLoading(UnloadEventPolicy);
Modified: releases/WebKitGTK/webkit-2.26/Source/WebCore/loader/FrameLoaderTypes.h (250219 => 250220)
--- releases/WebKitGTK/webkit-2.26/Source/WebCore/loader/FrameLoaderTypes.h 2019-09-23 10:14:22 UTC (rev 250219)
+++ releases/WebKitGTK/webkit-2.26/Source/WebCore/loader/FrameLoaderTypes.h 2019-09-23 10:14:26 UTC (rev 250220)
@@ -141,6 +141,11 @@
ShouldNotClearProvisionalItem
};
+enum class StopLoadingPolicy {
+ PreventDuringUnloadEvents,
+ AlwaysStopLoading
+};
+
enum class ObjectContentType : uint8_t {
None,
Image,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes