-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Up for grabs.
I do not have access to the relevant hardware here to test on Apple Series M chips; and no way to emulate them either.
Motivations
Although this library is no_std and already supports ARM64 (aarch64); some operating systems have security measures in place which make hooking difficult.
For example, macOS enforces W^X on Apple hardware; where a region of memory can either only be writable or executable at any time. This is a bit problematic...
Solution
Some fiddling with JIT Entitlement might be necessary to acquire the desired outcome here.
The execute protection appears to function on a per thread basis, as described in the article, so simply calling pthread_jit_write_protect_np(false) before the code is written and pthread_jit_write_protect_np(true) after it is written, should be sufficient.
Additional Context
I do not have a way to simulate this hardware or test under hardened runtime.
All current testing of OSX was done in a veeeeeryyyy slowwwwww VM (Intel based macOS), and CI/CD.
To implement this, it might also be necessary to change the allocate perms on the Rust port Reloaded.Memory.Buffers which is the memory buffer provider; current perms allocate as RWX using mach_vm_allocate, the behaviour of that is unclear.