New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 17 users
Status: Fixed
Owner:
Email to this user bounced
Closed: Feb 2015
Cc:



Sign in to add a comment
OS X IOKit kernel memory corruption due to bad bzero in IOBluetoothDevice
Project Member Reported by ianbeer@google.com, Oct 23 2014 Back to list
requirements: A bluetooth device must be connected (tested with an Apple bluetooth keyboard)

IOBluetoothDeviceUserClient::clientMemoryForType memory type 0xff calls
 __ZN17IOBluetoothDevice18getSCOOutputBufferEv
which calls IOBluetoothDevice::initializeRingBuffer to allocate a buffer to
map into userspace.


IOBluetoothDevice18getSCOOutputBuffer:
...
lea     rsi, [rbx+178h]  <-- pass pointer to this+0x178 in rsi
mov     edx, 3C00h
add     rsp, 8
pop     rbx
pop     rbp
jmp     rax              <-- tail call to initializeRingBuffer


IOBluetoothDevice::initializeRingBuffer(_IOBluetoothRingBuffer **, int):
...
mov     r14, rsi        <-- save pointer to this+0x178
...
call    __ZN24IOBufferMemoryDescriptor11withOptionsEjmm ; IOBufferMemoryDescriptor::withOptions(uint,ulong,ulong)
mov     r12, rax
mov     rax, [r12]
mov     rdi, r12
call    qword ptr [rax+20h] ; ::retain
mov     rax, [r12]
mov     rdi, r12
call    qword ptr [rax+2E0h] ; IOBufferMemoryDescriptor::getBytesNoCopy(void)
mov     rbx, rax                    <-- pointer to buffer in kernel space (will be shared with userspace)
lea     rdi, [rbx+10h]  ; void *
xor     esi, esi        ; int
mov     rdx, r15        ; size_t
call    _memset                     <-- clear it
mov     dword ptr [rbx], 0
mov     dword ptr [rbx+4], 0
mov     dword ptr [rbx+8], 0
mov     [rbx+0Ch], r13d             <-- write the size as the fourth dword
mov     [r14], rbx                  <-- save buffer pointer


This buffer will then be mapped into userspace.

Calling external method 4 eventually reaches the following code:
IOBluetoothDevice::startSCOOutput:

__text:0000000000030F62                 mov     rdi, [rbx+178h]            <-- pointer to shared buffer
__text:0000000000030F69                 test    rdi, rdi
__text:0000000000030F6C                 jz      loc_31039
__text:0000000000030F72                 mov     r14d, 0E00002D2h
__text:0000000000030F78                 cmp     byte ptr [rbx+188h], 0
__text:0000000000030F7F                 jnz     loc_31060
__text:0000000000030F85                 mov     esi, [rdi+0Ch]  ; size_t   <-- read size from userspace shared mem
__text:0000000000030F88                 add     rdi, 10h        ; void *
__text:0000000000030F8C                 call    _bzero                     <-- passed as size arg to bzero


Userspace can modify the size in shared memory leading to the bzero writing a controlled number of NULL bytes off the end of the buffer.
 
bluetooth_ringbuffer.c
4.4 KB Download
Project Member Comment 1 by ianbeer@google.com, Oct 23 2014
Labels: Reported-2014-Oct-23 Id-613089081
Project Member Comment 2 by ianbeer@google.com, Jan 21 2015
Labels: -Restrict-View-Commit
Deadline exceeded - automatically derestricting
Comment 3 Deleted
Comment 4 by cevans@google.com, Jan 26 2015
Labels: Deadline-Exceeded
Project Member Comment 5 by ianbeer@google.com, Feb 4 2015
Labels: Fixed-2015-Jan-27 CVE-2014-8836
Status: Fixed
Apple advisory: http://support.apple.com/en-us/HT204244
Comment 6 Deleted
Comment 7 Deleted
Comment 8 by anon...@gmail.com, Jan 31 2016
Coool
Comment 9 Deleted
Comment 10 Deleted
Sign in to add a comment