Title: [250673] trunk
Revision
250673
Author
[email protected]
Date
2019-10-03 13:08:24 -0700 (Thu, 03 Oct 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.

Source/WebKit:

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 audit token of the Networking process when creating these.
This patch implements getting the audit token for the Networking process when the WebProcess is sending a message to
the UI process to establish the Networking process connection. The audit token is stored in the NetworkProcessConnection
object, and passed to the NetworkLoadParameters object when the load is started. Finally, when encoding the Network
resources load parameters, the audit token is used to create an extension for the Networking process.

API test: WKWebView.LoadFileWithLoadRequest

* NetworkProcess/NetworkLoadParameters.h:
* NetworkProcess/NetworkResourceLoadParameters.cpp:
(WebKit::NetworkResourceLoadParameters::encode const):
* Platform/IPC/ArgumentCoders.cpp:
(IPC::ArgumentCoder<audit_token_t>::encode):
(IPC::ArgumentCoder<audit_token_t>::decode):
* Platform/IPC/ArgumentCoders.h:
* Shared/Cocoa/SandboxExtensionCocoa.mm:
(WebKit::SandboxExtensionImpl::create):
(WebKit::SandboxExtensionImpl::sandboxExtensionForType):
(WebKit::SandboxExtensionImpl::SandboxExtensionImpl):
(WebKit::SandboxExtension::createHandleForMachLookupByPid):
(WebKit::SandboxExtension::createHandleForReadByPid):
(WebKit::SandboxExtension::createHandleForReadByAuditToken):
* Shared/SandboxExtension.h:
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::openNetworkProcessConnection):
* UIProcess/WebProcessProxy.messages.in:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/Network/NetworkProcessConnection.h:
(WebKit::NetworkProcessConnection::setNetworkProcessAuditToken):
(WebKit::NetworkProcessConnection::networkProcessAuditToken const):
* WebProcess/Network/NetworkProcessConnectionInfo.h: Added.
(WebKit::NetworkProcessConnectionInfo::identifier):
(WebKit::NetworkProcessConnectionInfo::encode const):
(WebKit::NetworkProcessConnectionInfo::decode):
* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
(WebKit::WebLoaderStrategy::loadResourceSynchronously):
(WebKit::WebLoaderStrategy::startPingLoad):
(WebKit::WebLoaderStrategy::preconnectTo):
* WebProcess/WebProcess.cpp:
(WebKit::getNetworkProcessConnection):
(WebKit::WebProcess::ensureNetworkProcessConnection):

Source/WTF:

Add HAVE_AUDIT_TOKEN and SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_AUDIT_TOKEN defines.

* wtf/Platform.h:

Tools:

Added API test WKWebView.LoadFileWithLoadRequest.

* TestWebKitAPI/Tests/WebKitCocoa/LoadFileURL.mm:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (250672 => 250673)


--- trunk/Source/WTF/ChangeLog	2019-10-03 19:38:52 UTC (rev 250672)
+++ trunk/Source/WTF/ChangeLog	2019-10-03 20:08:24 UTC (rev 250673)
@@ -1,3 +1,14 @@
+2019-10-03  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.
+
+        Add HAVE_AUDIT_TOKEN and SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_AUDIT_TOKEN defines.
+
+        * wtf/Platform.h:
+
 2019-10-02  Myles C. Maxfield  <[email protected]>
 
         REGRESSION (r245672): <select> dropdown with text-rendering: optimizeLegibility freezes Safari

Modified: trunk/Source/WTF/wtf/Platform.h (250672 => 250673)


--- trunk/Source/WTF/wtf/Platform.h	2019-10-03 19:38:52 UTC (rev 250672)
+++ trunk/Source/WTF/wtf/Platform.h	2019-10-03 20:08:24 UTC (rev 250673)
@@ -693,6 +693,7 @@
 #define HAVE_PTHREAD_SETNAME_NP 1
 #define HAVE_READLINE 1
 #define HAVE_SYS_TIMEB_H 1
