Skip to content
Permalink
Browse files
[iOS] [GPU] The UI process should issue the mach sandbox extension to…
… 'com.apple.AGXCompilerService'

https://bugs.webkit.org/show_bug.cgi?id=225004
<rdar://problem/68362930>

Reviewed by Darin Adler.

In Bug 203915 and Bug 210616 we did work to only extend access to AGX-related graphics facilities on relevant hardware. This was
lost in the transition to the GPU Process and should be added back.

Source/WebCore:

This change moves the definition of the AGX-related services and IOKit classes to the AGXCompilerService compilation unit so that
it can be shared by the WebContent and GPUProcess code paths.

Tested by existing graphics tests.

* platform/cocoa/AGXCompilerService.cpp:
(WebCore::agxCompilerServices):
(WebCore::agxCompilerClasses):
* platform/cocoa/AGXCompilerService.h:

Source/WebKit:

This change does the following:
1. Adds sandbox extension handles for the AGX-related compiler services and IOKit classes to the GPUProcess creation parameters.
2. Updates the GPUProcessProxy to extend AGX features when warranted and add them to the creation parameter structure.
3. Updates the GPUProcess to consume the extensions (when granted).
4. Updates the WebProcessPool to use the WebCore version of the 'agxCompilerClasses' and 'agxCompilerServices' functions.
5. Moves the 'agxCompilerClasses' and 'agxCompilerServices' functions to WebCore, alongside the other AGX functions.

It also corrects the sandbox rule for the AGXCompilerService in the GPU Process sandbox, which incorrectly called it a 'global-name',
when it is an xpc-service.

Tested by existing graphics tests.

* GPUProcess/GPUProcess.cpp:
(WebKit::GPUProcess::initializeGPUProcess):
* GPUProcess/GPUProcessCreationParameters.cpp:
(WebKit::GPUProcessCreationParameters::encode const):
(WebKit::GPUProcessCreationParameters::decode):
* GPUProcess/GPUProcessCreationParameters.h:
* Resources/SandboxProfiles/ios/com.apple.WebKit.GPU.sb: Correct AGX compiler service type.
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::nonBrowserServices):
(WebKit::WebProcessPool::platformInitializeWebProcess):
(WebKit::agxCompilerClasses): Deleted.
(WebKit::agxCompilerServices): Deleted.
* UIProcess/GPU/GPUProcessProxy.cpp:
(WebKit::GPUProcessProxy::GPUProcessProxy):


Canonical link: https://commits.webkit.org/237071@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276644 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
brentfulgham committed Apr 27, 2021
1 parent 38af5c1 commit c1f7011580872f16d2f7bbd797543e3c1c68ce43
Showing 10 changed files with 170 additions and 46 deletions.
@@ -1,3 +1,24 @@
2021-04-27 Brent Fulgham <bfulgham@apple.com>

[iOS] [GPU] The UI process should issue the mach sandbox extension to 'com.apple.AGXCompilerService'
https://bugs.webkit.org/show_bug.cgi?id=225004
<rdar://problem/68362930>

Reviewed by Darin Adler.

In Bug 203915 and Bug 210616 we did work to only extend access to AGX-related graphics facilities on relevant hardware. This was
lost in the transition to the GPU Process and should be added back.

This change moves the definition of the AGX-related services and IOKit classes to the AGXCompilerService compilation unit so that
it can be shared by the WebContent and GPUProcess code paths.

Tested by existing graphics tests.

* platform/cocoa/AGXCompilerService.cpp:
(WebCore::agxCompilerServices):
(WebCore::agxCompilerClasses):
* platform/cocoa/AGXCompilerService.h:

2021-04-27 Antoine Quint <graouts@webkit.org>

Correctly interpolate stroke-dasharray in the discrete case
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Apple Inc. All rights reserved.
* Copyright (C) 2020-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,7 +29,9 @@
#if PLATFORM(IOS_FAMILY)

#include <sys/utsname.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/Optional.h>
#include <wtf/text/ASCIILiteral.h>

namespace WebCore {

@@ -57,6 +59,34 @@ bool deviceHasAGXCompilerService()
return *hasAGXCompilerService;
}

const Vector<ASCIILiteral>& agxCompilerServices()
{
ASSERT(isMainRunLoop());
static const auto services = makeNeverDestroyed(Vector<ASCIILiteral> {
"com.apple.AGXCompilerService"_s,
"com.apple.AGXCompilerService-S2A8"_s
});
return services;
}

