[compiler-rt] r187412 - [msan] Intercept confstr.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Tue Jul 30 05:47:00 PDT 2013
Author: eugenis
Date: Tue Jul 30 07:46:59 2013
New Revision: 187412
URL: http://llvm.org/viewvc/llvm-project?rev=187412&view=rev
Log:
[msan] Intercept confstr.
Modified:
compiler-rt/trunk/lib/msan/tests/msan_test.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_stat.h
Modified: compiler-rt/trunk/lib/msan/tests/msan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/msan_test.cc?rev=187412&r1=187411&r2=187412&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/msan_test.cc (original)
+++ compiler-rt/trunk/lib/msan/tests/msan_test.cc Tue Jul 30 07:46:59 2013
@@ -926,6 +926,22 @@ TEST(MemorySanitizer, get_current_dir_na
free(res);
}
+TEST(MemorySanitizer, confstr) {
+ char buf[3];
+ size_t res = confstr(_CS_PATH, buf, sizeof(buf));
+ ASSERT_GT(res, sizeof(buf));
+ EXPECT_NOT_POISONED(buf[0]);
+ EXPECT_NOT_POISONED(buf[sizeof(buf) - 1]);
+
+ char buf2[1000];
+ res = confstr(_CS_PATH, buf2, sizeof(buf2));
+ ASSERT_LT(res, sizeof(buf2));
+ EXPECT_NOT_POISONED(buf2[0]);
+ EXPECT_NOT_POISONED(buf2[res - 1]);
+ EXPECT_POISONED(buf2[res]);
+ ASSERT_EQ(res, strlen(buf2) + 1);
+}
+
TEST(MemorySanitizer, readdir) {
DIR *dir = opendir(".");
struct dirent *d = readdir(dir);
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=187412&r1=187411&r2=187412&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Tue Jul 30 07:46:59 2013
@@ -1747,6 +1747,20 @@ INTERCEPTOR(char *, canonicalize_file_na
#define INIT_CANONICALIZE_FILE_NAME
#endif
+#if SANITIZER_INTERCEPT_CONFSTR
+INTERCEPTOR(SIZE_T, confstr, int name, char *buf, SIZE_T len) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, confstr, name, buf, len);
+ SIZE_T res = REAL(confstr)(name, buf, len);
+ if (buf && res)
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, buf, res < len ? res : len);
+ return res;
+}
+#define INIT_CONFSTR INTERCEPT_FUNCTION(confstr);
+#else
+#define INIT_CONFSTR
+#endif
+
#define SANITIZER_COMMON_INTERCEPTORS_INIT \
INIT_STRCMP; \
INIT_STRNCMP; \
@@ -1805,4 +1819,5 @@ INTERCEPTOR(char *, canonicalize_file_na
INIT_WCSNRTOMBS; \
INIT_TCGETATTR; \
INIT_REALPATH; \
- INIT_CANONICALIZE_FILE_NAME;
+ INIT_CANONICALIZE_FILE_NAME; \
+ INIT_CONFSTR;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h?rev=187412&r1=187411&r2=187412&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h Tue Jul 30 07:46:59 2013
@@ -109,5 +109,6 @@
# define SANITIZER_INTERCEPT_TCGETATTR SI_LINUX
# define SANITIZER_INTERCEPT_REALPATH SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_CANONICALIZE_FILE_NAME SI_LINUX_NOT_ANDROID
+# define SANITIZER_INTERCEPT_CONFSTR SI_MAC || SI_LINUX_NOT_ANDROID
#endif // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc?rev=187412&r1=187411&r2=187412&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc Tue Jul 30 07:46:59 2013
@@ -352,6 +352,7 @@ void StatOutput(u64 *stat) {
name[StatInt_tcgetattr] = " tcgetattr ";
name[StatInt_realpath] = " realpath ";
name[StatInt_canonicalize_file_name] = " canonicalize_file_name ";
+ name[StatInt_confstr] = " confstr ";
name[StatAnnotation] = "Dynamic annotations ";
name[StatAnnotateHappensBefore] = " HappensBefore ";
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_stat.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_stat.h?rev=187412&r1=187411&r2=187412&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_stat.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_stat.h Tue Jul 30 07:46:59 2013
@@ -347,6 +347,7 @@ enum StatType {
StatInt_tcgetattr,
StatInt_realpath,
StatInt_canonicalize_file_name,
+ StatInt_confstr,
// Dynamic annotations.
StatAnnotation,
More information about the llvm-commits
mailing list