Title: [270829] trunk/Source/WebKit
Revision
270829
Author
[email protected]
Date
2020-12-15 04:53:35 -0800 (Tue, 15 Dec 2020)

Log Message

[macOS] Add sandbox parameter for message filter entitlement status
https://bugs.webkit.org/show_bug.cgi?id=219852
<rdar://problem/72145560>

Reviewed by Brent Fulgham.

Add sandbox parameter to determine whether the WebContent process has message filter entitlement.
This parameter will be used in the sandbox to enable message filtering.

* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::initializeSandbox):
* WebProcess/com.apple.WebProcess.sb.in:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (270828 => 270829)


--- trunk/Source/WebKit/ChangeLog	2020-12-15 11:31:00 UTC (rev 270828)
+++ trunk/Source/WebKit/ChangeLog	2020-12-15 12:53:35 UTC (rev 270829)
@@ -1,3 +1,18 @@
+2020-12-15  Per Arne Vollan  <[email protected]>
+
+        [macOS] Add sandbox parameter for message filter entitlement status
+        https://bugs.webkit.org/show_bug.cgi?id=219852
+        <rdar://problem/72145560>
+
+        Reviewed by Brent Fulgham.
+
+        Add sandbox parameter to determine whether the WebContent process has message filter entitlement.
+        This parameter will be used in the sandbox to enable message filtering.
+
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::initializeSandbox):
+        * WebProcess/com.apple.WebProcess.sb.in:
+
 2020-12-15  Carlos Garcia Campos  <[email protected]>
 
         [SOUP] WebSockets: wrong data sent in some cases with libsoup < 2.68

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (270828 => 270829)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-12-15 11:31:00 UTC (rev 270828)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-12-15 12:53:35 UTC (rev 270829)
@@ -92,6 +92,7 @@
 #import <wtf/FileSystem.h>
 #import <wtf/ProcessPrivilege.h>
 #import <wtf/SoftLinking.h>
+#import <wtf/cocoa/Entitlements.h>
 #import <wtf/cocoa/NSURLExtras.h>
 #import <wtf/cocoa/RuntimeApplicationChecksCocoa.h>
 #import <wtf/cocoa/VectorCocoa.h>
@@ -671,6 +672,9 @@
 
     sandboxParameters.setOverrideSandboxProfilePath(makeString(String([webKitBundle resourcePath]), "/com.apple.WebProcess.sb"));
 
+    auto hasMessageFilterEntitlement = WTF::processHasEntitlement("com.apple.private.security.message-filter");
+    sandboxParameters.addParameter("ENABLE_SANDBOX_MESSAGE_FILTER", hasMessageFilterEntitlement ? "YES" : "NO");
+
     AuxiliaryProcess::initializeSandbox(parameters, sandboxParameters);
 #endif
 }

Modified: trunk/Source/WebKit/WebProcess/com.apple.WebProcess.sb.in (270828 => 270829)


--- trunk/Source/WebKit/WebProcess/com.apple.WebProcess.sb.in	2020-12-15 11:31:00 UTC (rev 270828)
+++ trunk/Source/WebKit/WebProcess/com.apple.WebProcess.sb.in	2020-12-15 12:53:35 UTC (rev 270829)
@@ -120,14 +120,16 @@
         (iokit-connection "IOAccelerator")
 #if HAVE(SANDBOX_MESSAGE_FILTERING)
         (with telemetry-backtrace)
