tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: mmap RW then mprotect RWX





On 1/13/25 5:46 PM, Emmanuel Dreyfus wrote:
Hello

I try to fix unoconv, which currently requires paxctl +m ${PYTHONBIN}
to work. The problem is in allocExec() from
  libreoffice/bridges/source/cpp_uno/shared/vtablefactory.cxx

It attempts a mmap() with RW protection, and immediatly a mprotect()
with RWX protection. That chokes with PaX mprotect.

Well, there are actually two separate issues here:
(1) Mapping the same page writeable and executable (W^X)
(2) Increasing the permissions of the mapping (RW -> RWX)

What you normally want to do is:
(1) mmap with RW | PROT_MPROTECT(PROT_EXEC) to declare that PROT_EXEC is needed later.
(2) modify the page as necessary
(3) mprotect to RX

Joerg


Home | Main Index | Thread Index | Old Index