diff options
author | Andrea Fioraldi <andreafioraldi@gmail.com> | 2021-03-01 15:30:55 +0100 |
---|---|---|
committer | Andrea Fioraldi <andreafioraldi@gmail.com> | 2021-03-01 15:30:55 +0100 |
commit | ad7a7fcf075c617e09cb516da000b244be161093 (patch) | |
tree | 76acc86a336184e8a57bea929fcca0ddda3cf669 | |
parent | 82c05630ba201bfc631e4e2335c6d8c2e76d91c0 (diff) | |
download | afl++-ad7a7fcf075c617e09cb516da000b244be161093.tar.gz |
ASan-compatible area_is_mapped()
-rw-r--r-- | instrumentation/afl-compiler-rt.o.c | 10 | ||||
m--------- | qemu_mode/qemuafl | 0 |
2 files changed, 9 insertions, 1 deletions
diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c index ecb94cab..dab06177 100644 --- a/instrumentation/afl-compiler-rt.o.c +++ b/instrumentation/afl-compiler-rt.o.c @@ -34,6 +34,7 @@ #include <errno.h> #include <sys/mman.h> +#include <sys/syscall.h> #ifndef __HAIKU__ #include <sys/shm.h> #endif @@ -1551,15 +1552,22 @@ void __sanitizer_cov_trace_switch(uint64_t val, uint64_t *cases) { } +__attribute__((weak)) void *__asan_region_is_poisoned(void *beg, size_t size) { + return NULL; +} + // POSIX shenanigan to see if an area is mapped. // If it is mapped as X-only, we have a problem, so maybe we should add a check // to avoid to call it on .text addresses static int area_is_mapped(void *ptr, size_t len) { + if (__asan_region_is_poisoned(ptr, len) == NULL) + return 1; + char *p = (char *)ptr; char *page = (char *)((uintptr_t)p & ~(sysconf(_SC_PAGE_SIZE) - 1)); - int r = msync(page, (p - page) + len, MS_ASYNC); + int r = syscall(SYS_msync, page, (p - page) + len, MS_ASYNC); if (r < 0) return errno != ENOMEM; return 1; diff --git a/qemu_mode/qemuafl b/qemu_mode/qemuafl -Subproject e36a30ebca57ca433a5d6e20b1a32975aabb761 +Subproject 213f3b27dd099ef352181c48cd75c0f20a73e3f |