mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-23 05:40:09 +00:00
[dfsan] Don't clear shadow on dlopen(NULL, flags)
This ports msan https://reviews.llvm.org/D14795 to dfsan. dfsan, like msan, clears shadow for globals in a newly opened DSO in case the DSO occupies the address of a previously labeled/poisoned area. The operation should not happen on the main executable. In addition, for a DT_EXEC executable, l_addr is zero and will lead to a null pointer dereference in ForEachMappedRegion.
This commit is contained in:
parent
184c22dd3a
commit
8434e5d0a1
@ -842,7 +842,7 @@ __dfsw_dlopen(const char *filename, int flag, dfsan_label filename_label,
|
||||
dfsan_label flag_label, dfsan_label *ret_label) {
|
||||
void *handle = dlopen(filename, flag);
|
||||
link_map *map = GET_LINK_MAP_BY_DLOPEN_HANDLE(handle);
|
||||
if (map)
|
||||
if (filename && map)
|
||||
ForEachMappedRegion(map, dfsan_set_zero_label);
|
||||
*ret_label = 0;
|
||||
return handle;
|
||||
|
@ -1,7 +1,7 @@
|
||||
// RUN: %clang_dfsan %s -o %t && DFSAN_OPTIONS="strict_data_dependencies=0" %run %t
|
||||
// RUN: %clang_dfsan -DSTRICT_DATA_DEPENDENCIES %s -o %t && %run %t
|
||||
// RUN: %clang_dfsan -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 -mllvm -dfsan-combine-pointer-labels-on-load=false -DSTRICT_DATA_DEPENDENCIES %s -o %t && %run %t
|
||||
// RUN: %clang_dfsan -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 -mllvm -dfsan-combine-pointer-labels-on-load=false %s -o %t && DFSAN_OPTIONS="strict_data_dependencies=0" %run %t
|
||||
// RUN: %clang_dfsan -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 -mllvm -dfsan-combine-pointer-labels-on-load=false -no-pie %s -o %t && DFSAN_OPTIONS="strict_data_dependencies=0" %run %t
|
||||
//
|
||||
// Tests custom implementations of various glibc functions.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user