Nicolas Seriot

Security

A Panic in Apple IOGPUFamily

An ID reused between two lookups (TOCTOU race) lets any app trigger a kernel OOB read.

2026-12-03

Affected Systems

IOGPUFamily kernel extension, reached through Metal

Tested on macOS 27.2.1, macOS 27.3 Beta and iOS 27.3 Beta

The bug

An app sends work to the GPU in Metal command buffers. When it submits one, Metal passes the kernel the ID of a shared-memory object that holds the buffer's segment list: the list of segments, each with a header giving its size and entry count, that the kernel walks to process the buffer.

IOGPUFamily looks up this ID twice during the submit, and keeps no reference to the object in between. If the app frees that ID and a new object takes it in between, the kernel reads past the end of the new object and panics.

PoC

The PoC apple_iogpufamily_poc.zip:
1. Hooks Metal methods so it can set its own segment-list IDs. Done once.
2. Creates a segment-list object L with IOGPUDeviceCreateDeviceShmem and submits a command buffer with its ID. In submitCommandBuffer, the kernel looks up the ID for the first time.
3. The submission waits on another queue before the second lookup. The kernel keeps no reference to L meanwhile.
4. Frees L with IOGPUDeviceDestroyDeviceShmem and creates a replacement list, new L. The kernel gives new L the ID that L had, because it reuses the lowest free slot. New L's final segment occupies only its 16-byte header and ends exactly at the end of its memory, but declares one entry. There is no room for that entry within the mapping. Two helper queues submit new L, advancing its list position to the final segment.
5. In processCommandBuffer, the kernel looks up the ID a second time and gets new L. It walks from new L's current position and reads past its end.

The PoC repeats steps 2–5 with random timing until the race hits.

Reproduction

poc/poc.m builds as a command-line tool on macOS:

poc/run.sh mac

or a minimal app on iOS:

TEAM_ID=<team> poc/run.sh ios <device-udid>

On iOS, run.sh also copies back the app log and the new panic log.

Observed Result

Kernel panic reproduced on:

The kernel reads the next entry header just past the end of new L's memory and faults.

iOS panic log excerpt:

panic(cpu 2 caller 0xfffffe004169e664): Kernel data abort. at pc 0xfffffe00402919e8, lr 0xfffffe0040291710
  x28: 0xfffffe381e10c000   far: 0xfffffe381e10c01c   esr: 0x0000000096000007
Panicked task: pid 684: POC
Backtrace (IOGPUFamily 163.1.4 frames):
  IOGPUFamily+0x38398   <- faulting pc: ldr w8, [x28, #0x1c]; x28 = end of new L's mapping
  IOGPUFamily+0x3a558
  IOGPUFamily+0x37864
  IOGPUFamily+0x375ac
  IOGPUFamily+0x8e9c

Security Impact

This is a kernel out-of-bounds read.

The PoC triggers a kernel panic and device reboot on the tested systems.