Title: [250136] branches/safari-608.2.11.1-branch/Source/WebKit

Diff

Modified: branches/safari-608.2.11.1-branch/Source/WebKit/ChangeLog (250135 => 250136)


--- branches/safari-608.2.11.1-branch/Source/WebKit/ChangeLog	2019-09-20 17:24:17 UTC (rev 250135)
+++ branches/safari-608.2.11.1-branch/Source/WebKit/ChangeLog	2019-09-20 18:18:14 UTC (rev 250136)
@@ -1,3 +1,38 @@
+2019-09-20  Alan Coon  <alanc...@apple.com>
+
+        Apply patch. rdar://problem/55564031
+
+    2019-09-20  Chris Dumez  <cdu...@apple.com>
+
+            Regression(r248832): Unable to quicklook HTML files in Mail
+            https://bugs.webkit.org/show_bug.cgi?id=202012
+            <rdar://problem/55285295>
+
+            Reviewed by Geoff Garen and Brent Fulgham.
+
+            r248832 inadvertently reverted the fix for Mail that landed in r247400 by not using
+            the same logic to initialize the sandbox extension if the process had already
+            finished launching or not. In particular, the new code path that happens on process
+            launch unconditionally used '/' as resource directory for the sandbox extension if
+            the client did not provide one. The logic in maybeInitializeSandboxExtensionHandle()
+            would use the file URL's base URL as resource directory when creating a sandbox
+            extension for '/' would fail (which it often does).
+
+            To address the issue, have the logic that runs on process launch call
+            maybeInitializeSandboxExtensionHandle() so avoid duplicating code and make sure
+            both cases now have the Mail fix.
+
+            * UIProcess/AuxiliaryProcessProxy.cpp:
+            (WebKit::AuxiliaryProcessProxy::didFinishLaunching):
+            * UIProcess/AuxiliaryProcessProxy.h:
+            (WebKit::AuxiliaryProcessProxy::isLaunching const):
+            * UIProcess/WebPageProxy.cpp:
+            (WebKit::WebPageProxy::maybeInitializeSandboxExtensionHandle):
+            (WebKit::WebPageProxy::loadRequestWithNavigationShared):
+            (WebKit::WebPageProxy::loadFile):
+            * UIProcess/WebPageProxy.h:
+            * WebProcess/WebPage/WebPage.messages.in:
+
 2019-09-19  Kocsen Chung  <kocsen_ch...@apple.com>
 
         Cherry-pick r250069. rdar://problem/55524978

Modified: branches/safari-608.2.11.1-branch/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp (250135 => 250136)


--- branches/safari-608.2.11.1-branch/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp	2019-09-20 17:24:17 UTC (rev 250135)
+++ branches/safari-608.2.11.1-branch/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp	2019-09-20 18:18:14 UTC (rev 250136)
@@ -29,6 +29,8 @@
 #include "AuxiliaryProcessMessages.h"
 #include "LoadParameters.h"
 #include "WebPageMessages.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
 #include <wtf/RunLoop.h>
 
 namespace WebKit {
@@ -183,12 +185,16 @@
             auto bufferSize = message->bufferSize();
             std::unique_ptr<IPC::Decoder> decoder = std::make_unique<IPC::Decoder>(buffer, bufferSize, nullptr, Vector<IPC::Attachment> { });
             LoadParameters loadParameters;
-            String sandboxExtensionPath;
-            if (decoder->decode(loadParameters) && decoder->decode(sandboxExtensionPath)) {
-                SandboxExtension::createHandleForReadByPid(sandboxExtensionPath, processIdentifier(), loadParameters.sandboxExtensionHandle);
-                send(Messages::WebPage::LoadRequest(loadParameters), decoder->destinationID());
-                continue;
-            }
+            URL resourceDirectoryURL;
+            WebCore::PageIdentifier pageID;
+            if (decoder->decode(loadParameters) && decoder->decode(resourceDirectoryURL) && decoder->decode(pageID)) {
+                if (auto* page = WebProcessProxy::webPage(pageID)) {
+                    page->maybeInitializeSandboxExtensionHandle(static_cast<WebProcessProxy&>(*this), loadParameters.request.url(), resourceDirectoryURL, loadParameters.sandboxExtensionHandle);
+                    send(Messages::WebPage::LoadRequest(loadParameters), decoder->destinationID());
+                }
+            } else
+                ASSERT_NOT_REACHED();
+            continue;
         }
 #endif
         m_connection->sendMessage(WTFMove(message), sendOptions);

