[compiler-rt] r247100 - [msan] Unpoison dlpi_phdr in dl_iterate_phdr.
Evgeniy Stepanov via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 8 16:14:44 PDT 2015
Author: eugenis
Date: Tue Sep 8 18:14:44 2015
New Revision: 247100
URL: http://llvm.org/viewvc/llvm-project?rev=247100&view=rev
Log:
[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.
Modified:
compiler-rt/trunk/lib/msan/msan_interceptors.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h
Modified: compiler-rt/trunk/lib/msan/msan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=247100&r1=247099&r2=247100&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Tue Sep 8 18:14:44 2015
@@ -1092,6 +1092,8 @@ static int msan_dl_iterate_phdr_cb(__san
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);
}
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc?rev=247100&r1=247099&r2=247100&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc Tue Sep 8 18:14:44 2015
@@ -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;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h?rev=247100&r1=247099&r2=247100&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h Tue Sep 8 18:14:44 2015
@@ -609,6 +609,8 @@ namespace __sanitizer {
const void *dlpi_phdr;
short dlpi_phnum;
};
+
+ extern unsigned struct_ElfW_Phdr_sz;
#endif
struct __sanitizer_addrinfo {
More information about the llvm-commits
mailing list