const Vector<ASCIILiteral>& agxCompilerClasses()
{
ASSERT(isMainRunLoop());
static const auto iokitClasses = makeNeverDestroyed(Vector<ASCIILiteral> {
"AGXCommandQueue"_s,
"AGXDevice"_s,
"AGXSharedUserClient"_s,
"IOAccelContext"_s,
"IOAccelContext2"_s,
"IOAccelDevice"_s,
"IOAccelDevice2"_s,
"IOAccelSharedUserClient"_s,
"IOAccelSharedUserClient2"_s,
"IOAccelSubmitter2"_s,
});
return iokitClasses;
}

}

#endif
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Apple Inc. All rights reserved.
* Copyright (C) 2020-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -25,9 +25,17 @@

#pragma once

#if PLATFORM(IOS_FAMILY)

#include <wtf/Forward.h>

namespace WebCore {

WEBCORE_EXPORT bool deviceHasAGXCompilerService();
WEBCORE_EXPORT void setDeviceHasAGXCompilerServiceForTesting();
WEBCORE_EXPORT const Vector<ASCIILiteral>& agxCompilerServices();
WEBCORE_EXPORT const Vector<ASCIILiteral>& agxCompilerClasses();

}

#endif
@@ -1,3 +1,41 @@
2021-04-27 Brent Fulgham <bfulgham@apple.com>

[iOS] [GPU] The UI process should issue the mach sandbox extension to 'com.apple.AGXCompilerService'
https://bugs.webkit.org/show_bug.cgi?id=225004
<rdar://problem/68362930>

Reviewed by Darin Adler.

In Bug 203915 and Bug 210616 we did work to only extend access to AGX-related graphics facilities on relevant hardware. This was
lost in the transition to the GPU Process and should be added back.

This change does the following:
1. Adds sandbox extension handles for the AGX-related compiler services and IOKit classes to the GPUProcess creation parameters.
2. Updates the GPUProcessProxy to extend AGX features when warranted and add them to the creation parameter structure.
3. Updates the GPUProcess to consume the extensions (when granted).
4. Updates the WebProcessPool to use the WebCore version of the 'agxCompilerClasses' and 'agxCompilerServices' functions.
5. Moves the 'agxCompilerClasses' and 'agxCompilerServices' functions to WebCore, alongside the other AGX functions.

It also corrects the sandbox rule for the AGXCompilerService in the GPU Process sandbox, which incorrectly called it a 'global-name',
when it is an xpc-service.

Tested by existing graphics tests.

* GPUProcess/GPUProcess.cpp:
(WebKit::GPUProcess::initializeGPUProcess):
* GPUProcess/GPUProcessCreationParameters.cpp:
(WebKit::GPUProcessCreationParameters::encode const):
(WebKit::GPUProcessCreationParameters::decode):
* GPUProcess/GPUProcessCreationParameters.h:
* Resources/SandboxProfiles/ios/com.apple.WebKit.GPU.sb: Correct AGX compiler service type.
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::nonBrowserServices):
(WebKit::WebProcessPool::platformInitializeWebProcess):
(WebKit::agxCompilerClasses): Deleted.
(WebKit::agxCompilerServices): Deleted.
* UIProcess/GPU/GPUProcessProxy.cpp:
(WebKit::GPUProcessProxy::GPUProcessProxy):

2021-04-27 Chris Fleizach <cfleizach@apple.com>

AX: Smart invert>Safari>images & other colors improperly invert
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 Apple Inc. All rights reserved.
* Copyright (C) 2019-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -220,6 +220,10 @@ void GPUProcess::initializeGPUProcess(GPUProcessCreationParameters&& parameters)
SandboxExtension::consumePermanently(parameters.containerCachesDirectoryExtensionHandle);
SandboxExtension::consumePermanently(parameters.containerTemporaryDirectoryExtensionHandle);
#endif
#if PLATFORM(IOS_FAMILY)
SandboxExtension::consumePermanently(parameters.compilerServiceExtensionHandles);
SandboxExtension::consumePermanently(parameters.dynamicIOKitExtensionHandles);
#endif

