[PATCH] D86168: [DFSan] Handle mmap() calls before interceptors are installed.

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 19 14:50:15 PDT 2020


vitalybuka accepted this revision.
vitalybuka added inline comments.
This revision is now accepted and ready to land.


================
Comment at: compiler-rt/lib/dfsan/dfsan_interceptors.cpp:23
 
+static bool interceptors_initialized;
+
----------------
morehouse wrote:
> vitalybuka wrote:
> > Have you considered EnsureInterceptorsInitialized from compiler-rt/lib/cfi/cfi.cpp or compiler-rt/lib/safestack/safestack.cpp
> > I suspect it should not work as you can't do INTERCEPT_FUNCTION here
> > 
> > Anyway as is it's a data race, some synchronization is needed.
> Initialization happens during preinit_array, when we're single-threaded.  The issue this solves is that initialization calls dlysm calls calloc calls mmap.  If we did lazy-initialization, we'd get infinite recursion.
Interesting, I never considered that. Maybe it's relevant for other EnsureInterceptorsInitialized and we don't need locking there.


================
Comment at: compiler-rt/lib/dfsan/dfsan_interceptors.cpp:29
+  if (!interceptors_initialized)
+    res = (void*)syscall(__NR_mmap, addr, length, prot, flags, fd, offset);
+  else
----------------
Can you please fix this ?
clang-format: please reformat the code


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86168/new/

https://reviews.llvm.org/D86168



More information about the llvm-commits mailing list