Modified: branches/safari-608.2.11.1-branch/Source/WebKit/UIProcess/AuxiliaryProcessProxy.h (250135 => 250136)


--- branches/safari-608.2.11.1-branch/Source/WebKit/UIProcess/AuxiliaryProcessProxy.h	2019-09-20 17:24:17 UTC (rev 250135)
+++ branches/safari-608.2.11.1-branch/Source/WebKit/UIProcess/AuxiliaryProcessProxy.h	2019-09-20 18:18:14 UTC (rev 250136)
@@ -98,6 +98,7 @@
         Terminated,
     };
     State state() const;
+    bool isLaunching() const { return state() == State::Launching; }
 
     ProcessID processIdentifier() const { return m_processLauncher ? m_processLauncher->processIdentifier() : 0; }
 

Modified: branches/safari-608.2.11.1-branch/Source/WebKit/UIProcess/WebPageProxy.cpp (250135 => 250136)


--- branches/safari-608.2.11.1-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-09-20 17:24:17 UTC (rev 250135)
+++ branches/safari-608.2.11.1-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-09-20 18:18:14 UTC (rev 250136)
@@ -1049,6 +1049,13 @@
     if (!url.isLocalFile())
         return;
 
+#if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID)
+    // If the process is still launching then it does not have a PID yet. We will take care of creating the sandbox extension
+    // once the process has finished launching.
+    if (process.isLaunching())
+        return;
+#endif
+
     if (!resourceDirectoryURL.isEmpty()) {
         if (process.hasAssumedReadAccessToURL(resourceDirectoryURL))
             return;
@@ -1159,19 +1166,10 @@
     addPlatformLoadParameters(loadParameters);
 
 #if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID)
-    if (processIdentifier() || !url.isLocalFile())
+    if (!process->isLaunching() || !url.isLocalFile())
         process->send(Messages::WebPage::LoadRequest(loadParameters), m_pageID);
-    else {
-        String sandboxExtensionPath;
-        if (!m_pageLoadState.resourceDirectoryURL().isEmpty()) {
-            sandboxExtensionPath = m_pageLoadState.resourceDirectoryURL().fileSystemPath();
-            process->assumeReadAccessToBaseURL(*this, m_pageLoadState.resourceDirectoryURL());
-        } else {
-            sandboxExtensionPath = "/";
-            willAcquireUniversalFileReadSandboxExtension(process);
-        }
-        process->send(Messages::WebPage::LoadRequestWaitingForPID(loadParameters, sandboxExtensionPath), m_pageID);
-    }
+    else
+        process->send(Messages::WebPage::LoadRequestWaitingForPID(loadParameters, m_pageLoadState.resourceDirectoryURL(), m_pageID), m_pageID);
 #else
     process->send(Messages::WebPage::LoadRequest(loadParameters), m_pageID);
 #endif
@@ -1213,26 +1211,19 @@
 
     m_pageLoadState.setPendingAPIRequest(transaction, { navigation->navigationID(), fileURLString }, resourceDirectoryURL);
 
-    String resourceDirectoryPath = resourceDirectoryURL.fileSystemPath();
-
     LoadParameters loadParameters;
     loadParameters.navigationID = navigation->navigationID();
     loadParameters.request = fileURL;
     loadParameters.shouldOpenExternalURLsPolicy = ShouldOpenExternalURLsPolicy::ShouldNotAllow;
     loadParameters.userData = UserData(process().transformObjectsToHandles(userData).get());
-#if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID)
-    SandboxExtension::createHandleForReadByPid(resourceDirectoryPath, processIdentifier(), loadParameters.sandboxExtensionHandle);
-#else
-    SandboxExtension::createHandle(resourceDirectoryPath, SandboxExtension::Type::ReadOnly, loadParameters.sandboxExtensionHandle);
-#endif
+    maybeInitializeSandboxExtensionHandle(m_process, fileURL, resourceDirectoryURL, loadParameters.sandboxExtensionHandle);
     addPlatformLoadParameters(loadParameters);
 
-    m_process->assumeReadAccessToBaseURL(*this, resourceDirectoryURL);
 #if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID)
-    if (processIdentifier())
+    if (m_process->isLaunching())
+        m_process->send(Messages::WebPage::LoadRequestWaitingForPID(loadParameters, resourceDirectoryURL, m_pageID), m_pageID);
+    else
         m_process->send(Messages::WebPage::LoadRequest(loadParameters), m_pageID);
-    else
-        m_process->send(Messages::WebPage::LoadRequestWaitingForPID(loadParameters, resourceDirectoryPath), m_pageID);
 #else
     m_process->send(Messages::WebPage::LoadRequest(loadParameters), m_pageID);
 #endif

Modified: branches/safari-608.2.11.1-branch/Source/WebKit/UIProcess/WebPageProxy.h (250135 => 250136)


--- branches/safari-608.2.11.1-branch/Source/WebKit/UIProcess/WebPageProxy.h	2019-09-20 17:24:17 UTC (rev 250135)
+++ branches/safari-608.2.11.1-branch/Source/WebKit/UIProcess/WebPageProxy.h	2019-09-20 18:18:14 UTC (rev 250136)
@@ -1567,6 +1567,8 @@
     void setMockCaptureDevicesEnabledOverride(Optional<bool>);
 #endif
 
+    void maybeInitializeSandboxExtensionHandle(WebProcessProxy&, const URL&, const URL& resourceDirectoryURL, SandboxExtension::Handle&);
+
 private:
     WebPageProxy(PageClient&, WebProcessProxy&, WebCore::PageIdentifier, Ref<API::PageConfiguration>&&);
     void platformInitialize();
@@ -1903,8 +1905,6 @@
     void setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, uint64_t complexTextInputState);
 #endif
 
