[llvm] [llvm][Support][Memory] Add memfd based fallback for strict W^X Linux systems (PR #98538)

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 31 23:36:14 PDT 2024


lhames wrote:

I'm out of the loop on Linux memory protections. If I understand correctly this works around W^X by copying the content of the memory to the memfd, then mapping the memfd back in at the target address with R-X flags?

If so that's cool, but seems surprising behavior for `sys::Memory`.

What about adding a new W^X compliant `JITLinkMemoryManager` for this? Or a new `Mapper` for `MapperJITLinkMemoryManager`? The JIT linker only ever reads / writes memory, so the idea would be to create dual mappings -- one with `RW-` protections that can be used as the working memory for the linker, and a second with the requested permissions (which would simply have to be compliant with the system's policies) for use in JIT'd code. 

https://github.com/llvm/llvm-project/pull/98538


More information about the llvm-commits mailing list