Title: [277641] trunk/Source/WebKit
Revision
277641
Author
rn...@webkit.org
Date
2021-05-17 22:15:15 -0700 (Mon, 17 May 2021)

Log Message

Enabling IPC testing API should prevent WebContent process from getting terminated in more cases
https://bugs.webkit.org/show_bug.cgi?id=225906

Reviewed by Wenson Hsieh.

Avoid hitting debug assertions in WebContent process when a dispatched message isn't processed
in a message receivers and don't kill WebContent process in GPU processs when RemoteRenderingBackend
receives a bad IPC message.

Also fixed a typo in encodeSharedMemory where we were exiting early when the protection was ReadWrite
instead of when it was not ReadWrite or ReadOnly.

These fixes are needed to land tests for recent GPU process fixes.

* GPUProcess/graphics/RemoteRenderingBackend.cpp:
* Scripts/webkit/messages.py:
(generate_message_handler):
* WebProcess/WebPage/IPCTestingAPI.cpp:
(WebKit::IPCTestingAPI::encodeSharedMemory):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::ensureGPUProcessConnection):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (277640 => 277641)


--- trunk/Source/WebKit/ChangeLog	2021-05-18 04:26:45 UTC (rev 277640)
+++ trunk/Source/WebKit/ChangeLog	2021-05-18 05:15:15 UTC (rev 277641)
@@ -1,3 +1,29 @@
+2021-05-17  Ryosuke Niwa  <rn...@webkit.org>
+
+        Enabling IPC testing API should prevent WebContent process from getting terminated in more cases
+        https://bugs.webkit.org/show_bug.cgi?id=225906
+
+        Reviewed by Wenson Hsieh.
+
+        Avoid hitting debug assertions in WebContent process when a dispatched message isn't processed
+        in a message receivers and don't kill WebContent process in GPU processs when RemoteRenderingBackend
+        receives a bad IPC message.
+
+        Also fixed a typo in encodeSharedMemory where we were exiting early when the protection was ReadWrite
+        instead of when it was not ReadWrite or ReadOnly.
+
+        These fixes are needed to land tests for recent GPU process fixes.
+
+        * GPUProcess/graphics/RemoteRenderingBackend.cpp:
+        * Scripts/webkit/messages.py:
+        (generate_message_handler):
+        * WebProcess/WebPage/IPCTestingAPI.cpp:
+        (WebKit::IPCTestingAPI::encodeSharedMemory):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::ensureGPUProcessConnection):
+
 2021-05-17  Wenson Hsieh  <wenson_hs...@apple.com>
 
         [GPU Process] Object identifiers with the deleted value should cause MESSAGE_CHECKs

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp (277640 => 277641)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp	2021-05-18 04:26:45 UTC (rev 277640)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp	2021-05-18 05:15:15 UTC (rev 277641)
@@ -43,9 +43,17 @@
 #include <wtf/SystemTracing.h>
 #include <wtf/WorkQueue.h>
 
+#if ENABLE(IPC_TESTING_API)
+#define WEB_PROCESS_TERMINATE_CONDITION !m_gpuConnectionToWebProcess->connection().ignoreInvalidMessageForTesting()
+#else
+#define WEB_PROCESS_TERMINATE_CONDITION true
+#endif
+
 #define TERMINATE_WEB_PROCESS_WITH_MESSAGE(message) \
