New issue
Advanced search Search tips
Starred by 2 users
Status: Fixed
Owner:
Closed: Oct 2015
Cc:



Sign in to add a comment
Integer Overflow in IOHDIXControllerUserClient::convertClientBuffer leading to undersized kalloc allocation passed to DMA code
Project Member Reported by ianbeer@google.com, Aug 31 2015 Back to list
Method 5 of the IOHDIXController user client is createDrive64. This takes a 0x100 byte structure input from which it reads a userspace pointer and a size which it passes to IOHDIXController::convertClientBuffer. This wraps the memory pointed to by the userspace pointer in an IOMemoryDescriptor then takes the user-provided size, casts it to a 32-bit type and adds one. It passes that value to IOMalloc. By passing a size of 0xffffffff we can cause an integer overflow and IOMalloc will be passed a size of 0.

IOMalloc falls through to kalloc which will quite happily make a 0-sized allocation for us and return a valid, writable kernel heap pointer.

The original size we specified, cast to a 32-bit type but withone one added to it is then passed as the size of the target buffer in the call to IOMemoryDescriptor::readBytes which attempts to read from the wrapped userspace memory into the undersized kernel heap buffer.

It actually tries to use some fancy DMA stuff to do that copy and this PoC will almost certainly fail and kernel panic somewhere inside that DMA code as there probably aren't valid page-table entries for the whole destination range. But some kalloc heap spraying should take care of that allowing us to actually overwrite stuff :)
 
iohdix.c
3.1 KB Download
Project Member Comment 1 by ianbeer@google.com, Aug 31 2015
Labels: Reported-2015-Aug-31
Project Member Comment 2 by ianbeer@google.com, Aug 31 2015
Labels: Id-627536731
Project Member Comment 3 by ianbeer@google.com, Oct 22 2015
Labels: CVE-2015-6995
Status: Fixed
OS X Advisory: https://support.apple.com/en-us/HT205375
iOS Advisory: https://support.apple.com/en-us/HT205370
Project Member Comment 4 by ianbeer@google.com, Oct 22 2015
Labels: Fixed-2015-Oct-21
Project Member Comment 5 by ianbeer@google.com, Jan 27 2016
Labels: -Restrict-View-Commit
Sign in to add a comment