11.08.2016 Views

Behind the Scenes with iOS Security

2aCt1ji

2aCt1ji

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4. Prevent writing into <strong>the</strong> executable JIT mapping.<br />

result = mprotect(jitBase, jitSize, VM_PROT_READ | VM_PROT_EXECUTE);<br />

RELEASE_ASSERT(!result);<br />

// 5. Prevent execution in <strong>the</strong> writable JIT mapping.<br />

result = mprotect((void*)writableAddr, jitSize, VM_PROT_READ | VM_PROT_WRITE);<br />

RELEASE_ASSERT(!result);<br />

// 6. Zero out writableAddr to avoid leaking <strong>the</strong> address of <strong>the</strong> writable mapping.<br />

memset_s(&writableAddr, sizeof(writableAddr), 0, sizeof(writableAddr));<br />

jitWriteFunction =<br />

reinterpret_cast(writeThunk.code().executableAddress());<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!