[PATCH] D42897: Refactor mmap interceptors
Vitaly Buka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 5 16:08:33 PST 2018
vitalybuka requested changes to this revision.
vitalybuka added a comment.
This revision now requires changes to proceed.
Looks like tsan and esan tests do not work.
I've updated some stuff here https://reviews.llvm.org/D44125
================
Comment at: lib/esan/esan_interceptors.cpp:331
-INTERCEPTOR(void *, mmap, void *addr, SIZE_T sz, int prot, int flags,
- int fd, OFF_T off) {
- if (UNLIKELY(REAL(mmap) == nullptr)) {
- // With esan init during interceptor init and a static libc preventing
- // our early-calloc from triggering, we can end up here before our
- // REAL pointer is set up.
- return (void *)internal_mmap(addr, sz, prot, flags, fd, off);
- }
- void *ctx;
- COMMON_INTERCEPTOR_ENTER(ctx, mmap, addr, sz, prot, flags, fd, off);
- if (!fixMmapAddr(&addr, sz, flags))
- return (void *)-1;
- void *result = REAL(mmap)(addr, sz, prot, flags, fd, off);
- return (void *)checkMmapResult((uptr)result, sz);
+#undef COMMON_INTERCEPTOR_MMAP_IMPL
+#define COMMON_INTERCEPTOR_MMAP_IMPL(ctx, addr, sz, prot, flags, fd, off) \
----------------
This #undef is the evidence of a problem. As is these interceptors do not work and tests show it.
COMMON_INTERCEPTOR_MMAP_IMPL must be defined before common include.
================
Comment at: lib/sanitizer_common/sanitizer_common_interceptors.inc:6820
+ if ((prot & prot_write_exec) == prot_write_exec) {
+ if (common_flags()->mmap_prot_write_exec)
+ COMMON_INTERCEPTOR_MMAP_WRITE_EXEC();
----------------
mmap_prot_write_exec is functional change. please move out it from refactoring change.
================
Comment at: lib/tsan/rtl/tsan_interceptors.cc:763
-TSAN_INTERCEPTOR(void *, mmap, void *addr, SIZE_T sz, int prot, int flags,
- int fd, OFF_T off) {
- SCOPED_TSAN_INTERCEPTOR(mmap, addr, sz, prot, flags, fd, off);
- if (!fix_mmap_addr(&addr, sz, flags))
- return MAP_FAILED;
- void *res = REAL(mmap)(addr, sz, prot, flags, fd, off);
- if (res != MAP_FAILED) {
- if (fd > 0)
- FdAccess(thr, pc, fd);
-
- if (thr->ignore_reads_and_writes == 0)
- MemoryRangeImitateWrite(thr, pc, (uptr)res, sz);
- else
- MemoryResetRange(thr, pc, (uptr)res, sz);
- }
- return res;
+#define COMMON_INTERCEPT_MMAP_IMPL(ctx, addr, sz, prot, flags, fd, off) \
+{ \
----------------
-> COMMON_INTERCEPTOR_MMAP_IMPL
https://reviews.llvm.org/D42897
More information about the llvm-commits
mailing list