[PATCH] D35558: Use sys::Memory::AllocateRWX for JIT code
Kamil Rytarowski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 19 17:25:25 PDT 2017
krytarowski added a comment.
In https://reviews.llvm.org/D35558#815451, @joerg wrote:
> In https://reviews.llvm.org/D35558#815442, @lhames wrote:
>
> > > Right, the pages are allocated RWX.
> >
> > It seems odd to prevent the flipping of the W/X bits while allowing RWX pages. I assume there are additional privileges
> > required (granted only to JITs and debuggers?) to get RWX pages? Is there a good source for me to read up about the PaX MPROTECT design?
>
>
> They are not allocated RWX, they are allocated RW with the option for later X. I.e. the kernel enforces W^X, but you can request
> additional protections for later use. Without that, mprotect with X would be rejected later. There are patching for Linux for similar effect, but I don't think
> they ever got merged. libffi is a victim of that on Linux.
Right, this is NetBSD-specific implementation detail of AllocateRWX.
libffi examples (ffi_closure_alloc):
https://github.com/libffi/libffi/blob/6e2e041b6df6a3c3a5ca8a750dedbbd465e5ca97/src/closures.c
Repository:
rL LLVM
https://reviews.llvm.org/D35558
More information about the llvm-commits
mailing list