3 ms·
Can't a MAP_JIT region be writable by one thread and executable by a different thread at the same time?
by josephcsible 5y ago
Can't a MAP_JIT region be writable by one thread and executable by a different thread at the same time?
- anyfoo 5y agohttps://developer.apple.com/documentation/apple-silicon/porting-just-in-time-compilers-to-apple-silicon https://developer.apple.com/documentation/apple-silicon/port...
- josephcsible 5y agoThat link confirms that it can: > Because pthread_jit_write_protect_np changes only the current thread’s permissions, avoid accessing the same memory region from multiple threads. Giving multiple threads access to the same memory region opens up a potential attack vector, in which one thread has write access and another has executable access to the same region.
- marcan_42 5y agoAh, yes, I forgot about that. So indeed there is no non-racy hook point for the kernel to do such a check, even if it made sense and the RX/RW switch went through the kernel, which it doesn't.