#if HAVE(CGIMAGESOURCE_WITH_SET_ALLOWABLE_TYPES)
auto emptyArray = adoptCF(CFArrayCreate(kCFAllocatorDefault, nullptr, 0, &kCFTypeArrayCallBacks));
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 Apple Inc. All rights reserved.
* Copyright (C) 2019-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -61,6 +61,10 @@ void GPUProcessCreationParameters::encode(IPC::Encoder& encoder) const
encoder << containerCachesDirectoryExtensionHandle;
encoder << containerTemporaryDirectoryExtensionHandle;
#endif
#if PLATFORM(IOS_FAMILY)
encoder << compilerServiceExtensionHandles;
encoder << dynamicIOKitExtensionHandles;
#endif
}

bool GPUProcessCreationParameters::decode(IPC::Decoder& decoder, GPUProcessCreationParameters& result)
@@ -101,6 +105,19 @@ bool GPUProcessCreationParameters::decode(IPC::Decoder& decoder, GPUProcessCreat
return false;
result.containerTemporaryDirectoryExtensionHandle = WTFMove(*containerTemporaryDirectoryExtensionHandle);
#endif
#if PLATFORM(IOS_FAMILY)
Optional<SandboxExtension::HandleArray> compilerServiceExtensionHandles;
decoder >> compilerServiceExtensionHandles;
if (!compilerServiceExtensionHandles)
return false;
result.compilerServiceExtensionHandles = WTFMove(*compilerServiceExtensionHandles);

Optional<SandboxExtension::HandleArray> dynamicIOKitExtensionHandles;
decoder >> dynamicIOKitExtensionHandles;
if (!dynamicIOKitExtensionHandles)
return false;
result.dynamicIOKitExtensionHandles = WTFMove(*dynamicIOKitExtensionHandles);
#endif

return true;
}
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 Apple Inc. All rights reserved.
* Copyright (C) 2019-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -59,6 +59,10 @@ struct GPUProcessCreationParameters {
SandboxExtension::Handle containerCachesDirectoryExtensionHandle;
SandboxExtension::Handle containerTemporaryDirectoryExtensionHandle;
#endif
#if PLATFORM(IOS_FAMILY)
SandboxExtension::HandleArray compilerServiceExtensionHandles;
SandboxExtension::HandleArray dynamicIOKitExtensionHandles;
#endif

void encode(IPC::Encoder&) const;
static WARN_UNUSED_RETURN bool decode(IPC::Decoder&, GPUProcessCreationParameters&);
@@ -1,4 +1,4 @@
; Copyright (C) 2010-2019 Apple Inc. All rights reserved.
; Copyright (C) 2010-2021 Apple Inc. All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions
@@ -257,12 +257,12 @@
;;; Declare that the application uses the OpenGL, Metal, and CoreML hardware & frameworks.
;;;
(define-once (opengl)
(allow iokit-open
;; Items not seen in testing
(deny iokit-open (with telemetry)
(iokit-connection "IOGPU")
(iokit-user-client-class
"AGXCommandQueue"
"AGXDevice"
"AGXDeviceUserClient"
"AGXSharedUserClient"
"IOAccelContext"
"IOAccelDevice"
@@ -272,6 +272,11 @@
"IOAccelDevice2"
"IOAccelSharedUserClient2"))

(allow iokit-open
(iokit-connection "IOGPU")
(iokit-user-client-class
"AGXDeviceUserClient"))

(allow iokit-get-properties
(iokit-property "IOGLBundleName")
(iokit-property "IOGLESBundleName")
@@ -284,9 +289,6 @@
(allow sysctl-read
(sysctl-name #"kern.bootsessionuuid"))

(allow mach-lookup (with report) (with telemetry)
(xpc-service-name-prefix "com.apple.AGXCompilerService"))

(allow mach-lookup
;; <rdar://problem/47268166>
(xpc-service-name "com.apple.MTLCompilerService"))
@@ -940,14 +942,37 @@
(literal "/usr/local/lib/log") ; <rdar://problem/36629495>
)

(allow iokit-open
(require-all
(extension "com.apple.webkit.extension.iokit")
(iokit-user-client-class
"AGXCommandQueue"
"AGXDevice"
"AGXSharedUserClient"
"IOAccelContext"
"IOAccelDevice"
"IOAccelSharedUserClient"
"IOAccelSubmitter2"
"IOAccelContext2"
"IOAccelDevice2"
"IOAccelSharedUserClient2"
)
)
)

(deny mach-lookup (with no-log)
(xpc-service-name "com.apple.audio.toolbox.reporting.service")
)

(allow mach-lookup
(require-all
(extension "com.apple.webkit.extension.mach")
(global-name "com.apple.iphone.axserver-systemwide" "com.apple.tccd" "com.apple.AGXCompilerService")))
(global-name "com.apple.iphone.axserver-systemwide" "com.apple.tccd")))

(allow mach-lookup
(require-all
(extension "com.apple.webkit.extension.mach")
(xpc-service-name-prefix "com.apple.AGXCompilerService")))

(media-capture-support)

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2020 Apple Inc. All rights reserved.
* Copyright (C) 2010-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -234,36 +234,6 @@ static bool isInternalInstall()
});
return services;
}