+#define HAVE_AUDIT_TOKEN 1
 
 #if __has_include(<mach/mach_exc.defs>) && !PLATFORM(GTK)
 #define HAVE_MACH_EXCEPTIONS 1
@@ -1527,6 +1528,10 @@
 #define HAVE_SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID 1
 #endif
 
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500)
+#define HAVE_SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_AUDIT_TOKEN 1
+#endif
+
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000)
 #define HAVE_MDNS_FAST_REGISTRATION 1
 #endif

Modified: trunk/Source/WebKit/ChangeLog (250672 => 250673)


--- trunk/Source/WebKit/ChangeLog	2019-10-03 19:38:52 UTC (rev 250672)
+++ trunk/Source/WebKit/ChangeLog	2019-10-03 20:08:24 UTC (rev 250673)
@@ -1,3 +1,57 @@
+2019-10-03  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 audit token of the Networking process when creating these.
+        This patch implements getting the audit token for the Networking process when the WebProcess is sending a message to
+        the UI process to establish the Networking process connection. The audit token is stored in the NetworkProcessConnection
+        object, and passed to the NetworkLoadParameters object when the load is started. Finally, when encoding the Network
+        resources load parameters, the audit token is used to create an extension for the Networking process.
+
+        API test: WKWebView.LoadFileWithLoadRequest
+
+        * NetworkProcess/NetworkLoadParameters.h:
+        * NetworkProcess/NetworkResourceLoadParameters.cpp:
+        (WebKit::NetworkResourceLoadParameters::encode const):
+        * Platform/IPC/ArgumentCoders.cpp:
+        (IPC::ArgumentCoder<audit_token_t>::encode):
+        (IPC::ArgumentCoder<audit_token_t>::decode):
+        * Platform/IPC/ArgumentCoders.h:
+        * Shared/Cocoa/SandboxExtensionCocoa.mm:
+        (WebKit::SandboxExtensionImpl::create):
+        (WebKit::SandboxExtensionImpl::sandboxExtensionForType):
+        (WebKit::SandboxExtensionImpl::SandboxExtensionImpl):
+        (WebKit::SandboxExtension::createHandleForMachLookupByPid):
+        (WebKit::SandboxExtension::createHandleForReadByPid):
+        (WebKit::SandboxExtension::createHandleForReadByAuditToken):
+        * Shared/SandboxExtension.h:
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::openNetworkProcessConnection):
+        * UIProcess/WebProcessProxy.messages.in:
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/Network/NetworkProcessConnection.h:
+        (WebKit::NetworkProcessConnection::setNetworkProcessAuditToken):
+        (WebKit::NetworkProcessConnection::networkProcessAuditToken const):
+        * WebProcess/Network/NetworkProcessConnectionInfo.h: Added.
+        (WebKit::NetworkProcessConnectionInfo::identifier):
+        (WebKit::NetworkProcessConnectionInfo::encode const):
+        (WebKit::NetworkProcessConnectionInfo::decode):
+        * WebProcess/Network/WebLoaderStrategy.cpp:
+        (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
+        (WebKit::WebLoaderStrategy::loadResourceSynchronously):
+        (WebKit::WebLoaderStrategy::startPingLoad):
+        (WebKit::WebLoaderStrategy::preconnectTo):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::getNetworkProcessConnection):
+        (WebKit::WebProcess::ensureNetworkProcessConnection):
+
 2019-10-03  Konstantin Tokarev  <[email protected]>
 
         CMake-built WebKit.framework should launch XPC services successfully

Modified: trunk/Source/WebKit/NetworkProcess/NetworkLoadParameters.h (250672 => 250673)


--- trunk/Source/WebKit/NetworkProcess/NetworkLoadParameters.h	2019-10-03 19:38:52 UTC (rev 250672)
+++ trunk/Source/WebKit/NetworkProcess/NetworkLoadParameters.h	2019-10-03 20:08:24 UTC (rev 250673)
@@ -46,6 +46,9 @@
     WebCore::FrameIdentifier webFrameID;
     RefPtr<WebCore::SecurityOrigin> topOrigin;
     WTF::ProcessID parentPID { 0 };
