text stringlengths 0 1.99k |
|---|
The IOUserClient[11] is a subclass of IOService that serves as a secure |
bridge between user-space applications and kernel I/O service objects. |
It does not interact with hardware directly but provides a controlled |
interface for safe communication with kernel services. IOUserClient objects |
serve as security gatekeepers, running in kernel space and handling |
requests from unprivileged user-space applications. They validate input, |
enforce access controls, and sanitize data before passing it to services. |
The core logic is implemented in newUserClient[12] functions. |
================================= |
--[ 1.2.1 - Multiple User Clients per Service |
============================================================================ |
A single Service can have multiple User Clients registered. They can |
expose different interfaces to the same underlying Service. Each User |
Client type has a unique numeric identifier (uint32_t). Applications |
specify which User Client type they want when connecting with |
IOServiceOpen()[13]. Type 0 is typically the default/primary interface. |
================ |
--[ 1.2.2 - External Methods |
============================================================================ |
The externalMethod[14] within the User Client handles incoming |
IOConnectCallMethod[15] requests from the user-space app. It validates that |
the selector is within bounds and argument sizes. Based on the selector |
value, it routes them to appropriate handler functions. These are the final |
endpoints where core logic and most of the vulnerabilities lie. |
================== |
--[ 1.2.3 - Dispatch Mechanism |
============================================================================ |
At WWDC22, the validation portion of the external method was moved to a |
new "2022" dispatchExternalMethod, which serves as a wrapper around the |
method array (sIOExternalMethodArray): |
```````````````````````````````````````````````````````````````````````````` |
IOReturn AppleJPEGDriverUserClient::externalMethod( |
IOUserClient* userClient, // this user client instance |
uint32_t selector, // method id from user space |
IOExternalMethodArguments* arguments // I/O parameters from user space |
) |
{ |
return IOUserClient2022::dispatchExternalMethod( |
userClient, // the user client object |
selector, // which method to call (0-9) |
arguments, // parameters from user space |
&sIOExternalMethodArray, // dispatch table with 10 methods |
10, // number of methods in table |
userClient, // target object for method calls |
0 // additional flags/options |
); |
} |
```````````````````````````````````````````````````````````````````````````` |
The dispatchExternalMethod()[16] validates the selector is within bounds, |
calculates the dispatch table entry at methodArray[selector], checks |
arguments sizes (I/O scalars and structs), optionally validates |
entitlements for privileged operations, and finally, call the target |
handler function if all checks pass. |
========================== |
--[ 1.2.4 - getTargetAndMethodForIndex |
============================================================================ |
Although many UserClient::externalMethods were rewritten to include |
IOUserClient2022::dispatchExternalMethods, there is still a significant |
amount of code that follows the old method[17]. There are also |
getTargetAndMethodForIndex[18]. Drivers using the old way are more prone to |
misuse or missing validation. |
============== |
--[ 1.2.5 - Access Control |
============================================================================ |
The same selector can mean different things in different User Clients: |
```````````````````````````````````````````````````````````````````````````` |
IOService "MyDevice" |
|- IOUserClient Type 0 (standard interface) |
| |- Selector 0: GetStatus |
| `- Selector 1: SetConfig |
`- IOUserClient Type 1 (admin interface) |
|- Selector 0: FactoryReset |
`- Selector 1: UpdateFirmware |
```````````````````````````````````````````````````````````````````````````` |
This design provides both functional separation and security boundaries - |
unprivileged apps receive limited user clients, while privileged ones |
receive full-featured ones. The entitlements[19] embedded in the |
application's code signature[20] define access to these interfaces. |
============== |
--[ 1.3 - User Space App |
============================================================================ |
User-space applications can be sandboxed, restricting their access to |
IOKit even if they possess the necessary entitlements. Sandboxed apps are |
generally restricted from performing sensitive operations, such as opening |
hardware service connections or modifying properties. On macOS Sequoia, the |
Sandbox Operations affecting IOKit access include[21]: |
- "iokit*" |
- "iokit-get-properties" |
- "iokit-issue-extension" |
- "iokit-open*" |
- "iokit-open-user-client" |
- "iokit-open-service" |
- "iokit-set-properties" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.