Title: [249910] trunk/Source/WebKit
Revision
249910
Author
[email protected]
Date
2019-09-16 12:15:51 -0700 (Mon, 16 Sep 2019)

Log Message

REGRESSION(249649): Unable to open local files in MiniBrowser on macOS
https://bugs.webkit.org/show_bug.cgi?id=201798

Reviewed by Brent Fulgham.

The commit <https://trac.webkit.org/changeset/249649> introduced a MiniBrowser regression on macOS where
MiniBrowser is not able to open local files. The change set r249649 fixed a problem where the WebContent
process PID was not ready to be used when creating a sandbox extension. This happened in the cases where
the WebContent process had not finished launching when the load started. The WebContent process is also
creating sandbox extensions for the Networking process for the files being loaded, and also needs to be
passing the PID of the Networking process when creating these. This patch is addressing this by getting
the PID of the Networking process when the WebContent process is initially getting the connection to the
Networking process. The PID is then stored in the NetworkProcessConnection class, from where it is passed
to the NetworkLoadParameters, and used when creating the sandbox extension for the Networking process.

* NetworkProcess/NetworkLoadParameters.h:
* NetworkProcess/NetworkResourceLoadParameters.cpp:
(WebKit::NetworkResourceLoadParameters::encode const):
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::~NetworkProcessProxy):
(WebKit::NetworkProcessProxy::openNetworkProcessConnection):
(WebKit::NetworkProcessProxy::networkProcessCrashed):
(WebKit::NetworkProcessProxy::didFinishLaunching):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::loadRequestWithNavigationShared):
* UIProcess/WebProcessProxy.messages.in:
* WebProcess/Network/NetworkProcessConnection.cpp:
(WebKit::NetworkProcessConnection::NetworkProcessConnection):
* WebProcess/Network/NetworkProcessConnection.h:
(WebKit::NetworkProcessConnection::create):
(WebKit::NetworkProcessConnection::networkProcessPID const):
* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
* WebProcess/WebProcess.cpp:
(WebKit::getNetworkProcessConnection):
(WebKit::WebProcess::ensureNetworkProcessConnection):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (249909 => 249910)


--- trunk/Source/WebKit/ChangeLog	2019-09-16 18:59:18 UTC (rev 249909)
+++ trunk/Source/WebKit/ChangeLog	2019-09-16 19:15:51 UTC (rev 249910)
@@ -1,3 +1,42 @@
+2019-09-16  Per Arne Vollan  <[email protected]>
+
+        REGRESSION(249649): Unable to open local files in MiniBrowser on macOS
+        https://bugs.webkit.org/show_bug.cgi?id=201798
+
+        Reviewed by Brent Fulgham.
+
+        The commit <https://trac.webkit.org/changeset/249649> introduced a MiniBrowser regression on macOS where
+        MiniBrowser is not able to open local files. The change set r249649 fixed a problem where the WebContent
+        process PID was not ready to be used when creating a sandbox extension. This happened in the cases where
+        the WebContent process had not finished launching when the load started. The WebContent process is also
+        creating sandbox extensions for the Networking process for the files being loaded, and also needs to be
+        passing the PID of the Networking process when creating these. This patch is addressing this by getting
+        the PID of the Networking process when the WebContent process is initially getting the connection to the
+        Networking process. The PID is then stored in the NetworkProcessConnection class, from where it is passed
+        to the NetworkLoadParameters, and used when creating the sandbox extension for the Networking process.
+
+        * NetworkProcess/NetworkLoadParameters.h:
+        * NetworkProcess/NetworkResourceLoadParameters.cpp:
+        (WebKit::NetworkResourceLoadParameters::encode const):
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::~NetworkProcessProxy):
+        (WebKit::NetworkProcessProxy::openNetworkProcessConnection):
+        (WebKit::NetworkProcessProxy::networkProcessCrashed):
+        (WebKit::NetworkProcessProxy::didFinishLaunching):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::loadRequestWithNavigationShared):
+        * UIProcess/WebProcessProxy.messages.in:
+        * WebProcess/Network/NetworkProcessConnection.cpp:
+        (WebKit::NetworkProcessConnection::NetworkProcessConnection):
+        * WebProcess/Network/NetworkProcessConnection.h:
+        (WebKit::NetworkProcessConnection::create):
+        (WebKit::NetworkProcessConnection::networkProcessPID const):
+        * WebProcess/Network/WebLoaderStrategy.cpp:
+        (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::getNetworkProcessConnection):
+        (WebKit::WebProcess::ensureNetworkProcessConnection):
+
 2019-09-16  David Kilzer  <[email protected]>
 
         [WebAuthn] REGRESSION (r249059): Leak of WKMockNFTag objects and WKMockNFTag instance variables