+#if HAVE(AUDIT_TOKEN)
+    Optional<audit_token_t> networkProcessAuditToken;
+#endif
     WebCore::ResourceRequest request;
     WebCore::ContentSniffingPolicy contentSniffingPolicy { WebCore::ContentSniffingPolicy::SniffContent };
     WebCore::ContentEncodingSniffingPolicy contentEncodingSniffingPolicy { WebCore::ContentEncodingSniffingPolicy::Sniff };

Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp (250672 => 250673)


--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp	2019-10-03 19:38:52 UTC (rev 250672)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp	2019-10-03 20:08:24 UTC (rev 250673)
@@ -66,7 +66,14 @@
 
     if (request.url().isLocalFile()) {
         SandboxExtension::Handle requestSandboxExtension;
+#if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_AUDIT_TOKEN)
+        if (networkProcessAuditToken)
+            SandboxExtension::createHandleForReadByAuditToken(request.url().fileSystemPath(), *networkProcessAuditToken, requestSandboxExtension);
+        else
+            SandboxExtension::createHandle(request.url().fileSystemPath(), SandboxExtension::Type::ReadOnly, requestSandboxExtension);
+#else
         SandboxExtension::createHandle(request.url().fileSystemPath(), SandboxExtension::Type::ReadOnly, requestSandboxExtension);
+#endif
         encoder << requestSandboxExtension;
     }
 

Modified: trunk/Source/WebKit/Platform/IPC/ArgumentCoders.cpp (250672 => 250673)


--- trunk/Source/WebKit/Platform/IPC/ArgumentCoders.cpp	2019-10-03 19:38:52 UTC (rev 250672)
+++ trunk/Source/WebKit/Platform/IPC/ArgumentCoders.cpp	2019-10-03 20:08:24 UTC (rev 250673)
@@ -188,4 +188,21 @@
     return decoder.decodeFixedLengthData(digest.data(), sizeof(digest), 1);
 }
 
+#if HAVE(AUDIT_TOKEN)
+void ArgumentCoder<audit_token_t>::encode(Encoder& encoder, const audit_token_t& auditToken)
+{
+    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(auditToken.val); i++)
+        encoder << auditToken.val[i];
+}
+
+bool ArgumentCoder<audit_token_t>::decode(Decoder& decoder, audit_token_t& auditToken)
+{
+    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(auditToken.val); i++) {
+        if (!decoder.decode(auditToken.val[i]))
+            return false;
+    }
+    return true;
+}
+#endif
+
 } // namespace IPC

Modified: trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h (250672 => 250673)


--- trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h	2019-10-03 19:38:52 UTC (rev 250672)
+++ trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h	2019-10-03 20:08:24 UTC (rev 250673)
@@ -621,4 +621,11 @@
     static bool decode(Decoder&, SHA1::Digest&);
 };
 
+#if HAVE(AUDIT_TOKEN)
+template<> struct ArgumentCoder<audit_token_t> {
+    static void encode(Encoder&, const audit_token_t&);
+    static bool decode(Decoder&, audit_token_t&);
+};
+#endif
+
 } // namespace IPC

Modified: trunk/Source/WebKit/Shared/Cocoa/SandboxExtensionCocoa.mm (250672 => 250673)


--- trunk/Source/WebKit/Shared/Cocoa/SandboxExtensionCocoa.mm	2019-10-03 19:38:52 UTC (rev 250672)
+++ trunk/Source/WebKit/Shared/Cocoa/SandboxExtensionCocoa.mm	2019-10-03 20:08:24 UTC (rev 250673)
@@ -32,6 +32,7 @@
 #import "Decoder.h"
 #import "Encoder.h"
 #import <wtf/FileSystem.h>
+#import <wtf/Variant.h>
 #import <wtf/spi/darwin/SandboxSPI.h>
 #import <wtf/text/CString.h>
 
