Title: [273270] trunk/Source
Revision
273270
Author
pvol...@apple.com
Date
2021-02-22 12:58:56 -0800 (Mon, 22 Feb 2021)

Log Message

[macOS] Disabling relaunch on login for the WebContent process is racy
https://bugs.webkit.org/show_bug.cgi?id=222074
<rdar://problem/74230216>

Reviewed by Geoffrey Garen.

Source/WebCore/PAL:

Declare Launch Services key to disable relaunch on login.

* pal/spi/cocoa/LaunchServicesSPI.h:

Source/WebKit:

When NSApplication is being intialized, the method -[NSApplication disableRelaunchOnLogin] is dispatched on a non-main thread, which is in a race
with the revocation of the Launch Services sandbox extension. This patch addresses this by setting this information synchronously with Launch
Services while the sandbox extension is being held. Additionally, accessibility related code under WebPage::platformInitialize may reach out to
the Launch Services daemon once during the lifetime of the WebContent process. Make sure that call succeeds by making a synchronous call while
a sandbox extension to the Launch Services daemon is being held.

* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):

Modified Paths

Diff

Modified: trunk/Source/WebCore/PAL/ChangeLog (273269 => 273270)


--- trunk/Source/WebCore/PAL/ChangeLog	2021-02-22 20:15:51 UTC (rev 273269)
+++ trunk/Source/WebCore/PAL/ChangeLog	2021-02-22 20:58:56 UTC (rev 273270)
@@ -1,3 +1,15 @@
+2021-02-22  Per Arne  <pvol...@apple.com>
+
+        [macOS] Disabling relaunch on login for the WebContent process is racy
+        https://bugs.webkit.org/show_bug.cgi?id=222074
+        <rdar://problem/74230216>
+
+        Reviewed by Geoffrey Garen.
+
+        Declare Launch Services key to disable relaunch on login.
+
+        * pal/spi/cocoa/LaunchServicesSPI.h:
+
 2021-02-20  Chris Fleizach  <cfleiz...@apple.com>
 
         AX: Image should report the embedded accessibility description if available

Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h (273269 => 273270)


--- trunk/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h	2021-02-22 20:15:51 UTC (rev 273269)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h	2021-02-22 20:58:56 UTC (rev 273270)
@@ -110,6 +110,7 @@
 WTF_EXTERN_C_BEGIN
 
 extern const CFStringRef _kLSDisplayNameKey;
+extern const CFStringRef _kLSPersistenceSuppressRelaunchAtLoginKey;
 
 LSASNRef _LSGetCurrentApplicationASN();
 LSASNRef _LSCopyLSASNForAuditToken(LSSessionID, audit_token_t);

Modified: trunk/Source/WebKit/ChangeLog (273269 => 273270)


--- trunk/Source/WebKit/ChangeLog	2021-02-22 20:15:51 UTC (rev 273269)
+++ trunk/Source/WebKit/ChangeLog	2021-02-22 20:58:56 UTC (rev 273270)
@@ -1,3 +1,20 @@
+2021-02-22  Per Arne  <pvol...@apple.com>
+
+        [macOS] Disabling relaunch on login for the WebContent process is racy
+        https://bugs.webkit.org/show_bug.cgi?id=222074
+        <rdar://problem/74230216>
+
+        Reviewed by Geoffrey Garen.
+
+        When NSApplication is being intialized, the method -[NSApplication disableRelaunchOnLogin] is dispatched on a non-main thread, which is in a race
+        with the revocation of the Launch Services sandbox extension. This patch addresses this by setting this information synchronously with Launch
+        Services while the sandbox extension is being held. Additionally, accessibility related code under WebPage::platformInitialize may reach out to
+        the Launch Services daemon once during the lifetime of the WebContent process. Make sure that call succeeds by making a synchronous call while
+        a sandbox extension to the Launch Services daemon is being held.
+        
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+
 2021-02-22  Sam Sneddon  <gsnedd...@apple.com>
 
         REGRESSION(r273204): webkitpy tests don't run on Py3

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (273269 => 273270)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-02-22 20:15:51 UTC (rev 273269)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-02-22 20:58:56 UTC (rev 273270)
@@ -329,6 +329,15 @@
     updateProcessName(IsInProcessInitialization::Yes);
 
 #if ENABLE(SET_WEBCONTENT_PROCESS_INFORMATION_IN_NETWORK_PROCESS)
+    // Disable relaunch on login. This is also done from -[NSApplication init] by dispatching -[NSApplication disableRelaunchOnLogin] on a non-main thread.
+    // This will be in a race with the closing of the Launch Services connection, so call it synchronously here.
+    // The cost of calling this should be small, and it is not expected to have any impact on performance.
+    _LSSetApplicationInformationItem(kLSDefaultSessionID, _LSGetCurrentApplicationASN(), _kLSPersistenceSuppressRelaunchAtLoginKey, kCFBooleanTrue, nullptr);
+    
+    // This is being called under WebPage::platformInitialize(), and may reach out to the Launch Services daemon once in the lifetime of the process.
+    // Call this synchronously here while a sandbox extension to Launch Services is being held.
+    [NSAccessibilityRemoteUIElement remoteTokenForLocalUIElement:adoptNS([[WKAccessibilityWebPageObject alloc] init]).get()];
+
     auto method = class_getInstanceMethod([NSApplication class], @selector(_updateCanQuitQuietlyAndSafely));
     method_setImplementation(method, (IMP)preventAppKitFromContactingLaunchServices);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to