Modified: trunk/Source/WebKit/NetworkProcess/NetworkLoadParameters.h (249909 => 249910)


--- trunk/Source/WebKit/NetworkProcess/NetworkLoadParameters.h	2019-09-16 18:59:18 UTC (rev 249909)
+++ trunk/Source/WebKit/NetworkProcess/NetworkLoadParameters.h	2019-09-16 19:15:51 UTC (rev 249910)
@@ -53,6 +53,7 @@
     WebCore::FrameIdentifier webFrameID;
     RefPtr<WebCore::SecurityOrigin> topOrigin;
     WTF::ProcessID parentPID { 0 };
+    WTF::ProcessID networkProcessPID { 0 };
     WebCore::ResourceRequest request;
     WebCore::ContentSniffingPolicy contentSniffingPolicy { WebCore::ContentSniffingPolicy::SniffContent };
     WebCore::ContentEncodingSniffingPolicy contentEncodingSniffingPolicy { WebCore::ContentEncodingSniffingPolicy::Sniff };

Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp (249909 => 249910)


--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp	2019-09-16 18:59:18 UTC (rev 249909)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp	2019-09-16 19:15:51 UTC (rev 249910)
@@ -67,7 +67,11 @@
 
     if (request.url().isLocalFile()) {
         SandboxExtension::Handle requestSandboxExtension;
+#if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID)
+        SandboxExtension::createHandleForReadByPid(request.url().fileSystemPath(), networkProcessPID, requestSandboxExtension);
+#else
         SandboxExtension::createHandle(request.url().fileSystemPath(), SandboxExtension::Type::ReadOnly, requestSandboxExtension);
+#endif
         encoder << requestSandboxExtension;
     }
 

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (249909 => 249910)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2019-09-16 18:59:18 UTC (rev 249909)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2019-09-16 19:15:51 UTC (rev 249910)
@@ -104,7 +104,7 @@
         m_downloadProxyMap->invalidate();
 
     for (auto& request : m_connectionRequests.values())
-        request.reply({ });
+        request.reply({ }, 0);
 }
 
 void NetworkProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& launchOptions)
@@ -156,10 +156,10 @@
         auto request = m_connectionRequests.take(connectionRequestIdentifier);
 
 #if USE(UNIX_DOMAIN_SOCKETS) || OS(WINDOWS)
-        request.reply(*connectionIdentifier);
+        request.reply(*connectionIdentifier, processIdentifier());
 #elif OS(DARWIN)
         MESSAGE_CHECK(MACH_PORT_VALID(connectionIdentifier->port()));
-        request.reply(IPC::Attachment { connectionIdentifier->port(), MACH_MSG_TYPE_MOVE_SEND });
+        request.reply(IPC::Attachment { connectionIdentifier->port(), MACH_MSG_TYPE_MOVE_SEND }, processIdentifier());
 #else
         notImplemented();
 #endif
@@ -248,7 +248,7 @@
         if (request.webProcess)
             pendingRequests.uncheckedAppend(std::make_pair(makeRefPtr(request.webProcess.get()), WTFMove(request.reply)));
         else
-            request.reply({ });
+            request.reply({ }, 0);
     }
     m_connectionRequests.clear();
 
@@ -394,7 +394,7 @@
         if (connectionRequest.webProcess)
             getNetworkProcessConnection(*connectionRequest.webProcess, WTFMove(connectionRequest.reply));
         else
