Bug 213357

Summary: [iOS, macOS] Allow access to the container manager to support Mail InjectedBundle
Product: WebKit Reporter: Brent Fulgham <bfulgham>
Component: WebKit Misc.Assignee: Brent Fulgham <bfulgham>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, darin, ddkilzer, pvollan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch for landing
none
Catalina crash log
none
Patch none

Description Brent Fulgham 2020-06-18 15:19:12 PDT
The Mail Injected Bundle requires access to the container manager to support certain OS operations. We do not need this access for web browsing, and should limit this access to this one case.

This patch creates a dynamic mach extension to the container manager for this single use case.
Comment 1 Brent Fulgham 2020-06-18 15:20:15 PDT
<rdar://problem/63837247>
Comment 2 Brent Fulgham 2020-06-18 15:22:06 PDT
Created attachment 402240 [details]
Patch
Comment 3 Brent Fulgham 2020-06-18 15:28:37 PDT
Created attachment 402242 [details]
Patch
Comment 4 Darin Adler 2020-06-18 16:13:56 PDT
Comment on attachment 402242 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=402242&action=review

Is there any more scalable way to do this? Seems unfortunate to hardcode a client app bundle ID again.

> Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:299
> +#else

How about this instead?

#elif PLATFORM(IOS)
    return WebCore::IOSApplication::isMobileMail()
#else
    return false;
#endif
Comment 5 David Kilzer (:ddkilzer) 2020-06-19 02:32:51 PDT
Comment on attachment 402242 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=402242&action=review

>> Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:299
>> +#else
> 
> How about this instead?
> 
> #elif PLATFORM(IOS)
>     return WebCore::IOSApplication::isMobileMail()
> #else
>     return false;
> #endif

The problem is that it’s not just MobileMail that needs access.  We see other apps that use the WebContent process and talk to containermanagerd as well.

This only fixes the majority of cases, but not all of them.
Comment 6 Brent Fulgham 2020-06-19 13:44:24 PDT
Comment on attachment 402242 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=402242&action=review

>>> Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:299
>>> +#else
>> 
>> How about this instead?
>> 
>> #elif PLATFORM(IOS)
>>     return WebCore::IOSApplication::isMobileMail()
>> #else
>>     return false;
>> #endif
> 
> The problem is that it’s not just MobileMail that needs access.  We see other apps that use the WebContent process and talk to containermanagerd as well.
> 
> This only fixes the majority of cases, but not all of them.

Darin: Will do!

David: I'll add telemetry-backtrace so we get a backtrace if this is hit by anyone else. I'm very interested to see how that's possible.
Comment 7 Brent Fulgham 2020-06-19 13:45:31 PDT
Created attachment 402319 [details]
Patch for landing
Comment 8 EWS 2020-06-19 14:12:20 PDT
Committed r263287: <https://trac.webkit.org/changeset/263287>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 402319 [details].
Comment 9 Ryan Haddad 2020-06-19 17:51:32 PDT
This change caused testing to exit early on Catalina due to crashes:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.apple.WebKit              	0x0000000104e58d95 WebKit::AuxiliaryProcess::initializeSandbox(WebKit::AuxiliaryProcessInitializationParameters const&, WebKit::SandboxInitializationParameters&) + 6783 (AuxiliaryProcessMac.mm:693)
1   com.apple.WebKit              	0x00000001050fcdb0 WebKit::WebProcess::initializeSandbox(WebKit::AuxiliaryProcessInitializationParameters const&, WebKit::SandboxInitializationParameters&) + 196 (WebProcessCocoa.mm:589)
2   com.apple.WebKit              	0x0000000104c8e1ff WebKit::AuxiliaryProcess::initialize(WebKit::AuxiliaryProcessInitializationParameters const&) + 103
3   com.apple.WebKit              	0x000000010506cab9 void WebKit::XPCServiceInitializer<WebKit::WebProcess, WebKit::XPCServiceInitializerDelegate>(WTF::OSObjectPtr<NSObject<OS_xpc_object>*>, NSObject<OS_xpc_object>*, NSObject<OS_xpc_object>*) + 645 (XPCServiceEntryPoint.h:135)
4   com.apple.WebKit              	0x000000010506c7fe WebContentServiceInitializer + 61 (WebContentServiceEntryPoint.mm:53)


https://build.webkit.org/builders/Apple-Catalina-Release-WK2-Tests/builds/6485
Comment 10 Ryan Haddad 2020-06-19 17:51:49 PDT
Created attachment 402363 [details]
Catalina crash log
Comment 11 Ryan Haddad 2020-06-19 18:08:18 PDT
Reverted in https://trac.webkit.org/changeset/263307/webkit
Comment 12 Brent Fulgham 2020-06-20 12:19:25 PDT
Created attachment 402397 [details]
Patch
Comment 13 EWS 2020-06-20 16:36:05 PDT
Committed r263320: <https://trac.webkit.org/changeset/263320>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 402397 [details].