summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2015-09-08 23:14:44 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2015-09-08 23:14:44 +0000
commit26dfddc93583e5c4cb9abfff3675d89aa193fb1f (patch)
tree9c39d2b24b7c4ef670a6361cf5120c75bfddb666
parentcdb8032c23e36ac8a182b5f9aea097a1940ed083 (diff)
downloadcompiler-rt-26dfddc93583e5c4cb9abfff3675d89aa193fb1f.tar.gz
[msan] Unpoison dlpi_phdr in dl_iterate_phdr.
In some cases, PHDR table is allocated with malloc() by the linker instead of being mapped from file. It needs to be unpoisoned in the dl_iterate_phdr callback then. This happens when program headers are not part of any loadable ELF segment. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@247100 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/msan/msan_interceptors.cc2
-rw-r--r--lib/sanitizer_common/sanitizer_platform_limits_posix.cc4
-rw-r--r--lib/sanitizer_common/sanitizer_platform_limits_posix.h2
3 files changed, 8 insertions, 0 deletions
diff --git a/lib/msan/msan_interceptors.cc b/lib/msan/msan_interceptors.cc
index 5cd29130e..32aef3038 100644
--- a/lib/msan/msan_interceptors.cc
+++ b/lib/msan/msan_interceptors.cc
@@ -1092,6 +1092,8 @@ static int msan_dl_iterate_phdr_cb(__sanitizer_dl_phdr_info *info, SIZE_T size,
void *data) {
if (info) {
__msan_unpoison(info, size);
+ if (info->dlpi_phdr && info->dlpi_phnum)
+ __msan_unpoison(info->dlpi_phdr, struct_ElfW_Phdr_sz * info->dlpi_phnum);
if (info->dlpi_name)
__msan_unpoison(info->dlpi_name, REAL(strlen)(info->dlpi_name) + 1);
}
diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
index aaa37ed02..d038b9c56 100644
--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -290,6 +290,10 @@ namespace __sanitizer {
return 0;
}
+#if SANITIZER_LINUX || SANITIZER_FREEBSD
+unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr));
+#endif
+
#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
int glob_nomatch = GLOB_NOMATCH;
int glob_altdirfunc = GLOB_ALTDIRFUNC;
diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/lib/sanitizer_common/sanitizer_platform_limits_posix.h
index 4da7c70da..babac1e67 100644
--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -609,6 +609,8 @@ namespace __sanitizer {
const void *dlpi_phdr;
short dlpi_phnum;
};
+
+ extern unsigned struct_ElfW_Phdr_sz;
#endif
struct __sanitizer_addrinfo {