-            connectionRequest.reply({ });
+            connectionRequest.reply({ }, 0);
     }
 
 #if PLATFORM(COCOA)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (249909 => 249910)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-09-16 18:59:18 UTC (rev 249909)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-09-16 19:15:51 UTC (rev 249910)
@@ -1175,7 +1175,7 @@
     addPlatformLoadParameters(loadParameters);
 
 #if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID)
-    if (processIdentifier() || !url.isLocalFile())
+    if (process->processIdentifier() || !url.isLocalFile())
         process->send(Messages::WebPage::LoadRequest(loadParameters), webPageID);
     else {
         String sandboxExtensionPath;

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.messages.in (249909 => 249910)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.messages.in	2019-09-16 18:59:18 UTC (rev 249909)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.messages.in	2019-09-16 19:15:51 UTC (rev 249910)
@@ -36,7 +36,7 @@
     GetPlugins(bool refresh) -> (Vector<WebCore::PluginInfo> plugins, Vector<WebCore::PluginInfo> applicationPlugins, struct Optional<Vector<WebCore::SupportedPluginIdentifier>> supportedPluginIdentifiers) Synchronous
     GetPluginProcessConnection(uint64_t pluginProcessToken) -> (IPC::Attachment connectionHandle, bool supportsAsynchronousInitialization) Synchronous
 #endif
-    GetNetworkProcessConnection() -> (IPC::Attachment connectionHandle) Synchronous
+    GetNetworkProcessConnection() -> (IPC::Attachment connectionHandle, int32_t pid) Synchronous
     ProcessReadyToSuspend()
     DidCancelProcessSuspension()
 

Modified: trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp (249909 => 249910)


--- trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp	2019-09-16 18:59:18 UTC (rev 249909)
+++ trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp	2019-09-16 19:15:51 UTC (rev 249910)
@@ -68,8 +68,9 @@
 namespace WebKit {
 using namespace WebCore;
 
-NetworkProcessConnection::NetworkProcessConnection(IPC::Connection::Identifier connectionIdentifier)
+NetworkProcessConnection::NetworkProcessConnection(IPC::Connection::Identifier connectionIdentifier, WTF::ProcessID pid)
     : m_connection(IPC::Connection::createClientConnection(connectionIdentifier, *this))
+    , m_networkProcessPID(pid)
 {
     m_connection->open();
 }

Modified: trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h (249909 => 249910)


--- trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h	2019-09-16 18:59:18 UTC (rev 249909)
+++ trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h	2019-09-16 19:15:51 UTC (rev 249910)
@@ -58,9 +58,9 @@
 
 class NetworkProcessConnection : public RefCounted<NetworkProcessConnection>, IPC::Connection::Client {
 public:
-    static Ref<NetworkProcessConnection> create(IPC::Connection::Identifier connectionIdentifier)
+    static Ref<NetworkProcessConnection> create(IPC::Connection::Identifier connectionIdentifier, WTF::ProcessID pid)
     {
-        return adoptRef(*new NetworkProcessConnection(connectionIdentifier));
+        return adoptRef(*new NetworkProcessConnection(connectionIdentifier, pid));
     }
     ~NetworkProcessConnection();
     
@@ -80,8 +80,10 @@
     WebSWClientConnection& serviceWorkerConnectionForSession(PAL::SessionID);
 #endif
 
+    WTF::ProcessID networkProcessPID() const { return m_networkProcessPID; }
+
 private:
-    NetworkProcessConnection(IPC::Connection::Identifier);
+    NetworkProcessConnection(IPC::Connection::Identifier, WTF::ProcessID);
 
     // IPC::Connection::Client
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
@@ -103,6 +105,7 @@
 
     // The connection from the web process to the network process.
     Ref<IPC::Connection> m_connection;
+    WTF::ProcessID m_networkProcessPID { 0 };
 
 #if ENABLE(INDEXED_DATABASE)
     HashMap<uint64_t, RefPtr<WebIDBConnectionToServer>> m_webIDBConnectionsBySession;

Modified: trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp (249909 => 249910)


--- trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp	2019-09-16 18:59:18 UTC (rev 249909)
+++ trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp	2019-09-16 19:15:51 UTC (rev 249910)
@@ -285,6 +285,7 @@
     loadParameters.webPageID = trackingParameters.pageID;
     loadParameters.webFrameID = trackingParameters.frameID;
     loadParameters.parentPID = presentingApplicationPID();
+    loadParameters.networkProcessPID = WebProcess::singleton().ensureNetworkProcessConnection().networkProcessPID();
     loadParameters.request = request;
     loadParameters.contentSniffingPolicy = contentSniffingPolicy;
     loadParameters.contentEncodingSniffingPolicy = contentEncodingSniffingPolicy;

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (249909 => 249910)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2019-09-16 18:59:18 UTC (rev 249909)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2019-09-16 19:15:51 UTC (rev 249910)
@@ -1162,10 +1162,11 @@
     injectedBundle->setBundleParameters(value);
 }
 
-static IPC::Connection::Identifier getNetworkProcessConnection(IPC::Connection& connection)
+static std::pair<IPC::Connection::Identifier, WTF::ProcessID> getNetworkProcessConnection(IPC::Connection& connection)
 {
     IPC::Attachment encodedConnectionIdentifier;
-    if (!connection.sendSync(Messages::WebProcessProxy::GetNetworkProcessConnection(), Messages::WebProcessProxy::GetNetworkProcessConnection::Reply(encodedConnectionIdentifier), 0)) {
+    WTF::ProcessID pid;
+    if (!connection.sendSync(Messages::WebProcessProxy::GetNetworkProcessConnection(), Messages::WebProcessProxy::GetNetworkProcessConnection::Reply(encodedConnectionIdentifier, pid), 0)) {
 #if PLATFORM(GTK) || PLATFORM(WPE)
         // GTK+ and WPE ports don't exit on send sync message failure.
         // In this particular case, the network process can be terminated by the UI process while the
@@ -1179,14 +1180,14 @@
     }
 
 #if USE(UNIX_DOMAIN_SOCKETS)
-    return encodedConnectionIdentifier.releaseFileDescriptor();
+    return std::make_pair(encodedConnectionIdentifier.releaseFileDescriptor(), pid);
 #elif OS(DARWIN)
-    return encodedConnectionIdentifier.port();
+    return std::make_pair(encodedConnectionIdentifier.port(), pid);
 #elif OS(WINDOWS)
-    return encodedConnectionIdentifier.handle();
+    return std::make_pair(encodedConnectionIdentifier.handle(), pid);
 #else
     ASSERT_NOT_REACHED();
-    return IPC::Connection::Identifier();
+    return std::make_pair(IPC::Connection::Identifier(), pid);
 #endif
 }
 
@@ -1197,17 +1198,23 @@
 
     // If we've lost our connection to the network process (e.g. it crashed) try to re-establish it.
     if (!m_networkProcessConnection) {
-        IPC::Connection::Identifier connectionIdentifier = getNetworkProcessConnection(*parentProcessConnection());
+        auto connectionIdentifierAndPID = getNetworkProcessConnection(*parentProcessConnection());
+        
+        IPC::Connection::Identifier connectionIdentifier = connectionIdentifierAndPID.first;
+        WTF::ProcessID pid = connectionIdentifierAndPID.second;
 
         // Retry once if the IPC to get the connectionIdentifier succeeded but the connectionIdentifier we received
         // is invalid. This may indicate that the network process has crashed.
-        if (!IPC::Connection::identifierIsValid(connectionIdentifier))
-            connectionIdentifier = getNetworkProcessConnection(*parentProcessConnection());
+        if (!IPC::Connection::identifierIsValid(connectionIdentifier)) {
+            connectionIdentifierAndPID = getNetworkProcessConnection(*parentProcessConnection());
+            connectionIdentifier = connectionIdentifierAndPID.first;
+            pid = connectionIdentifierAndPID.second;
+        }
 
         if (!IPC::Connection::identifierIsValid(connectionIdentifier))
             CRASH();
 
-        m_networkProcessConnection = NetworkProcessConnection::create(connectionIdentifier);
+        m_networkProcessConnection = NetworkProcessConnection::create(connectionIdentifier, pid);
     }
     
     return *m_networkProcessConnection;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to