-    RELEASE_LOG_FAULT(IPC, "Requesting termination of web process %" PRIu64 " for reason: %" PUBLIC_LOG_STRING, m_gpuConnectionToWebProcess->webProcessIdentifier().toUInt64(), #message); \
-    m_gpuConnectionToWebProcess->terminateWebProcess();
+    if (WEB_PROCESS_TERMINATE_CONDITION) { \
+        RELEASE_LOG_FAULT(IPC, "Requesting termination of web process %" PRIu64 " for reason: %" PUBLIC_LOG_STRING, m_gpuConnectionToWebProcess->webProcessIdentifier().toUInt64(), #message); \
+        m_gpuConnectionToWebProcess->terminateWebProcess(); \
+    }
 
 #define MESSAGE_CHECK(assertion, message) do { \
     if (UNLIKELY(!(assertion))) { \

Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (277640 => 277641)


--- trunk/Source/WebKit/Scripts/webkit/messages.py	2021-05-18 04:26:45 UTC (rev 277640)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py	2021-05-18 05:15:15 UTC (rev 277641)
@@ -954,6 +954,10 @@
         else:
             result.append('    UNUSED_PARAM(decoder);\n')
             result.append('    UNUSED_PARAM(connection);\n')
+            result.append('#if ENABLE(IPC_TESTING_API)\n')
+            result.append('    if (connection.connection().ignoreInvalidMessageForTesting())\n')
+            result.append('        return;\n')
+            result.append('#endif // ENABLE(IPC_TESTING_API)\n')
             result.append('    ASSERT_NOT_REACHED_WITH_MESSAGE("Unhandled stream message %s to %" PRIu64, description(decoder.messageName()), decoder.destinationID());\n')
         result.append('}\n')
     elif async_messages or receiver.has_attribute(WANTS_DISPATCH_MESSAGE_ATTRIBUTE) or receiver.has_attribute(WANTS_ASYNC_DISPATCH_MESSAGE_ATTRIBUTE):
@@ -973,6 +977,10 @@
         else:
             result.append('    UNUSED_PARAM(connection);\n')
             result.append('    UNUSED_PARAM(decoder);\n')
+            result.append('#if ENABLE(IPC_TESTING_API)\n')
+            result.append('    if (connection.ignoreInvalidMessageForTesting())\n')
+            result.append('        return;\n')
+            result.append('#endif // ENABLE(IPC_TESTING_API)\n')
             result.append('    ASSERT_NOT_REACHED_WITH_MESSAGE("Unhandled message %s to %" PRIu64, description(decoder.messageName()), decoder.destinationID());\n')
         result.append('}\n')
 
@@ -989,6 +997,10 @@
         result.append('    UNUSED_PARAM(connection);\n')
         result.append('    UNUSED_PARAM(decoder);\n')
         result.append('    UNUSED_PARAM(replyEncoder);\n')
+        result.append('#if ENABLE(IPC_TESTING_API)\n')
+        result.append('    if (connection.ignoreInvalidMessageForTesting())\n')
+        result.append('        return false;\n')
+        result.append('#endif // ENABLE(IPC_TESTING_API)\n')
         result.append('    ASSERT_NOT_REACHED_WITH_MESSAGE("Unhandled synchronous message %s to %" PRIu64, description(decoder.messageName()), decoder.destinationID());\n')
         result.append('    return false;\n')
         result.append('}\n')

Modified: trunk/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp (277640 => 277641)


--- trunk/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp	2021-05-18 04:26:45 UTC (rev 277640)
+++ trunk/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp	2021-05-18 05:15:15 UTC (rev 277641)
@@ -814,7 +814,7 @@
     auto protection = SharedMemory::Protection::ReadWrite;
     if (equalLettersIgnoringASCIICase(protectionValue, "readonly"))
         protection = SharedMemory::Protection::ReadOnly;
-    else if (equalLettersIgnoringASCIICase(protectionValue, "readwrite"))
+    else if (!equalLettersIgnoringASCIICase(protectionValue, "readwrite"))
         return false;
 
     encoder << SharedMemory::IPCHandle { jsSharedMemory->createHandle(protection), dataSize };

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (277640 => 277641)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-05-18 04:26:45 UTC (rev 277640)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-05-18 05:15:15 UTC (rev 277641)
@@ -3995,6 +3995,10 @@
 
 #if ENABLE(IPC_TESTING_API)
     m_ipcTestingAPIEnabled = store.getBoolValueForKey(WebPreferencesKey::ipcTestingAPIEnabledKey());
+
+    WebProcess::singleton().parentProcessConnection()->setIgnoreInvalidMessageForTesting();
+    if (auto* gpuProcessConnection = WebProcess::singleton().existingGPUProcessConnection())
+        gpuProcessConnection->connection().setIgnoreInvalidMessageForTesting();
 #endif
 
 #if ENABLE(WEB_AUTHN) && PLATFORM(IOS)

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (277640 => 277641)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2021-05-18 04:26:45 UTC (rev 277640)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2021-05-18 05:15:15 UTC (rev 277641)
@@ -1240,6 +1240,10 @@
         ASSERT(connectionInfo.auditToken);
         m_gpuProcessConnection->setAuditToken(WTFMove(connectionInfo.auditToken));
 #endif
+#if ENABLE(IPC_TESTING_API)
+        if (parentProcessConnection()->ignoreInvalidMessageForTesting())
+            m_gpuProcessConnection->connection().setIgnoreInvalidMessageForTesting();
+#endif
 
         for (auto& page : m_pageMap.values()) {
             // If page is null, then it is currently being constructed.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to