static const Vector<ASCIILiteral>& agxCompilerClasses()
{
ASSERT(isMainRunLoop());
static const auto iokitClasses = makeNeverDestroyed(Vector<ASCIILiteral> {
"AGXCommandQueue"_s,
"AGXDevice"_s,
"AGXSharedUserClient"_s,
"IOAccelContext"_s,
"IOAccelContext2"_s,
"IOAccelDevice"_s,
"IOAccelDevice2"_s,
"IOAccelSharedUserClient"_s,
"IOAccelSharedUserClient2"_s,
"IOAccelSubmitter2"_s,
});
return iokitClasses;
}
#endif

#if PLATFORM(IOS)
static const Vector<ASCIILiteral>& agxCompilerServices()
{
ASSERT(isMainRunLoop());
static const auto services = makeNeverDestroyed(Vector<ASCIILiteral> {
"com.apple.AGXCompilerService"_s,
"com.apple.AGXCompilerService-S2A8"_s
});
return services;
}
#endif

static const Vector<ASCIILiteral>& diagnosticServices()
@@ -403,15 +373,15 @@ static bool requiresContainerManagerAccess()

#if PLATFORM(IOS)
if (WebCore::deviceHasAGXCompilerService())
parameters.compilerServiceExtensionHandles = SandboxExtension::createHandlesForMachLookup(agxCompilerServices(), WTF::nullopt);
parameters.compilerServiceExtensionHandles = SandboxExtension::createHandlesForMachLookup(WebCore::agxCompilerServices(), WTF::nullopt);
#endif

#if PLATFORM(IOS_FAMILY)
if (!WebCore::IOSApplication::isMobileSafari())
parameters.dynamicMachExtensionHandles = SandboxExtension::createHandlesForMachLookup(nonBrowserServices(), WTF::nullopt);

if (WebCore::deviceHasAGXCompilerService())
parameters.dynamicIOKitExtensionHandles = SandboxExtension::createHandlesForIOKitClassExtensions(agxCompilerClasses(), WTF::nullopt);
parameters.dynamicIOKitExtensionHandles = SandboxExtension::createHandlesForIOKitClassExtensions(WebCore::agxCompilerClasses(), WTF::nullopt);
#endif

if (isInternalInstall())
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Apple Inc. All rights reserved.
* Copyright (C) 2019-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -51,6 +51,7 @@
#include <wtf/TranslatedProcess.h>

#if PLATFORM(IOS_FAMILY)
#include <WebCore/AGXCompilerService.h>
#include <wtf/spi/darwin/XPCSPI.h>
#endif

@@ -188,6 +189,12 @@ GPUProcessProxy::GPUProcessProxy()
if (!containerTemporaryDirectory.isEmpty())
SandboxExtension::createHandleWithoutResolvingPath(containerTemporaryDirectory, SandboxExtension::Type::ReadWrite, parameters.containerTemporaryDirectoryExtensionHandle);
#endif
#if PLATFORM(IOS_FAMILY)
if (WebCore::deviceHasAGXCompilerService()) {
parameters.compilerServiceExtensionHandles = SandboxExtension::createHandlesForMachLookup(WebCore::agxCompilerServices(), WTF::nullopt);
parameters.dynamicIOKitExtensionHandles = SandboxExtension::createHandlesForIOKitClassExtensions(WebCore::agxCompilerClasses(), WTF::nullopt);
}
#endif

// Initialize the GPU process.
send(Messages::GPUProcess::InitializeGPUProcess(parameters), 0);

0 comments on commit c1f7011

Please sign in to comment.