Title: [211747] trunk/Source/WebKit2
Revision
211747
Author
ander...@apple.com
Date
2017-02-06 13:49:54 -0800 (Mon, 06 Feb 2017)

Log Message

Crash child processes if they receive an invalid message
https://bugs.webkit.org/show_bug.cgi?id=167900

Reviewed by Dan Bernstein.

Previously, some processes would try to gracefully exit, others would just drop messages leading to weird bugs.
Instead, set app-specific crash information to the message that failed to be decoded, and then crash.

* DatabaseProcess/DatabaseProcess.cpp:
(WebKit::DatabaseProcess::didReceiveInvalidMessage): Deleted.
* DatabaseProcess/DatabaseProcess.h:
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::didReceiveInvalidMessage): Deleted.
* NetworkProcess/NetworkProcess.h:
* PluginProcess/PluginProcess.cpp:
(WebKit::PluginProcess::didReceiveInvalidMessage): Deleted.
* PluginProcess/PluginProcess.h:
* Shared/ChildProcess.h:
* Shared/Cocoa/ChildProcessCocoa.mm: Added.
(WebKit::ChildProcess::didReceiveInvalidMessage):
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::didReceiveInvalidMessage): Deleted.
* WebProcess/WebProcess.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (211746 => 211747)


--- trunk/Source/WebKit2/ChangeLog	2017-02-06 21:49:24 UTC (rev 211746)
+++ trunk/Source/WebKit2/ChangeLog	2017-02-06 21:49:54 UTC (rev 211747)
@@ -1,3 +1,30 @@
+2017-02-06  Anders Carlsson  <ander...@apple.com>
+
+        Crash child processes if they receive an invalid message
+        https://bugs.webkit.org/show_bug.cgi?id=167900
+
+        Reviewed by Dan Bernstein.
+
+        Previously, some processes would try to gracefully exit, others would just drop messages leading to weird bugs.
+        Instead, set app-specific crash information to the message that failed to be decoded, and then crash.
+
+        * DatabaseProcess/DatabaseProcess.cpp:
+        (WebKit::DatabaseProcess::didReceiveInvalidMessage): Deleted.
+        * DatabaseProcess/DatabaseProcess.h:
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::didReceiveInvalidMessage): Deleted.
+        * NetworkProcess/NetworkProcess.h:
+        * PluginProcess/PluginProcess.cpp:
+        (WebKit::PluginProcess::didReceiveInvalidMessage): Deleted.
+        * PluginProcess/PluginProcess.h:
+        * Shared/ChildProcess.h:
+        * Shared/Cocoa/ChildProcessCocoa.mm: Added.
+        (WebKit::ChildProcess::didReceiveInvalidMessage):
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::didReceiveInvalidMessage): Deleted.
+        * WebProcess/WebProcess.h:
+
 2017-02-06  Chris Dumez  <cdu...@apple.com>
 
         [WK2] Drop legacy WKBundlePageDiagnosticLoggingClient API

Modified: trunk/Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp (211746 => 211747)


--- trunk/Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp	2017-02-06 21:49:24 UTC (rev 211746)
+++ trunk/Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp	2017-02-06 21:49:54 UTC (rev 211747)
@@ -90,11 +90,6 @@
     }
 }
 
-void DatabaseProcess::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference, IPC::StringReference)
-{
-    stopRunLoop();
-}
-
 #if ENABLE(INDEXED_DATABASE)
 IDBServer::IDBServer& DatabaseProcess::idbServer()
 {

Modified: trunk/Source/WebKit2/DatabaseProcess/DatabaseProcess.h (211746 => 211747)


--- trunk/Source/WebKit2/DatabaseProcess/DatabaseProcess.h	2017-02-06 21:49:24 UTC (rev 211746)
+++ trunk/Source/WebKit2/DatabaseProcess/DatabaseProcess.h	2017-02-06 21:49:54 UTC (rev 211747)
@@ -93,7 +93,6 @@
     // IPC::Connection::Client
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
     void didClose(IPC::Connection&) override;
-    void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName) override;
     void didReceiveDatabaseProcessMessage(IPC::Connection&, IPC::Decoder&);
 
     // Message Handlers

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp (211746 => 211747)


--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp	2017-02-06 21:49:24 UTC (rev 211746)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp	2017-02-06 21:49:54 UTC (rev 211747)
@@ -170,11 +170,6 @@
     stopRunLoop();
 }
 