-        (apply-message-filter
-            (allow
-                iokit-async-external-method
-                iokit-external-method
+        (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
+            (apply-message-filter
+                (allow
+                    iokit-async-external-method
+                    iokit-external-method
+                )
+                (allow (with telemetry)
+                    iokit-external-trap
+                )
             )
-            (allow (with telemetry)
-                iokit-external-trap
-            )
         )
 #endif
     )
@@ -135,11 +137,13 @@
         (iokit-registry-entry-class "IOAccelerationUserClient")
 #if HAVE(SANDBOX_MESSAGE_FILTERING)
         (with telemetry-backtrace)
-        (apply-message-filter
-            (allow (with telemetry)
-                iokit-async-external-method
-                iokit-external-trap
-                iokit-external-method
+        (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
+            (apply-message-filter
+                (allow (with telemetry)
+                    iokit-async-external-method
+                    iokit-external-trap
+                    iokit-external-method
+                )
             )
         )
 #endif
@@ -148,14 +152,16 @@
         (iokit-registry-entry-class "IOSurfaceRootUserClient")
 #if HAVE(SANDBOX_MESSAGE_FILTERING)
         (with telemetry-backtrace)
-        (apply-message-filter
-            (allow
-                iokit-async-external-method
-                iokit-external-method
+        (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
+            (apply-message-filter
+                (allow
+                    iokit-async-external-method
+                    iokit-external-method
+                )
+                (allow (with telemetry)
+                    iokit-external-trap
+                )
             )
-            (allow (with telemetry)
-                iokit-external-trap
-            )
         )
 #endif
     )
@@ -163,11 +169,13 @@
         (iokit-registry-entry-class "IOSurfaceSendRight")
 #if HAVE(SANDBOX_MESSAGE_FILTERING)
         (with telemetry-backtrace)
-        (apply-message-filter
-            (allow (with telemetry)
-                iokit-async-external-method
-                iokit-external-trap
-                iokit-external-method
+        (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
+            (apply-message-filter
+                (allow (with telemetry)
+                    iokit-async-external-method
+                    iokit-external-trap
+                    iokit-external-method
+                )
             )
         )
 #endif
@@ -186,18 +194,20 @@
         )
 #if HAVE(SANDBOX_MESSAGE_FILTERING)
         (with telemetry-backtrace)
-        (apply-message-filter
-            (allow
-                iokit-external-method
+        (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
+            (apply-message-filter
+                (allow
+                    iokit-external-method
+                )
+                (allow (with telemetry)
+                    iokit-async-external-method
+                    iokit-external-trap
+                )
             )
-            (allow (with telemetry)
-                iokit-async-external-method
-                iokit-external-trap
-            )
         )
 #endif
     )
-    
+
     ;; This is needed for Encrypted Media on some hardware (MacMini8,1 for example)
     (allow iokit-open
         (require-all
@@ -206,14 +216,16 @@
         )
 #if HAVE(SANDBOX_MESSAGE_FILTERING)
         (with telemetry-backtrace)
-        (apply-message-filter
-            (allow
-                iokit-external-method
+        (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
+            (apply-message-filter
+                (allow
+                    iokit-external-method
+                )
+                (allow (with telemetry)
+                    iokit-async-external-method
+                    iokit-external-trap
+                )
             )
-            (allow (with telemetry)
-                iokit-async-external-method
-                iokit-external-trap
-            )
         )
 #endif
     )
@@ -223,11 +235,13 @@
         (iokit-registry-entry-class "AGPMClient")
 #if HAVE(SANDBOX_MESSAGE_FILTERING)
         (with telemetry-backtrace)
-        (apply-message-filter
-            (allow (with telemetry)
-                iokit-async-external-method
-                iokit-external-trap
-                iokit-external-method
+        (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
+            (apply-message-filter
+                (allow (with telemetry)
+                    iokit-async-external-method
+                    iokit-external-trap
+                    iokit-external-method
+                )
             )
         )
 #endif
@@ -236,14 +250,16 @@
         (iokit-registry-entry-class "AppleGraphicsControlClient")
 #if HAVE(SANDBOX_MESSAGE_FILTERING)
         (with telemetry-backtrace)
-        (apply-message-filter
-            (allow
-                iokit-async-external-method
-                iokit-external-method
+        (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
+            (apply-message-filter
+                (allow
+                    iokit-async-external-method
+                    iokit-external-method
+                )
+                (allow (with telemetry)
+                    iokit-external-trap
+                )
             )
-            (allow (with telemetry)
-                iokit-external-trap
-            )
         )
 #endif
     )
@@ -251,11 +267,13 @@
         (iokit-registry-entry-class "AppleGraphicsPolicyClient")
 #if HAVE(SANDBOX_MESSAGE_FILTERING)
         (with telemetry-backtrace)
-        (apply-message-filter
-            (allow (with telemetry)
-                iokit-async-external-method
-                iokit-external-trap
-                iokit-external-method
+        (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
+            (apply-message-filter
+                (allow (with telemetry)
+                    iokit-async-external-method
+                    iokit-external-trap
+                    iokit-external-method
+                )
             )
         )
 #endif
@@ -265,11 +283,13 @@
         (iokit-registry-entry-class "AppleMGPUPowerControlClient")
 #if HAVE(SANDBOX_MESSAGE_FILTERING)
         (with telemetry-backtrace)
-        (apply-message-filter
-            (allow (with telemetry)
-                iokit-async-external-method
-                iokit-external-trap
-                iokit-external-method
+        (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
+            (apply-message-filter
+                (allow (with telemetry)
+                    iokit-async-external-method
+                    iokit-external-trap
+                    iokit-external-method
+                )
             )
         )
 #endif
@@ -852,11 +872,13 @@
     (iokit-user-client-class "AppleUpstreamUserClient")
 #if HAVE(SANDBOX_MESSAGE_FILTERING)
     (with telemetry-backtrace)
-    (apply-message-filter
-        (allow (with telemetry)
-            iokit-async-external-method
-            iokit-external-trap
-            iokit-external-method
+    (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
+        (apply-message-filter
+            (allow (with telemetry)
+                iokit-async-external-method
+                iokit-external-trap
+                iokit-external-method
+            )
         )
     )
 #endif
@@ -869,11 +891,13 @@
     )
 #if HAVE(SANDBOX_MESSAGE_FILTERING)
     (with telemetry-backtrace)
-    (apply-message-filter
-        (allow (with telemetry)
-            iokit-async-external-method
-            iokit-external-trap
-            iokit-external-method
+    (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
+        (apply-message-filter
+            (allow (with telemetry)
+                iokit-async-external-method
+                iokit-external-trap
+                iokit-external-method
+            )
         )
     )
 #endif
@@ -883,11 +907,13 @@
     (iokit-user-client-class "AudioAUUC") ;; <rdar://problem/10427451> && <rdar://problem/10808817>
 #if HAVE(SANDBOX_MESSAGE_FILTERING)
     (with telemetry-backtrace)
-    (apply-message-filter
-        (allow (with telemetry)
-            iokit-async-external-method
-            iokit-external-trap
-            iokit-external-method
+    (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
+        (apply-message-filter
+            (allow (with telemetry)
+                iokit-async-external-method
+                iokit-external-trap
+                iokit-external-method
+            )
         )
     )
 #endif
@@ -897,11 +923,13 @@
     (iokit-user-client-class "IOAudioControlUserClient")
 #if HAVE(SANDBOX_MESSAGE_FILTERING)
     (with telemetry-backtrace)
-    (apply-message-filter
-        (allow (with telemetry)
-            iokit-async-external-method
-            iokit-external-trap
-            iokit-external-method
+    (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
+        (apply-message-filter
+            (allow (with telemetry)
+                iokit-async-external-method
+                iokit-external-trap
+                iokit-external-method
+            )
         )
     )
 #endif
@@ -911,11 +939,13 @@
     (iokit-user-client-class "IOAudioEngineUserClient")
 #if HAVE(SANDBOX_MESSAGE_FILTERING)
     (with telemetry-backtrace)
-    (apply-message-filter
-        (allow (with telemetry)
-            iokit-async-external-method
-            iokit-external-trap
-            iokit-external-method
+    (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
+        (apply-message-filter
+            (allow (with telemetry)
+                iokit-async-external-method
+                iokit-external-trap
+                iokit-external-method
+            )
         )
     )
 #endif
@@ -1234,11 +1264,13 @@
         (iokit-user-client-class "IOUSBDeviceUserClientV2")
 #if HAVE(SANDBOX_MESSAGE_FILTERING)
         (with telemetry-backtrace)
-        (apply-message-filter
-            (allow (with telemetry)
-                iokit-async-external-method
-                iokit-external-trap
-                iokit-external-method
+        (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
+            (apply-message-filter
+                (allow (with telemetry)
+                    iokit-async-external-method
+                    iokit-external-trap
+                    iokit-external-method
+                )
             )
         )
 #endif
@@ -1247,11 +1279,13 @@
         (iokit-user-client-class "IOUSBInterfaceUserClientV2")
 #if HAVE(SANDBOX_MESSAGE_FILTERING)
         (with telemetry-backtrace)
-        (apply-message-filter
-            (allow (with telemetry)
-                iokit-async-external-method
-                iokit-external-trap
-                iokit-external-method
+        (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
+            (apply-message-filter
+                (allow (with telemetry)
+                    iokit-async-external-method
+                    iokit-external-trap
+                    iokit-external-method
+                )
             )
         )
 #endif
@@ -1516,7 +1550,7 @@
 #endif
 
 #if HAVE(SANDBOX_MESSAGE_FILTERING)
-(when (defined? 'mach-bootstrap)
+(if (and (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES") (defined? 'mach-bootstrap))
     (allow mach-bootstrap
         (apply-message-filter
             (deny xpc-message-send (with telemetry))
@@ -1533,7 +1567,7 @@
     )
 )
 
-(when (defined? 'mach-kernel-endpoint)
+(if (and (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES") (defined? 'mach-kernel-endpoint))
     (allow mach-kernel-endpoint
         (apply-message-filter
             (deny mach-message-send (with telemetry))
@@ -1601,7 +1635,7 @@
     )
 )
 
-(when (defined? 'syscall-mach)
+(if (and (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES") (defined? 'syscall-mach))
     (deny syscall-mach (with telemetry))
     (allow syscall-mach (machtrap-number
         MSC__kernelrpc_mach_port_allocate_trap
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to