summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_common_interceptors.inc
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-10-24 14:47:34 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-10-24 14:47:34 +0000
commit10362d66fffcd99bd5ced983e4b389dfeba114d0 (patch)
treeae8c70de46a077ca5cd55908fe483219c13251d5 /lib/sanitizer_common/sanitizer_common_interceptors.inc
parent1161eb4bff61908074699f6459eabce25839f966 (diff)
downloadcompiler-rt-10362d66fffcd99bd5ced983e4b389dfeba114d0.tar.gz
compiler-rt-10362d66fffcd99bd5ced983e4b389dfeba114d0.tar.bz2
compiler-rt-10362d66fffcd99bd5ced983e4b389dfeba114d0.tar.xz
[sanitizer] Intercept shmctl.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@193348 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_common_interceptors.inc')
-rw-r--r--lib/sanitizer_common/sanitizer_common_interceptors.inc23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_common_interceptors.inc b/lib/sanitizer_common/sanitizer_common_interceptors.inc
index 9cef9380..4beedd21 100644
--- a/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -2504,6 +2504,28 @@ INTERCEPTOR(__sanitizer_ether_addr *, ether_aton_r, char *buf,
#define INIT_ETHER_R
#endif
+#if SANITIZER_INTERCEPT_SHMCTL
+INTERCEPTOR(int, shmctl, int shmid, int cmd, void *buf) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, shmctl, shmid, cmd, buf);
+ int res = REAL(shmctl)(shmid, cmd, buf);
+ if (res >= 0) {
+ unsigned sz = 0;
+ if (cmd == shmctl_ipc_stat || cmd == shmctl_shm_stat)
+ sz = struct_shmid_ds_sz;
+ else if (cmd == shmctl_ipc_info)
+ sz = struct_shminfo_sz;
+ else if (cmd == shmctl_shm_info)
+ sz = struct_shm_info_sz;
+ if (sz) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, buf, sz);
+ }
+ return res;
+}
+#define INIT_SHMCTL INTERCEPT_FUNCTION(shmctl);
+#else
+#define INIT_SHMCTL
+#endif
+
#define SANITIZER_COMMON_INTERCEPTORS_INIT \
INIT_STRCMP; \
INIT_STRNCMP; \
@@ -2597,4 +2619,5 @@ INTERCEPTOR(__sanitizer_ether_addr *, ether_aton_r, char *buf,
INIT_INITGROUPS; \
INIT_ETHER; \
INIT_ETHER_R; \
+ INIT_SHMCTL; \
/**/