Skip to content

m32 allocator unconditionally mmaps a WX mapping

Mattias Kilian reports on ghc-devs that GHCi fails on OpenBSD due to m32_allocator_init trying to create a memory mapping with writable and executable access. The culprit appears to be this call-graph:

  • Linker.initDynLinker calls
  • Linker.reallyInitDynLinker calls
  • GHCi.initObjLinker calls
  • GHCi.ObjLink.initObjLinker calls
  • initLinker_ calls
  • m32_allocator_init which creates the mapping in question via mmapForLinker

It's unclear exactly what calls initDynLinker but there are numerous call-sites; I suspect it's not possible to enter GHCi without passing through initDynLinker at some point.

I suspect the solution here is to teach the linker to be more deliberate in the access that it requests for its mappings (see #12657 (closed)).

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information