[DFSan] Handle mmap() calls before interceptors are installed.
authorMatt Morehouse <mascasa@google.com>
Wed, 19 Aug 2020 22:07:17 +0000 (15:07 -0700)
committerMatt Morehouse <mascasa@google.com>
Wed, 19 Aug 2020 22:07:41 +0000 (15:07 -0700)
commit4deda57106f7c9b982a49cb907c33e3966c8de7f
tree2cb57197ebc2992f186a9b71b94037d7a3e92cf5
parente2645488ca3b18dfb4f5cc8d7494a208f89e91a0
[DFSan] Handle mmap() calls before interceptors are installed.

InitializeInterceptors() calls dlsym(), which calls calloc().  Depending
on the allocator implementation, calloc() may invoke mmap(), which
results in a segfault since REAL(mmap) is still being resolved.

We fix this by doing a direct syscall if interceptors haven't been fully
resolved yet.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D86168
compiler-rt/lib/dfsan/dfsan_interceptors.cpp
compiler-rt/test/dfsan/interceptors.c [new file with mode: 0644]