mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-12 18:18:07 +00:00
libdislocator freebsd 13 update to amke it works
with vm.imply_prot_max set.
This commit is contained in:
@ -168,7 +168,7 @@ static void *__dislocator_alloc(size_t len) {
|
|||||||
|
|
||||||
u8 * ret, *base;
|
u8 * ret, *base;
|
||||||
size_t tlen;
|
size_t tlen;
|
||||||
int flags, fd, sp;
|
int flags, protflags, fd, sp;
|
||||||
|
|
||||||
if (total_mem + len > max_mem || total_mem + len < total_mem) {
|
if (total_mem + len > max_mem || total_mem + len < total_mem) {
|
||||||
|
|
||||||
@ -191,8 +191,14 @@ static void *__dislocator_alloc(size_t len) {
|
|||||||
|
|
||||||
base = NULL;
|
base = NULL;
|
||||||
tlen = (1 + PG_COUNT(rlen + 8)) * PAGE_SIZE;
|
tlen = (1 + PG_COUNT(rlen + 8)) * PAGE_SIZE;
|
||||||
|
protflags = PROT_READ | PROT_WRITE;
|
||||||
flags = MAP_PRIVATE | MAP_ANONYMOUS;
|
flags = MAP_PRIVATE | MAP_ANONYMOUS;
|
||||||
fd = -1;
|
fd = -1;
|
||||||
|
#if defined(PROT_MAX)
|
||||||
|
// apply when sysctl vm.imply_prot_max is set to 1
|
||||||
|
// no-op otherwise
|
||||||
|
protflags |= PROT_MAX(PROT_READ | PROT_WRITE);
|
||||||
|
#endif
|
||||||
#if defined(USEHUGEPAGE)
|
#if defined(USEHUGEPAGE)
|
||||||
sp = (rlen >= SUPER_PAGE_SIZE && !(rlen % SUPER_PAGE_SIZE));
|
sp = (rlen >= SUPER_PAGE_SIZE && !(rlen % SUPER_PAGE_SIZE));
|
||||||
|
|
||||||
@ -215,7 +221,7 @@ static void *__dislocator_alloc(size_t len) {
|
|||||||
(void)sp;
|
(void)sp;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret = (u8 *)mmap(base, tlen, PROT_READ | PROT_WRITE, flags, fd, 0);
|
ret = (u8 *)mmap(base, tlen, protflags, flags, fd, 0);
|
||||||
#if defined(USEHUGEPAGE)
|
#if defined(USEHUGEPAGE)
|
||||||
/* We try one more time with regular call */
|
/* We try one more time with regular call */
|
||||||
if (ret == MAP_FAILED) {
|
if (ret == MAP_FAILED) {
|
||||||
@ -229,7 +235,7 @@ static void *__dislocator_alloc(size_t len) {
|
|||||||
#elif defined(__sun)
|
#elif defined(__sun)
|
||||||
flags &= -MAP_ALIGN;
|
flags &= -MAP_ALIGN;
|
||||||
#endif
|
#endif
|
||||||
ret = (u8 *)mmap(NULL, tlen, PROT_READ | PROT_WRITE, flags, fd, 0);
|
ret = (u8 *)mmap(NULL, tlen, protflags, flags, fd, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user