[compiler-rt] r188167 - [sanitizer] Intercept getgroups.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Mon Aug 12 04:01:40 PDT 2013
Author: eugenis
Date: Mon Aug 12 06:01:40 2013
New Revision: 188167
URL: http://llvm.org/viewvc/llvm-project?rev=188167&view=rev
Log:
[sanitizer] Intercept getgroups.
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=188167&r1=188166&r2=188167&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/msan_test.cc (original)
+++ compiler-rt/trunk/lib/msan/tests/msan_test.cc Mon Aug 12 06:01:40 2013
@@ -2275,6 +2275,15 @@ TEST(MemorySanitizer, getgrnam_r) {
EXPECT_NOT_POISONED(grp.gr_gid);
}
+TEST(MemorySanitizer, getgroups) {
+ int n = getgroups(0, 0);
+ gid_t *gids = new gid_t[n];
+ int res = getgroups(n, gids);
+ ASSERT_EQ(n, res);
+ for (int i = 0; i < n; ++i)
+ EXPECT_NOT_POISONED(gids[i]);
+}
+
template<class T>
static bool applySlt(T value, T shadow) {
__msan_partial_poison(&value, &shadow, sizeof(T));
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=188167&r1=188166&r2=188167&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Mon Aug 12 06:01:40 2013
@@ -1923,6 +1923,20 @@ INTERCEPTOR(int, scandir64, char *dirp,
#define INIT_SCANDIR64
#endif
+#if SANITIZER_INTERCEPT_GETGROUPS
+INTERCEPTOR(int, getgroups, int size, u32 *lst) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, getgroups, size, lst);
+ int res = REAL(getgroups)(size, lst);
+ if (res && lst)
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, lst, res * sizeof(*lst));
+ return res;
+}
+#define INIT_GETGROUPS INTERCEPT_FUNCTION(getgroups);
+#else
+#define INIT_GETGROUPS
+#endif
+
#define SANITIZER_COMMON_INTERCEPTORS_INIT \
INIT_STRCMP; \
INIT_STRNCMP; \
@@ -1987,4 +2001,5 @@ INTERCEPTOR(int, scandir64, char *dirp,
INIT_STRERROR; \
INIT_STRERROR_R; \
INIT_SCANDIR; \
- INIT_SCANDIR64;
+ INIT_SCANDIR64; \
+ INIT_GETGROUPS;
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=188167&r1=188166&r2=188167&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h Mon Aug 12 06:01:40 2013
@@ -115,5 +115,6 @@
# define SANITIZER_INTERCEPT_STRERROR_R SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_SCANDIR SI_LINUX_NOT_ANDROID
# define SANITIZER_INTERCEPT_SCANDIR64 SI_LINUX_NOT_ANDROID
+# define SANITIZER_INTERCEPT_GETGROUPS SI_NOT_WINDOWS
#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=188167&r1=188166&r2=188167&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc Mon Aug 12 06:01:40 2013
@@ -358,6 +358,7 @@ void StatOutput(u64 *stat) {
name[StatInt_strerror_r] = " strerror_r ";
name[StatInt_scandir] = " scandir ";
name[StatInt_scandir64] = " scandir64 ";
+ name[StatInt_getgroups] = " getgroups ";
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=188167&r1=188166&r2=188167&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_stat.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_stat.h Mon Aug 12 06:01:40 2013
@@ -353,6 +353,7 @@ enum StatType {
StatInt_strerror_r,
StatInt_scandir,
StatInt_scandir64,
+ StatInt_getgroups,
// Dynamic annotations.
StatAnnotation,
More information about the llvm-commits
mailing list