Title: [250110] trunk/Source/WebKit
Revision
250110
Author
[email protected]
Date
2019-09-19 16:55:36 -0700 (Thu, 19 Sep 2019)

Log Message

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:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (250109 => 250110)


--- trunk/Source/WebKit/ChangeLog	2019-09-19 23:34:06 UTC (rev 250109)
+++ trunk/Source/WebKit/ChangeLog	2019-09-19 23:55:36 UTC (rev 250110)
@@ -1,3 +1,34 @@
+2019-09-19  Chris Dumez  <[email protected]>
+
+        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  Tim Horton  <[email protected]>
 
         macCatalyst apps crash under TextCheckingControllerProxy::replaceRelativeToSelection when spell checking

Modified: trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp (250109 => 250110)


--- trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp	2019-09-19 23:34:06 UTC (rev 250109)
+++ trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp	2019-09-19 23:55:36 UTC (rev 250110)
@@ -30,6 +30,8 @@
 #include "LoadParameters.h"
 #include "Logging.h"
 #include "WebPageMessages.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
 #include <wtf/RunLoop.h>
 
 namespace WebKit {
@@ -217,12 +219,16 @@
             auto bufferSize = encoder->bufferSize();
             std::unique_ptr<IPC::Decoder> decoder = makeUnique<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;
+            WebPageProxyIdentifier 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
         if (pendingMessage.asyncReplyInfo)

Modified: trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.h (250109 => 250110)


--- trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.h	2019-09-19 23:34:06 UTC (rev 250109)
+++ trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.h	2019-09-19 23:55:36 UTC (rev 250110)
@@ -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: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (250109 => 250110)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-09-19 23:34:06 UTC (rev 250109)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-09-19 23:55:36 UTC (rev 250110)
@@ -1066,6 +1066,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;
@@ -1176,19 +1183,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), webPageID);
-    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), webPageID);
-    }
+    else
+        process->send(Messages::WebPage::LoadRequestWaitingForPID(loadParameters, m_pageLoadState.resourceDirectoryURL(), m_identifier), webPageID);
 #else
     process->send(Messages::WebPage::LoadRequest(loadParameters), webPageID);
 #endif
@@ -1230,26 +1228,20 @@
 
     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_identifier), m_webPageID);
+    else
         m_process->send(Messages::WebPage::LoadRequest(loadParameters), m_webPageID);
-    else
-        m_process->send(Messages::WebPage::LoadRequestWaitingForPID(loadParameters, resourceDirectoryPath), m_webPageID);
 #else
     m_process->send(Messages::WebPage::LoadRequest(loadParameters), m_webPageID);
 #endif

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (250109 => 250110)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-09-19 23:34:06 UTC (rev 250109)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-09-19 23:55:36 UTC (rev 250110)
@@ -1585,6 +1585,8 @@
     void setMockCaptureDevicesEnabledOverride(Optional<bool>);
 #endif
 
+    void maybeInitializeSandboxExtensionHandle(WebProcessProxy&, const URL&, const URL& resourceDirectoryURL, SandboxExtension::Handle&);
+
 private:
     WebPageProxy(PageClient&, WebProcessProxy&, Ref<API::PageConfiguration>&&);
     void platformInitialize();
@@ -1925,8 +1927,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: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (250109 => 250110)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-09-19 23:34:06 UTC (rev 250109)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-09-19 23:55:36 UTC (rev 250110)
@@ -1553,7 +1553,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&&, WebPageProxyIdentifier)
 {
     RELEASE_ASSERT_NOT_REACHED();
 }

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (250109 => 250110)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-09-19 23:34:06 UTC (rev 250109)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-09-19 23:55:36 UTC (rev 250110)
@@ -1317,7 +1317,7 @@
     void tryClose();
     void platformDidReceiveLoadParameters(const LoadParameters&);
     void loadRequest(LoadParameters&&);
-    NO_RETURN void loadRequestWaitingForPID(LoadParameters&&, const String&);
+    NO_RETURN void loadRequestWaitingForPID(LoadParameters&&, URL&&, WebPageProxyIdentifier);
     void loadData(LoadParameters&&);
     void loadAlternateHTML(LoadParameters&&);
     void navigateToPDFLinkWithSimulatedClick(const String& url, WebCore::IntPoint documentPoint, WebCore::IntPoint screenPoint);

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (250109 => 250110)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2019-09-19 23:34:06 UTC (rev 250109)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2019-09-19 23:55:36 UTC (rev 250110)
@@ -165,7 +165,7 @@
     LoadURLInFrame(URL url, String referrer, WebCore::FrameIdentifier frameID)
     LoadDataInFrame(IPC::DataReference data, String MIMEType, String encodingName, URL baseURL, WebCore::FrameIdentifier frameID)
     LoadRequest(struct WebKit::LoadParameters loadParameters)
-    LoadRequestWaitingForPID(struct WebKit::LoadParameters loadParameters, String sandboxExtensionPath)
+    LoadRequestWaitingForPID(struct WebKit::LoadParameters loadParameters, URL resourceDirectoryURL, WebKit::WebPageProxyIdentifier pageID)
     LoadData(struct WebKit::LoadParameters loadParameters)
     LoadAlternateHTML(struct WebKit::LoadParameters loadParameters)
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to