Merge pull request #593 from devnexen/fbsd_mprotect

Hunk: FreeBSD set the map permission to max read and write
This commit is contained in:
Yamagi 2020-08-31 13:31:03 +02:00 committed by GitHub
commit 56ddda7021
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -59,6 +59,7 @@ Hunk_Begin(int maxsize)
maxhunksize = maxsize + sizeof(size_t) + 32;
curhunksize = 0;
int flags = MAP_PRIVATE | MAP_ANONYMOUS;
int prot = PROT_READ | PROT_WRITE;
#if defined(MAP_ALIGNED_SUPER)
const size_t hgpagesize = 1UL<<21;
@ -72,7 +73,13 @@ Hunk_Begin(int maxsize)
}
#endif
membase = mmap(0, maxhunksize, PROT_READ | PROT_WRITE,
#if defined(PROT_MAX)
/* For now it is FreeBSD exclusif but could possibly be extended
to other like DFBSD for example */
prot = PROT_MAX(prot);
#endif
membase = mmap(0, maxhunksize, prot,
flags, -1, 0);
if ((membase == NULL) || (membase == (byte *)-1))