Bug 210616 - [iOS] Deny iokit open access to graphics related classes
Summary: [iOS] Deny iokit open access to graphics related classes
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Per Arne Vollan
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-04-16 12:15 PDT by Per Arne Vollan
Modified: 2021-04-23 15:45 PDT (History)
7 users (show)

See Also:


Attachments
Patch (27.15 KB, patch)
2020-04-16 14:07 PDT, Per Arne Vollan
no flags Details | Formatted Diff | Diff
Patch (34.66 KB, patch)
2020-04-16 15:03 PDT, Per Arne Vollan
no flags Details | Formatted Diff | Diff
Patch (34.67 KB, patch)
2020-04-16 15:23 PDT, Per Arne Vollan
darin: review+
Details | Formatted Diff | Diff
Patch (34.64 KB, patch)
2020-04-16 16:21 PDT, Per Arne Vollan
no flags Details | Formatted Diff | Diff
Patch (34.70 KB, patch)
2020-04-16 16:59 PDT, Per Arne Vollan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Per Arne Vollan 2020-04-16 12:15:10 PDT
Deny iokit open access to graphics related classes in the WebContent process on iOS, but issue extensions for these for some devices which still need access to them.
Comment 1 Per Arne Vollan 2020-04-16 14:07:21 PDT
Created attachment 396696 [details]
Patch
Comment 2 Per Arne Vollan 2020-04-16 15:03:49 PDT
Created attachment 396702 [details]
Patch
Comment 3 Per Arne Vollan 2020-04-16 15:23:07 PDT
Created attachment 396707 [details]
Patch
Comment 4 Per Arne Vollan 2020-04-16 15:43:24 PDT
rdar://problem/61897550
Comment 5 Darin Adler 2020-04-16 15:47:06 PDT
Comment on attachment 396707 [details]
Patch

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

> Source/WebCore/platform/cocoa/AGXCompilerService.cpp:48
> +        if (uname(&systemInfo))
> +            return false;

Is this the behavior we want, to return a potentially incorrect "false" result and to also repeatedly call uname every time this function is called?

> Source/WebCore/platform/cocoa/AGXCompilerService.cpp:53
> +        if (!strcmp(machine, "iPad5,1") || !strcmp(machine, "iPad5,2") || !strcmp(machine, "iPad5,3") || !strcmp(machine, "iPad5,4"))
> +            hasAGXCompilerService = true;
> +        else
> +            hasAGXCompilerService = false;

Apparently this code was just moved, not new, but we want this to be false for all future hardware, including future iPads?

> Source/WebCore/testing/Internals.mm:127
> +        RELEASE_ASSERT_NOT_REACHED();

Seems peculiar to put RELEASE_ASSERT in an internals function, since they are present only for testing.

> Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:378
> +        static const char* ioKitClasses[] = {

One more const here would be good, after the *. Or constexpr before the whole thing.

> Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:388
> +            "AGXCommandQueue",
> +            "AGXDevice",
> +            "AGXSharedUserClient",
> +            "IOAccelContext",
> +            "IOAccelDevice",
> +            "IOAccelSharedUserClient",
> +            "IOAccelSubmitter2",
> +            "IOAccelContext2",
> +            "IOAccelDevice2",
> +            "IOAccelSharedUserClient2"

Why not sort alphabetically instead of having them almost sorted?

> Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:300
> +    for (size_t i = 0, size = parameters.dynamicIOKitExtensionHandles.size(); i < size; ++i)

Modern for loop would be good here.

    for (auto& handle : parameters.dynamicIOKitExtensionHandles)

> Tools/TestWebKitAPI/Tests/WebKit/AGXCompilerService.mm:37
> +    WKRetainPtr<WKContextRef> context = adoptWK(TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest"));

auto
Comment 6 Per Arne Vollan 2020-04-16 16:21:23 PDT
Created attachment 396717 [details]
Patch
Comment 7 Per Arne Vollan 2020-04-16 16:23:34 PDT
(In reply to Darin Adler from comment #5)
> Comment on attachment 396707 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=396707&action=review
> 
> > Source/WebCore/platform/cocoa/AGXCompilerService.cpp:48
> > +        if (uname(&systemInfo))
> > +            return false;
> 
> Is this the behavior we want, to return a potentially incorrect "false"
> result and to also repeatedly call uname every time this function is called?
> 
> > Source/WebCore/platform/cocoa/AGXCompilerService.cpp:53
> > +        if (!strcmp(machine, "iPad5,1") || !strcmp(machine, "iPad5,2") || !strcmp(machine, "iPad5,3") || !strcmp(machine, "iPad5,4"))
> > +            hasAGXCompilerService = true;
> > +        else
> > +            hasAGXCompilerService = false;
> 
> Apparently this code was just moved, not new, but we want this to be false
> for all future hardware, including future iPads?
> 

Yes, I believe that this will be the case going forward.

> > Source/WebCore/testing/Internals.mm:127
> > +        RELEASE_ASSERT_NOT_REACHED();
> 
> Seems peculiar to put RELEASE_ASSERT in an internals function, since they
> are present only for testing.
> 
> > Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:378
> > +        static const char* ioKitClasses[] = {
> 
> One more const here would be good, after the *. Or constexpr before the
> whole thing.
> 
> > Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:388
> > +            "AGXCommandQueue",
> > +            "AGXDevice",
> > +            "AGXSharedUserClient",
> > +            "IOAccelContext",
> > +            "IOAccelDevice",
> > +            "IOAccelSharedUserClient",
> > +            "IOAccelSubmitter2",
> > +            "IOAccelContext2",
> > +            "IOAccelDevice2",
> > +            "IOAccelSharedUserClient2"
> 
> Why not sort alphabetically instead of having them almost sorted?
> 
> > Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:300
> > +    for (size_t i = 0, size = parameters.dynamicIOKitExtensionHandles.size(); i < size; ++i)
> 
> Modern for loop would be good here.
> 
>     for (auto& handle : parameters.dynamicIOKitExtensionHandles)
> 
> > Tools/TestWebKitAPI/Tests/WebKit/AGXCompilerService.mm:37
> > +    WKRetainPtr<WKContextRef> context = adoptWK(TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest"));
> 
> auto

Thanks for reviewing! The latest patch addresses all of the issues above.
Comment 8 Per Arne Vollan 2020-04-16 16:59:00 PDT
Created attachment 396724 [details]
Patch
Comment 9 EWS 2020-04-17 07:40:13 PDT
Committed r260247: <https://trac.webkit.org/changeset/260247>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 396724 [details].
Comment 10 Daniel Bates 2020-05-15 12:58:18 PDT
Comment on attachment 396707 [details]
Patch

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

> Tools/TestWebKitAPI/Tests/WebKit/AGXCompilerService.mm:28
> +#if WK_HAVE_C_SPI && PLATFORM(IOS)

This test is never run: WK_HAVE_C_SPI is only defined when building on Mac.
Comment 11 Per Arne Vollan 2020-05-15 13:05:20 PDT
(In reply to Daniel Bates from comment #10)
> Comment on attachment 396707 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=396707&action=review
> 
> > Tools/TestWebKitAPI/Tests/WebKit/AGXCompilerService.mm:28
> > +#if WK_HAVE_C_SPI && PLATFORM(IOS)
> 
> This test is never run: WK_HAVE_C_SPI is only defined when building on Mac.

Ah, good point! I will look into making this test run on iOS.