2026-11-20
IOStorageFamily
macOS 27.2.1
macOS 27.3 Beta 2 (26C5047e)
A crafted disk image can make a 32-bit multiplication overflow inside Apple's kernel storage driver.
The driver then reads from an address about 4 GB below its own buffer, hits unmapped kernel memory, and panics the machine.
IOApplePartitionScheme::scan()
walks an Apple Partition Map, computing a pointer of the form buffer + index for each entry:
for (dpmeID = 1, dpmeCount = 1; dpmeID <= dpmeCount; dpmeID++) {
if (dpmeID * dpmeBlockSize + sizeof(dpme) > bufferReadAt + bufferSize) {
bufferReadAt = dpmeID * dpmeBlockSize; // UInt32
if (media->read(this, bufferReadAt, buffer) != kIOReturnSuccess) goto scanErr;
}
dpmeMap = (dpme *)((UInt8 *)buffer->getBytesNoCopy() +
(dpmeID * dpmeBlockSize) - bufferReadAt); // UInt32 index (L415)
if (OSSwapBigToHostInt16(dpmeMap->dpme_signature) != DPME_SIGNATURE) goto scanErr; // OOB read (L420)
...
}
dpmeBlockSize and dpmeCount are read from the image but never validated against the media size.
dpmeID and dpmeBlockSize are both UInt32, so when dpmeID * dpmeBlockSize crosses 2^32, the wrapped index is small while bufferReadAt
is still near 2^32.
Subtracting them puts the read pointer dpmeMap ~4 GB below the buffer base buffer->getBytesNoCopy().
Build and attach a 4 GB sparse image using poc.py:
python3 poc.py x.img
hdiutil attach -nomount -readonly -imagekey diskimage-class=CRawDiskImage x.img
Expected: the kernel rejects the out-of-range block size and entry count.
Actual: immediate kernel data abort in IOApplePartitionScheme::scan, followed by reboot.
The panic captured on macOS 27.2.1 shows the overflow directly.
With block size 0x8000 and dpmeID 0x20000, the product is exactly 2³², and
the fault address lands at the buffer base minus 0xFFFF8000:
panic(...): Kernel data abort.
x0 = buffer->getBytesNoCopy()
x24 = 0x8000 dpmeBlockSize
x25 = 0x20000 dpmeID (0x20000 * 0x8000 == 2³²)
x23 = 0xffff8000 bufferReadAt
far = x0 - 0xffff8000 (buffer - ~4 GB)
esr = 0x96000006 read fault, unmapped page
(far is the address the CPU tried to read; esr says why it faulted.)
The faulting instruction is the dpme_signature load at
IOApplePartitionScheme.cpp:420,
dereferencing the pointer computed two lines earlier (L415). It is reached
through the normal attach path:
IOService::probeCandidates > IOApplePartitionScheme::probe > IOApplePartitionScheme::scan.
An unprivileged user can reliably panic the machine and force a reboot.