-    void maybeInitializeSandboxExtensionHandle(WebProcessProxy&, const URL& url, const URL& resourceDirectoryURL, SandboxExtension::Handle&);
-
 #if USE(AUTOMATIC_TEXT_REPLACEMENT)
     void toggleSmartInsertDelete();
     void toggleAutomaticQuoteSubstitution();

Modified: branches/safari-608.2.11.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp (250135 => 250136)


--- branches/safari-608.2.11.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-09-20 17:24:17 UTC (rev 250135)
+++ branches/safari-608.2.11.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-09-20 18:18:14 UTC (rev 250136)
@@ -1554,7 +1554,7 @@
 }
 
 // LoadRequestWaitingForPID should never be sent to the WebProcess. It must always be converted to a LoadRequest message.
-NO_RETURN void WebPage::loadRequestWaitingForPID(LoadParameters&&, const String&)
+NO_RETURN void WebPage::loadRequestWaitingForPID(LoadParameters&&, URL&&, PageIdentifier)
 {
     RELEASE_ASSERT_NOT_REACHED();
 }

Modified: branches/safari-608.2.11.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.h (250135 => 250136)


--- branches/safari-608.2.11.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-09-20 17:24:17 UTC (rev 250135)
+++ branches/safari-608.2.11.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-09-20 18:18:14 UTC (rev 250136)
@@ -1309,7 +1309,7 @@
     void tryClose();
     void platformDidReceiveLoadParameters(const LoadParameters&);
     void loadRequest(LoadParameters&&);
-    void loadRequestWaitingForPID(LoadParameters&&, const String&);
+    NO_RETURN void loadRequestWaitingForPID(LoadParameters&&, URL&&, WebCore::PageIdentifier);
     void loadData(LoadParameters&&);
     void loadAlternateHTML(LoadParameters&&);
     void navigateToPDFLinkWithSimulatedClick(const String& url, WebCore::IntPoint documentPoint, WebCore::IntPoint screenPoint);

Modified: branches/safari-608.2.11.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (250135 => 250136)


--- branches/safari-608.2.11.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2019-09-20 17:24:17 UTC (rev 250135)
+++ branches/safari-608.2.11.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2019-09-20 18:18:14 UTC (rev 250136)
@@ -165,7 +165,7 @@
     LoadURLInFrame(URL url, String referrer, uint64_t frameID)
     LoadDataInFrame(IPC::DataReference data, String MIMEType, String encodingName, URL baseURL, uint64_t frameID)
     LoadRequest(struct WebKit::LoadParameters loadParameters)
-    LoadRequestWaitingForPID(struct WebKit::LoadParameters loadParameters, String sandboxExtensionPath)
+    LoadRequestWaitingForPID(struct WebKit::LoadParameters loadParameters, URL resourceDirectoryURL, WebCore::PageIdentifier pageID)
     LoadData(struct WebKit::LoadParameters loadParameters)
     LoadAlternateHTML(struct WebKit::LoadParameters loadParameters)
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to