-void NetworkProcess::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference, IPC::StringReference)
-{
-    stopRunLoop();
-}
-
 void NetworkProcess::didCreateDownload()
 {
     disableTermination();

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h (211746 => 211747)


--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h	2017-02-06 21:49:24 UTC (rev 211746)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h	2017-02-06 21:49:54 UTC (rev 211747)
@@ -141,7 +141,6 @@
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
     void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) override;
     void didClose(IPC::Connection&) override;
-    void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName) override;
 
     // DownloadManager::Client
     void didCreateDownload() override;

Modified: trunk/Source/WebKit2/PluginProcess/PluginProcess.cpp (211746 => 211747)


--- trunk/Source/WebKit2/PluginProcess/PluginProcess.cpp	2017-02-06 21:49:24 UTC (rev 211746)
+++ trunk/Source/WebKit2/PluginProcess/PluginProcess.cpp	2017-02-06 21:49:54 UTC (rev 211747)
@@ -121,10 +121,6 @@
     stopRunLoop();
 }
 
-void PluginProcess::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference, IPC::StringReference)
-{
-}
-
 void PluginProcess::initializePluginProcess(PluginProcessCreationParameters&& parameters)
 {
     ASSERT(!m_pluginModule);

Modified: trunk/Source/WebKit2/PluginProcess/PluginProcess.h (211746 => 211747)


--- trunk/Source/WebKit2/PluginProcess/PluginProcess.h	2017-02-06 21:49:24 UTC (rev 211746)
+++ trunk/Source/WebKit2/PluginProcess/PluginProcess.h	2017-02-06 21:49:54 UTC (rev 211747)
@@ -89,7 +89,6 @@
     // IPC::Connection::Client
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
     void didClose(IPC::Connection&) override;
-    void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName) override;
 
     // Message handlers.
     void didReceivePluginProcessMessage(IPC::Connection&, IPC::Decoder&);

Modified: trunk/Source/WebKit2/Shared/ChildProcess.cpp (211746 => 211747)


--- trunk/Source/WebKit2/Shared/ChildProcess.cpp	2017-02-06 21:49:24 UTC (rev 211746)
+++ trunk/Source/WebKit2/Shared/ChildProcess.cpp	2017-02-06 21:49:54 UTC (rev 211747)
@@ -196,6 +196,11 @@
 void ChildProcess::initializeSandbox(const ChildProcessInitializationParameters&, SandboxInitializationParameters&)
 {
 }
+
+void ChildProcess::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference, IPC::StringReference)
+{
+    CRASH();
+}
 #endif
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/Shared/ChildProcess.h (211746 => 211747)


--- trunk/Source/WebKit2/Shared/ChildProcess.h	2017-02-06 21:49:24 UTC (rev 211746)
+++ trunk/Source/WebKit2/Shared/ChildProcess.h	2017-02-06 21:49:54 UTC (rev 211747)
@@ -108,6 +108,9 @@
     IPC::Connection* messageSenderConnection() override;
     uint64_t messageSenderDestinationID() override;
 
+    // IPC::Connection::Client.
+    void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName) final;
+
     void shutDown();
 
     void terminationTimerFired();

Added: trunk/Source/WebKit2/Shared/Cocoa/ChildProcessCocoa.mm (0 => 211747)


--- trunk/Source/WebKit2/Shared/Cocoa/ChildProcessCocoa.mm	                        (rev 0)
+++ trunk/Source/WebKit2/Shared/Cocoa/ChildProcessCocoa.mm	2017-02-06 21:49:54 UTC (rev 211747)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#import "config.h"
+#import "ChildProcess.h"
+
+#import <WebKitSystemInterface.h>
+
+namespace WebKit {
+
+void ChildProcess::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageName, IPC::StringReference messageReceiverName)
+{
+    WKSetCrashReportApplicationSpecificInformation((__bridge CFStringRef)[NSString stringWithFormat:@"Received invalid message: '%s::%s'", messageReceiverName.toString().data(), messageName.toString().data()]);
+    CRASH();
+}
+
+}

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (211746 => 211747)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2017-02-06 21:49:24 UTC (rev 211746)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2017-02-06 21:49:54 UTC (rev 211747)
@@ -287,6 +287,7 @@
 		1A6563E51B7A8C50009CF787 /* APIWindowFeatures.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6563E31B7A8C50009CF787 /* APIWindowFeatures.h */; };
 		1A66BF8F18A052ED002071B4 /* WKWebViewInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A66BF8E18A052ED002071B4 /* WKWebViewInternal.h */; };
 		1A67CD2E1CBC513F00BFE3EA /* WKOpenPanelParametersInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A67CD2D1CBC513F00BFE3EA /* WKOpenPanelParametersInternal.h */; };
