Re: mmap RW then mprotect RWX

Jörg Sonnenberger <[email protected]>
Newsgroups gmane.os.netbsd.devel.kernel
Message-ID <[email protected]>

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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.