selfrando
selfrando copied to clipboard
Support PaX MPROTECT
The MPROTECT mitigation in PaX kernels prevents us from re-mapping executable pages as writable and vice versa. This means that, for now, selfrando is not compatible with MPROTECT and the latter needs to be disabled.
One way to solve this is to write out the randomized code to a file, then map that file back into memory as executable code. We should investigate this approach.
One way to solve this is to write out the randomized code to a file, then map that file back into memory as executable code. We should investigate this approach.
That works around the direct conflict with MPROTECT and the comparable SELinux memory protections, etc. but will conflict with Trusted Path Execution and Mandatory Access Control policies used to prevent dynamic native code generation as a whole.
I think a better approach would be integration with a kernel mitigation where selfrando can signal to the kernel that the initial loading phase is done and that it should start enforcing prevention of dynamic code generation. It wouldn't be compatible with using selfrando for dlopen though.
I think we'd also need to add a way to send that signal to the kernel, if the security mechanism doesn't provide one. If that's the case, this would only work with a patched kernel, making selfrando incompatible with vanilla kernels.
I looked at SELinux briefly a while ago and remember there was a way for an application to switch contexts on demand, but it wasn't trivial.