mmap RW then mprotect RWX

Emmanuel Dreyfus <[email protected]>
Newsgroups gmane.os.netbsd.devel.kernel
Message-ID <[email protected]>
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.

A simple fix seems to just call mmap() with RWX protection and forget
the mprotect(). A simple C program (see below) shows that it works well 
with NetBSD-10.0/amd64 and PaX mprotect enabled. 

I wonder if there are other environments (other NetBSD setups, perhaps?)
where mmap() RW then mprotect() RWX would be required. 

#include <stdio.h>
#include <err.h>
#include <sys/mman.h>

int
main(void)
{
        void *p;

        p = mmap(NULL, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON, -1, 0);
        if (p == NULL)
                err(1, "mmap RWX failed");

	return 0;
}


-- 
Emmanuel Dreyfus
[email protected]
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.