Bug 184485

Summary: Add JIT entitlements to WebContent process and plugin process on macOS
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: WebKit2Assignee: Brent Fulgham <bfulgham>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, bfulgham, commit-queue, fpizlo, ggaren, jiewen_tan, mitz
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 185526    
Bug Blocks:    
Attachments:
Description Flags
Adds entitlements
none
Patch
none
Patch
none
Patch none

Ryosuke Niwa
Reported 2018-04-10 21:45:21 PDT
Adopt the newly introduced JIT entitlements on macOS. <rdar://problem/37556535>
Attachments
Adds entitlements (1.65 KB, patch)
2018-04-10 21:46 PDT, Ryosuke Niwa
no flags
Patch (13.28 KB, patch)
2018-05-31 09:35 PDT, Brent Fulgham
no flags
Patch (2.66 KB, patch)
2018-05-31 11:13 PDT, Brent Fulgham
no flags
Patch (5.67 KB, patch)
2018-05-31 12:04 PDT, Brent Fulgham
no flags
Ryosuke Niwa
Comment 1 2018-04-10 21:46:47 PDT
Created attachment 337676 [details] Adds entitlements
mitz
Comment 2 2018-04-10 21:49:17 PDT
The same question I asked in bug 181995 comment 4 applies here.
Ryosuke Niwa
Comment 3 2018-04-10 22:16:25 PDT
(In reply to mitz from comment #2) > The same question I asked in bug 181995 comment 4 applies here. We need to be able to use JIT in STP, WebKit nightlies, etc... if that's what you're asking.
Brent Fulgham
Comment 4 2018-04-10 22:31:20 PDT
(In reply to mitz from comment #2) > The same question I asked in bug 181995 comment 4 applies here. Your r- would be much more helpful if you provided a comment explaining why you rejected the patch. It would also be very helpful if you answered the question I posed to you in my response to your comment (in bug 181995 comment 5). It seems like this patch (like bug 181995) is incomplete. But where should the entitlement for the system WebKit go?
mitz
Comment 5 2018-04-10 22:52:31 PDT
(In reply to Brent Fulgham from comment #4) > (In reply to mitz from comment #2) > > The same question I asked in bug 181995 comment 4 applies here. > > Your r- would be much more helpful if you provided a comment explaining why > you rejected the patch. It became obvious from my exchange with Ryosuke that the patch didn’t accomplish what it was meant to do, and that it wasn’t tested in any way (it’s understandable if someone doesn’t know how to test that granting the entitlement has the desired effect, but it’s puzzling that someone can’t test whether their patch does in fact add the entitlement). > > It would also be very helpful if you answered the question I posed to you in > my response to your comment (in bug 181995 comment 5). > > It seems like this patch (like bug 181995) is incomplete. But where should > the entitlement for the system WebKit go? The project is not currently set up to sign the macOS Web Content process with entitlements except in production builds with relocatable frameworks, because those require the XPC domain extension private entitlement. That entitlement is not appropriate for any other configuration: it is a private entitlement, so it can’t be used by people outside Apple, and it is adding attack surface which is not needed in Apple products other than Safari Technology Preview. The entitlement in attachment 332041 [details] from bug 181995 also can’t be used by folks outside Apple. The entitlement in attachment 337676 [details] in this bug, on the other hand, seems like it should be given to the Web Content process in all configurations targeting macOS. It seems like there are several combinations of entitlements, each applicable to a different situation, so the project would need to be set up with some custom build settings (similar to the existing WK_WEBCONTENT_SERVICE_NEEDS_XPC_DOMAIN_EXTENSION_ENTITLEMENT) to express which entitlements are needed in a given configuration, and then either a separate entitlements file mapping to each valid combination of entitlements, or a way to generate the entitlements file during build time (in a manner compatible with the Xcode build system) based on what’s needed.
Brent Fulgham
Comment 6 2018-05-31 09:35:40 PDT
mitz
Comment 7 2018-05-31 10:06:14 PDT
Comment on attachment 341668 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=341668&action=review > Source/WebKit/ChangeLog:12 > + 1. Adds a new process-plugin-entitlements.sh script, which conditionally adds the restricted JIT entitlement My understanding and knowledge is that the JIT entitlement is *not* restricted. So granting it shouldn’t be conditional on whether we’re building with restricted entitlements.
Geoffrey Garen
Comment 8 2018-05-31 10:39:19 PDT
Relatedly, if the JIT entitlement were restricted, how would we produce open source builds with the JIT enabled?
Brent Fulgham
Comment 9 2018-05-31 10:43:01 PDT
(In reply to Geoffrey Garen from comment #8) > Relatedly, if the JIT entitlement were restricted, how would we produce open > source builds with the JIT enabled? I just confirmed with the sandboxing team that the JIT entitlement is not restricted.
mitz
Comment 10 2018-05-31 10:54:32 PDT
(In reply to Geoffrey Garen from comment #8) > Relatedly, if the JIT entitlement were restricted, how would we produce open > source builds with the JIT enabled? We wouldn’t but it isn’t (for good reasons).
Brent Fulgham
Comment 11 2018-05-31 11:13:18 PDT
Brent Fulgham
Comment 12 2018-05-31 11:15:12 PDT
(In reply to mitz from comment #7) > Comment on attachment 341668 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=341668&action=review > > > Source/WebKit/ChangeLog:12 > > + 1. Adds a new process-plugin-entitlements.sh script, which conditionally adds the restricted JIT entitlement > > My understanding and knowledge is that the JIT entitlement is *not* > restricted. So granting it shouldn’t be conditional on whether we’re > building with restricted entitlements. Thank you -- I was wrong on that point. I've revised the patch and it is now much simpler, since we unconditionally include this entitlement. I added it to the PluginService.entitlements file. Will that pose problems when building for down-level OS's? I believe it will just be a dormant entity in the app signature. If not, I can go back to my script to conditionally apply the entitlement to the plugin process, but I'd prefer to avoid it as it adds a lot of complexity to this change.
mitz
Comment 13 2018-05-31 11:19:44 PDT
(In reply to Brent Fulgham from comment #12) > I added it to the PluginService.entitlements file. Will that pose problems > when building for down-level OS's? I believe it will just be a dormant > entity in the app signature. That’s right. I can see no harm in having this entitlement on OS versions that don’t recognize it.
Brent Fulgham
Comment 14 2018-05-31 11:42:59 PDT
(In reply to mitz from comment #13) > (In reply to Brent Fulgham from comment #12) > > I added it to the PluginService.entitlements file. Will that pose problems > > when building for down-level OS's? I believe it will just be a dormant > > entity in the app signature. > > That’s right. I can see no harm in having this entitlement on OS versions > that don’t recognize it. Did you mean to clear the review flag on this patch? It looked accidental so I put it back in review ? state.
mitz
Comment 15 2018-05-31 11:44:36 PDT
I removed the r+ from the patch because I just realized that the fix for bug 185526 was missing a piece, and this is an opportunity to fix it: After the <https://trac.webkit.org/r232321>, we can end up (in production builds), with CODE_SIGN_ENTITLEMENTS being empty for the Web Content services, and consequently with Xcode not using our .xcent file. To fix that *and* this bug, we should just put the JIT entitlement in a new WebContent-OSX.entitlements (separate from the -restricted one), and set CODE_SIGN_ENTITLEMENTS_COCOA_TOUCH_NO to point to this new file. Then we wouldn’t need any changes to the script.
Brent Fulgham
Comment 16 2018-05-31 12:04:43 PDT
WebKit Commit Bot
Comment 17 2018-05-31 12:47:02 PDT
Comment on attachment 341682 [details] Patch Clearing flags on attachment: 341682 Committed r232364: <https://trac.webkit.org/changeset/232364>
WebKit Commit Bot
Comment 18 2018-05-31 12:47:04 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.