summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGCall.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2019-01-04 19:21:51 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2019-01-04 19:21:51 +0000
commitfcbcc6114f47a3e053a603aa40e3f79c237b0795 (patch)
tree87142464ad9bd250c98f19b9b092c0011288c231 /clang/lib/CodeGen/CGCall.cpp
parent0743cda6d4d5f0c8ab2d5d44dc72ee453722b726 (diff)
downloadbcm5719-llvm-fcbcc6114f47a3e053a603aa40e3f79c237b0795.tar.gz
bcm5719-llvm-fcbcc6114f47a3e053a603aa40e3f79c237b0795.zip
hwasan: Use system allocator to realloc and free untagged pointers in interceptor mode.
The Android dynamic loader has a non-standard feature that allows libraries such as the hwasan runtime to interpose symbols even after the symbol already has a value. The new value of the symbol is used to relocate libraries loaded after the interposing library, but existing libraries keep the old value. This behaviour is activated by the DF_1_GLOBAL flag in DT_FLAGS_1, which is set by passing -z global to the linker, which is what we already do to link the hwasan runtime. What this means in practice is that if we have .so files that depend on interceptor-mode hwasan without the main executable depending on it, some of the libraries in the process will be using the hwasan allocator and some will be using the system allocator, and these allocators need to interact somehow. For example, if an instrumented library calls a function such as strdup that allocates memory on behalf of the caller, the instrumented library can reasonably expect to be able to call free to deallocate the memory. We can handle that relatively easily with hwasan by using tag 0 to represent allocations from the system allocator. If hwasan's realloc or free functions are passed a pointer with tag 0, the system allocator is called. One limitation is that this scheme doesn't work in reverse: if an instrumented library allocates memory, it must free the memory itself and cannot pass ownership to a system library. In a future change, we may want to expose an API for calling the system allocator so that instrumented libraries can safely transfer ownership of memory to system libraries. Differential Revision: https://reviews.llvm.org/D55986 llvm-svn: 350427
Diffstat (limited to 'clang/lib/CodeGen/CGCall.cpp')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud