summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2014-03-28 11:46:35 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2014-03-28 11:46:35 +0000
commit163ee4efb529147c53ddc12ac69ec8448d9a3cc8 (patch)
tree42f971613ab91af4b5c884a180b709d93df1db17
parent92bee36b3efa2e7fd23f661412fb75c8fff0151e (diff)
downloadbcm5719-llvm-163ee4efb529147c53ddc12ac69ec8448d9a3cc8.tar.gz
bcm5719-llvm-163ee4efb529147c53ddc12ac69ec8448d9a3cc8.zip
[sanitizer] Intercept setpwent/endpwent.
It's hard to write a reliable test for this code because they work with unpredictable memory locations. But this change should fix current failures in getpwent() tests on the sanitizer bots. llvm-svn: 205002
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc34
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h1
2 files changed, 35 insertions, 0 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index 21574093561..7a9d9f64cd1 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -1092,6 +1092,39 @@ INTERCEPTOR(int, fgetgrent_r, void *fp, void *pwbuf, char *buf, SIZE_T buflen,
#define INIT_GETPWENT_R
#endif
+#if SANITIZER_INTERCEPT_SETPWENT
+// The only thing these interceptors do is disable any nested interceptors.
+// These functions may open nss modules and call uninstrumented functions from
+// them, and we don't want things like strlen() to trigger.
+INTERCEPTOR(void, setpwent, int dummy) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, setpwent, dummy);
+ REAL(setpwent)(dummy);
+}
+INTERCEPTOR(void, endpwent, int dummy) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, endpwent, dummy);
+ REAL(endpwent)(dummy);
+}
+INTERCEPTOR(void, setgrent, int dummy) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, setgrent, dummy);
+ REAL(setgrent)(dummy);
+}
+INTERCEPTOR(void, endgrent, int dummy) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, endgrent, dummy);
+ REAL(endgrent)(dummy);
+}
+#define INIT_SETPWENT \
+ COMMON_INTERCEPT_FUNCTION(setpwent); \
+ COMMON_INTERCEPT_FUNCTION(endpwent); \
+ COMMON_INTERCEPT_FUNCTION(setgrent); \
+ COMMON_INTERCEPT_FUNCTION(endgrent);
+#else
+#define INIT_SETPWENT
+#endif
+
#if SANITIZER_INTERCEPT_CLOCK_GETTIME
INTERCEPTOR(int, clock_getres, u32 clk_id, void *tp) {
void *ctx;
@@ -3635,6 +3668,7 @@ INTERCEPTOR(int, ftime, __sanitizer_timeb *tp) {
INIT_GETPWNAM_R_AND_FRIENDS; \
INIT_GETPWENT; \
INIT_GETPWENT_R; \
+ INIT_SETPWENT; \
INIT_CLOCK_GETTIME; \
INIT_GETITIMER; \
INIT_TIME; \
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
index dc559398cf2..b2955bac5da 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
@@ -90,6 +90,7 @@
SI_MAC || SI_LINUX_NOT_ANDROID
#define SANITIZER_INTERCEPT_GETPWENT SI_NOT_WINDOWS
#define SANITIZER_INTERCEPT_GETPWENT_R SI_LINUX_NOT_ANDROID
+#define SANITIZER_INTERCEPT_SETPWENT SI_NOT_WINDOWS
#define SANITIZER_INTERCEPT_CLOCK_GETTIME SI_LINUX
#define SANITIZER_INTERCEPT_GETITIMER SI_NOT_WINDOWS
#define SANITIZER_INTERCEPT_TIME SI_NOT_WINDOWS
OpenPOWER on IntegriCloud