+		1A698F191E4910220064E881 /* ChildProcessCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A698F171E4910220064E881 /* ChildProcessCocoa.mm */; };
 		1A6D86C11DF75265007745E8 /* MachMessage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6D86BF1DF75265007745E8 /* MachMessage.cpp */; };
 		1A6D86C21DF75265007745E8 /* MachMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6D86C01DF75265007745E8 /* MachMessage.h */; };
 		1A6FA21E1BD0435B00AAA650 /* WKFrameInfoPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6FA21D1BD0435B00AAA650 /* WKFrameInfoPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -2376,6 +2377,7 @@
 		1A6563E31B7A8C50009CF787 /* APIWindowFeatures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIWindowFeatures.h; sourceTree = "<group>"; };
 		1A66BF8E18A052ED002071B4 /* WKWebViewInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewInternal.h; sourceTree = "<group>"; };
 		1A67CD2D1CBC513F00BFE3EA /* WKOpenPanelParametersInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKOpenPanelParametersInternal.h; sourceTree = "<group>"; };
+		1A698F171E4910220064E881 /* ChildProcessCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ChildProcessCocoa.mm; sourceTree = "<group>"; };
 		1A6D141F1B0167D500785FF0 /* Info-OSX-10.9-10.10.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-OSX-10.9-10.10.plist"; sourceTree = "<group>"; };
 		1A6D14211B01681600785FF0 /* PluginService.32-64-10.9-10.10.Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "PluginService.32-64-10.9-10.10.Info.plist"; path = "PluginProcess/EntryPoint/mac/XPCService/PluginService.32-64-10.9-10.10.Info.plist"; sourceTree = SOURCE_ROOT; };
 		1A6D86BF1DF75265007745E8 /* MachMessage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MachMessage.cpp; sourceTree = "<group>"; };
@@ -5516,6 +5518,7 @@
 			children = (
 				1A1EF1971A1D5B420023200A /* APIDataCocoa.mm */,
 				378E1A3B181ED6FF0031007A /* APIObject.mm */,
+				1A698F171E4910220064E881 /* ChildProcessCocoa.mm */,
 				37BEC4DF19491486008B4286 /* CompletionHandlerCallChecker.h */,
 				37BEC4DE19491486008B4286 /* CompletionHandlerCallChecker.mm */,
 				C55F916C1C595E440029E92D /* DataDetectionResult.h */,
@@ -9857,6 +9860,7 @@
 				413075AE1DE85F580039EC69 /* LibWebRTCSocket.cpp in Sources */,
 				BC0E607412D6BC200012A72A /* WebGeolocationPosition.cpp in Sources */,
 				BC1BE1F312D54DBD0004A228 /* WebGeolocationProvider.cpp in Sources */,
+				1A698F191E4910220064E881 /* ChildProcessCocoa.mm in Sources */,
 				2D5036751BCED19F00E20BB3 /* WebGestureEvent.cpp in Sources */,
 				93A88B361BC6EAD500ABA5C2 /* WebHitTestResultData.cpp in Sources */,
 				93A88B301BC6E99700ABA5C2 /* WebHitTestResultData.mm in Sources */,

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (211746 => 211747)


--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2017-02-06 21:49:24 UTC (rev 211746)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2017-02-06 21:49:54 UTC (rev 211747)
@@ -673,12 +673,6 @@
     stopRunLoop();
 }
 
-void WebProcess::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference, IPC::StringReference)
-{
-    // We received an invalid message, but since this is from the UI process (which we trust),
-    // we'll let it slide.
-}
-
 WebFrame* WebProcess::webFrame(uint64_t frameID) const
 {
     return m_frameMap.get(frameID);

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (211746 => 211747)


--- trunk/Source/WebKit2/WebProcess/WebProcess.h	2017-02-06 21:49:24 UTC (rev 211746)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h	2017-02-06 21:49:54 UTC (rev 211747)
@@ -338,7 +338,6 @@
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
     void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) override;
     void didClose(IPC::Connection&) override;
-    void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName) override;
 
     // Implemented in generated WebProcessMessageReceiver.cpp
     void didReceiveWebProcessMessage(IPC::Connection&, IPC::Decoder&);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to