@@ -40,9 +41,9 @@
 class SandboxExtensionImpl {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    static std::unique_ptr<SandboxExtensionImpl> create(const char* path, SandboxExtension::Type type, Optional<pid_t> pid = WTF::nullopt)
+    static std::unique_ptr<SandboxExtensionImpl> create(const char* path, SandboxExtension::Type type, Optional<Variant<pid_t, audit_token_t>> processToken = WTF::nullopt)
     {
-        std::unique_ptr<SandboxExtensionImpl> impl { new SandboxExtensionImpl(path, type, pid) };
+        std::unique_ptr<SandboxExtensionImpl> impl { new SandboxExtensionImpl(path, type, processToken) };
         if (!impl->m_token)
             return nullptr;
         return impl;
@@ -84,7 +85,7 @@
     }
 
 private:
-    char* sandboxExtensionForType(const char* path, SandboxExtension::Type type, Optional<pid_t> pid = WTF::nullopt)
+    char* sandboxExtensionForType(const char* path, SandboxExtension::Type type, Optional<Variant<pid_t, audit_token_t>> processToken)
     {
         switch (type) {
         case SandboxExtension::Type::ReadOnly:
@@ -93,19 +94,29 @@
             return sandbox_extension_issue_file(APP_SANDBOX_READ_WRITE, path, 0);
         case SandboxExtension::Type::Mach:
 #if HAVE(SANDBOX_ISSUE_MACH_EXTENSION_TO_PROCESS_BY_PID)
-            return sandbox_extension_issue_mach_to_process_by_pid("com.apple.webkit.extension.mach"_s, path, 0, pid.value());
+            if (!processToken)
+                return nullptr;
+            if (!WTF::holds_alternative<pid_t>(*processToken))
+                return nullptr;
+            return sandbox_extension_issue_mach_to_process_by_pid("com.apple.webkit.extension.mach"_s, path, 0, WTF::get<pid_t>(*processToken));
 #else
-            UNUSED_PARAM(pid);
+            UNUSED_PARAM(processToken);
             ASSERT_NOT_REACHED();
             return nullptr;
 #endif
         case SandboxExtension::Type::Generic:
             return sandbox_extension_issue_generic(path, 0);
-        case SandboxExtension::Type::ReadByPid:
+        case SandboxExtension::Type::ReadByProcess:
 #if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID)
-            return sandbox_extension_issue_file_to_process_by_pid(APP_SANDBOX_READ, path, SANDBOX_EXTENSION_USER_INTENT, pid.value());
+            if (!processToken)
+                return nullptr;
+            if (WTF::holds_alternative<pid_t>(*processToken))
+                return sandbox_extension_issue_file_to_process_by_pid(APP_SANDBOX_READ, path, SANDBOX_EXTENSION_USER_INTENT, WTF::get<pid_t>(*processToken));
+            if (WTF::holds_alternative<audit_token_t>(*processToken))
+                return sandbox_extension_issue_file_to_process(APP_SANDBOX_READ, path, SANDBOX_EXTENSION_USER_INTENT, WTF::get<audit_token_t>(*processToken));
+            return nullptr;
 #else
-            UNUSED_PARAM(pid);
+            UNUSED_PARAM(processToken);
             ASSERT_NOT_REACHED();
             return nullptr;
 #endif
@@ -112,8 +123,8 @@
         }
     }
 
-    SandboxExtensionImpl(const char* path, SandboxExtension::Type type, Optional<pid_t> pid = WTF::nullopt)
-        : m_token { sandboxExtensionForType(path, type, pid) }
+    SandboxExtensionImpl(const char* path, SandboxExtension::Type type, Optional<Variant<pid_t, audit_token_t>> processToken)
+        : m_token { sandboxExtensionForType(path, type, processToken) }
     {
     }
 
@@ -336,7 +347,8 @@
 {
     ASSERT(!handle.m_sandboxExtension);
     
-    handle.m_sandboxExtension = SandboxExtensionImpl::create(service.utf8().data(), Type::Mach, pid);
+    Variant<pid_t, audit_token_t> processToken(pid);
+    handle.m_sandboxExtension = SandboxExtensionImpl::create(service.utf8().data(), Type::Mach, WTFMove(processToken));
     if (!handle.m_sandboxExtension) {
         WTFLogAlways("Could not create a '%s' sandbox extension", service.utf8().data());
         return false;
@@ -352,7 +364,8 @@
     if (!pid)
         return false;
 
-    handle.m_sandboxExtension = SandboxExtensionImpl::create(path.utf8().data(), Type::ReadByPid, pid);
+    Variant<pid_t, audit_token_t> processToken(pid);
+    handle.m_sandboxExtension = SandboxExtensionImpl::create(path.utf8().data(), Type::ReadByProcess, WTFMove(processToken));
     if (!handle.m_sandboxExtension) {
         WTFLogAlways("Could not create sandbox extension");
         return false;
@@ -361,6 +374,20 @@
     return true;
 }
 
+bool SandboxExtension::createHandleForReadByAuditToken(const String& path, audit_token_t auditToken, Handle& handle)
+{
+    ASSERT(!handle.m_sandboxExtension);
+
+    Variant<pid_t, audit_token_t> processToken(auditToken);
+    handle.m_sandboxExtension = SandboxExtensionImpl::create(path.utf8().data(), Type::ReadByProcess, WTFMove(processToken));
+    if (!handle.m_sandboxExtension) {
+        WTFLogAlways("Could not create sandbox extension");
+        return false;
+    }
+    
+    return true;
+}
+
 SandboxExtension::SandboxExtension(const Handle& handle)
     : m_sandboxExtension(WTFMove(handle.m_sandboxExtension))
 {

Modified: trunk/Source/WebKit/Shared/SandboxExtension.h (250672 => 250673)


--- trunk/Source/WebKit/Shared/SandboxExtension.h	2019-10-03 19:38:52 UTC (rev 250672)
+++ trunk/Source/WebKit/Shared/SandboxExtension.h	2019-10-03 20:08:24 UTC (rev 250673)
@@ -49,7 +49,7 @@
         ReadWrite,
         Mach,
         Generic,
-        ReadByPid
+        ReadByProcess
     };
 
     class Handle {
@@ -106,6 +106,9 @@
     static bool createHandleForGenericExtension(const String& extensionClass, Handle&);
     static bool createHandleForMachLookupByPid(const String& service, ProcessID, Handle&);
     static bool createHandleForReadByPid(const String& path, ProcessID, Handle&);
+#if HAVE(AUDIT_TOKEN)
+    static bool createHandleForReadByAuditToken(const String& path, audit_token_t, Handle&);
+#endif
     ~SandboxExtension();
 
     bool consume();

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (250672 => 250673)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2019-10-03 19:38:52 UTC (rev 250672)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2019-10-03 20:08:24 UTC (rev 250673)
@@ -36,6 +36,7 @@
 #endif
 #include "Logging.h"
 #include "NetworkContentRuleListManagerMessages.h"
+#include "NetworkProcessConnectionInfo.h"
 #include "NetworkProcessCreationParameters.h"
 #include "NetworkProcessMessages.h"
 #include "SandboxExtension.h"
@@ -158,10 +159,10 @@
         auto request = m_connectionRequests.take(connectionRequestIdentifier);
 
 #if USE(UNIX_DOMAIN_SOCKETS) || OS(WINDOWS)
-        request.reply(*connectionIdentifier);
+        request.reply(NetworkProcessConnectionInfo { WTFMove(*connectionIdentifier) });
 #elif OS(DARWIN)
         MESSAGE_CHECK(MACH_PORT_VALID(connectionIdentifier->port()));
-        request.reply(IPC::Attachment { connectionIdentifier->port(), MACH_MSG_TYPE_MOVE_SEND });
+        request.reply(NetworkProcessConnectionInfo { IPC::Attachment { connectionIdentifier->port(), MACH_MSG_TYPE_MOVE_SEND }, connection()->getAuditToken() });
 #else
         notImplemented();
 #endif

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.messages.in (250672 => 250673)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.messages.in	2019-10-03 19:38:52 UTC (rev 250672)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.messages.in	2019-10-03 20:08:24 UTC (rev 250673)
@@ -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() -> (struct WebKit::NetworkProcessConnectionInfo connectionInfo) Synchronous
     ProcessReadyToSuspend()
     DidCancelProcessSuspension()
 

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (250672 => 250673)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2019-10-03 19:38:52 UTC (rev 250672)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2019-10-03 20:08:24 UTC (rev 250673)
@@ -4704,6 +4704,7 @@
 		E1E552C316AE065E004ED653 /* SandboxInitializationParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SandboxInitializationParameters.h; sourceTree = "<group>"; };
 		E1EE53DC11F8CF9F00CCBEE4 /* InjectedBundlePageEditorClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundlePageEditorClient.h; sourceTree = "<group>"; };
 		E1EE53E611F8CFFB00CCBEE4 /* InjectedBundlePageEditorClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundlePageEditorClient.cpp; sourceTree = "<group>"; };
+		E3439B632345463A0011DE0B /* NetworkProcessConnectionInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NetworkProcessConnectionInfo.h; path = Network/NetworkProcessConnectionInfo.h; sourceTree = "<group>"; };
 		E404907021DE65F70037F0DB /* ScrollerPairMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollerPairMac.h; sourceTree = "<group>"; };
 		E404907121DE65F70037F0DB /* ScrollingTreeFrameScrollingNodeRemoteMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingTreeFrameScrollingNodeRemoteMac.cpp; sourceTree = "<group>"; };
 		E404907221DE65F70037F0DB /* ScrollerPairMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollerPairMac.mm; sourceTree = "<group>"; };
@@ -6707,6 +6708,7 @@
 				5105B0D4162F7A7A00E27709 /* NetworkProcessConnection.cpp */,
 				5105B0D5162F7A7A00E27709 /* NetworkProcessConnection.h */,
 				51FB0902163A3B1C00EC324A /* NetworkProcessConnection.messages.in */,
+				E3439B632345463A0011DE0B /* NetworkProcessConnectionInfo.h */,
 				51ABF65616392F1500132A7A /* WebLoaderStrategy.cpp */,
 				51ABF65716392F1500132A7A /* WebLoaderStrategy.h */,
 				A5860E6F230F67DE00461AAE /* WebResourceInterceptController.cpp */,

Modified: trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h (250672 => 250673)


--- trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h	2019-10-03 19:38:52 UTC (rev 250672)
+++ trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h	2019-10-03 20:08:24 UTC (rev 250673)
@@ -76,6 +76,11 @@
     WebSWClientConnection& serviceWorkerConnection();
 #endif
 
+#if HAVE(AUDIT_TOKEN)
+    void setNetworkProcessAuditToken(Optional<audit_token_t> auditToken) { m_networkProcessAuditToken = auditToken; }
+    Optional<audit_token_t> networkProcessAuditToken() const { return m_networkProcessAuditToken; }
+#endif
+
 private:
     NetworkProcessConnection(IPC::Connection::Identifier);
 
@@ -99,6 +104,9 @@
 
     // The connection from the web process to the network process.
     Ref<IPC::Connection> m_connection;
+#if HAVE(AUDIT_TOKEN)
+    Optional<audit_token_t> m_networkProcessAuditToken;
+#endif
 
 #if ENABLE(INDEXED_DATABASE)
     RefPtr<WebIDBConnectionToServer> m_webIDBConnection;

Added: trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnectionInfo.h (0 => 250673)


--- trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnectionInfo.h	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnectionInfo.h	2019-10-03 20:08:24 UTC (rev 250673)
@@ -0,0 +1,70 @@
+/*
+* Copyright (C) 2019 Apple Inc. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* 1. Redistributions of source code must retain the above copyright
+*    notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+*    notice, this list of conditions and the following disclaimer in the
+*    documentation and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+* THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#pragma once
+
+namespace WebKit {
+
+struct NetworkProcessConnectionInfo {
+    IPC::Attachment connection;
+#if HAVE(AUDIT_TOKEN)
+    Optional<audit_token_t> auditToken;
+#endif
+
+    IPC::Connection::Identifier identifier()
+    {
+#if USE(UNIX_DOMAIN_SOCKETS)
+        return IPC::Connection::Identifier(connection.fileDescriptor());
+#elif OS(DARWIN)
+        return IPC::Connection::Identifier(connection.port());
+#elif OS(WINDOWS)
+        return IPC::Connection::Identifier(connection.handle());
+#else
+        ASSERT_NOT_REACHED();
+        return IPC::Connection::Identifier();
+#endif
+    }
+    
+    void encode(IPC::Encoder& encoder) const
+    {
+        encoder << connection;
+#if HAVE(AUDIT_TOKEN)
+        encoder << auditToken;
+#endif
+    }
+    
+    static bool decode(IPC::Decoder& decoder, NetworkProcessConnectionInfo& info)
+    {
+        if (!decoder.decode(info.connection))
+            return false;
+#if HAVE(AUDIT_TOKEN)
+        if (!decoder.decode(info.auditToken))
+            return false;
+#endif
+        return true;
+    }
+};
+
+};

Modified: trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp (250672 => 250673)


--- trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp	2019-10-03 19:38:52 UTC (rev 250672)
+++ trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp	2019-10-03 20:08:24 UTC (rev 250673)
@@ -286,6 +286,9 @@
     loadParameters.webPageID = trackingParameters.pageID;
     loadParameters.webFrameID = trackingParameters.frameID;
     loadParameters.parentPID = presentingApplicationPID();
+#if HAVE(AUDIT_TOKEN)
+    loadParameters.networkProcessAuditToken = WebProcess::singleton().ensureNetworkProcessConnection().networkProcessAuditToken();
+#endif
     loadParameters.request = request;
     loadParameters.contentSniffingPolicy = contentSniffingPolicy;
     loadParameters.contentEncodingSniffingPolicy = contentEncodingSniffingPolicy;
@@ -561,6 +564,9 @@
     loadParameters.webPageID = pageID;
     loadParameters.webFrameID = frameID;
     loadParameters.parentPID = presentingApplicationPID();
+#if HAVE(AUDIT_TOKEN)
+    loadParameters.networkProcessAuditToken = WebProcess::singleton().ensureNetworkProcessConnection().networkProcessAuditToken();
+#endif
     loadParameters.request = request;
     loadParameters.contentSniffingPolicy = ContentSniffingPolicy::SniffContent;
     loadParameters.contentEncodingSniffingPolicy = ContentEncodingSniffingPolicy::Sniff;
@@ -630,6 +636,9 @@
     loadParameters.sourceOrigin = &document->securityOrigin();
     loadParameters.topOrigin = &document->topOrigin();
     loadParameters.parentPID = presentingApplicationPID();
+#if HAVE(AUDIT_TOKEN)
+    loadParameters.networkProcessAuditToken = WebProcess::singleton().ensureNetworkProcessConnection().networkProcessAuditToken();
+#endif
     loadParameters.storedCredentialsPolicy = options.credentials == FetchOptions::Credentials::Omit ? StoredCredentialsPolicy::DoNotUse : StoredCredentialsPolicy::Use;
     loadParameters.options = options;
     loadParameters.originalRequestHeaders = originalRequestHeaders;
@@ -690,6 +699,9 @@
     parameters.webPageID = webPage->identifier();
     parameters.webFrameID = webFrame->frameID();
     parameters.parentPID = presentingApplicationPID();
+#if HAVE(AUDIT_TOKEN)
+    parameters.networkProcessAuditToken = WebProcess::singleton().ensureNetworkProcessConnection().networkProcessAuditToken();
+#endif
     parameters.storedCredentialsPolicy = storedCredentialsPolicy;
     parameters.shouldPreconnectOnly = PreconnectOnly::Yes;
     parameters.shouldRestrictHTTPResponseAccess = shouldPerformSecurityChecks();

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (250672 => 250673)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2019-10-03 19:38:52 UTC (rev 250672)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2019-10-03 20:08:24 UTC (rev 250673)
@@ -38,6 +38,7 @@
 #include "Logging.h"
 #include "NetworkConnectionToWebProcessMessages.h"
 #include "NetworkProcessConnection.h"
+#include "NetworkProcessConnectionInfo.h"
 #include "NetworkSession.h"
 #include "NetworkSessionCreationParameters.h"
 #include "PluginProcessConnectionManager.h"
@@ -1137,10 +1138,10 @@
     injectedBundle->setBundleParameters(value);
 }
 
-static IPC::Connection::Identifier getNetworkProcessConnection(IPC::Connection& connection)
+static NetworkProcessConnectionInfo getNetworkProcessConnection(IPC::Connection& connection)
 {
-    IPC::Attachment encodedConnectionIdentifier;
-    if (!connection.sendSync(Messages::WebProcessProxy::GetNetworkProcessConnection(), Messages::WebProcessProxy::GetNetworkProcessConnection::Reply(encodedConnectionIdentifier), 0)) {
+    NetworkProcessConnectionInfo connectionInfo;
+    if (!connection.sendSync(Messages::WebProcessProxy::GetNetworkProcessConnection(), Messages::WebProcessProxy::GetNetworkProcessConnection::Reply(connectionInfo), 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
@@ -1153,16 +1154,7 @@
 #endif
     }
 
-#if USE(UNIX_DOMAIN_SOCKETS)
-    return encodedConnectionIdentifier.releaseFileDescriptor();
-#elif OS(DARWIN)
-    return encodedConnectionIdentifier.port();
-#elif OS(WINDOWS)
-    return encodedConnectionIdentifier.handle();
-#else
-    ASSERT_NOT_REACHED();
-    return IPC::Connection::Identifier();
-#endif
+    return connectionInfo;
 }
 
 NetworkProcessConnection& WebProcess::ensureNetworkProcessConnection()
@@ -1172,17 +1164,20 @@
 
     // 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 connectionInfo = getNetworkProcessConnection(*parentProcessConnection());
 
         // 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(connectionInfo.identifier()))
+            connectionInfo = getNetworkProcessConnection(*parentProcessConnection());
 
-        if (!IPC::Connection::identifierIsValid(connectionIdentifier))
+        if (!IPC::Connection::identifierIsValid(connectionInfo.identifier()))
             CRASH();
 
-        m_networkProcessConnection = NetworkProcessConnection::create(connectionIdentifier);
+        m_networkProcessConnection = NetworkProcessConnection::create(connectionInfo.identifier());
+#if HAVE(AUDIT_TOKEN)
+        m_networkProcessConnection->setNetworkProcessAuditToken(WTFMove(connectionInfo.auditToken));
+#endif
     }
     
     return *m_networkProcessConnection;

Modified: trunk/Tools/ChangeLog (250672 => 250673)


--- trunk/Tools/ChangeLog	2019-10-03 19:38:52 UTC (rev 250672)
+++ trunk/Tools/ChangeLog	2019-10-03 20:08:24 UTC (rev 250673)
@@ -1,3 +1,14 @@
+2019-10-03  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.
+
+        Added API test WKWebView.LoadFileWithLoadRequest.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/LoadFileURL.mm:
+
 2019-10-03  Jonathan Bedard  <[email protected]>
 
         Add myself to various tools watchlists

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadFileURL.mm (250672 => 250673)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadFileURL.mm	2019-10-03 19:38:52 UTC (rev 250672)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadFileURL.mm	2019-10-03 20:08:24 UTC (rev 250673)
@@ -32,7 +32,18 @@
 #import <WebKit/WebViewPrivate.h>
 #import <wtf/RetainPtr.h>
 
+TEST(WKWebView, LoadFileWithLoadRequest)
+{
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
 
+    auto delegate = adoptNS([[TestNavigationDelegate alloc] init]);
+    [webView setNavigationDelegate:delegate.get()];
+
+    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+    [webView loadRequest:request];
+    [delegate waitForDidFinishNavigation];
+}
+
 TEST(WKWebView, LoadTwoFiles)
 {
     auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to