summaryrefslogtreecommitdiff
path: root/lib/msan
diff options
context:
space:
mode:
authorKamil Rytarowski <n54@gmx.com>2017-12-06 21:32:57 +0000
committerKamil Rytarowski <n54@gmx.com>2017-12-06 21:32:57 +0000
commitd4f4f7cd131af547f3d94219c1f486534fec2e60 (patch)
treebe72aadd5637c6fdc2ee73d59663d1f4c55b3403 /lib/msan
parent7c9843b5d84b56cd622b13dadf19a9159a2355be (diff)
Handle NetBSD symbol renaming in msan_interceptors.cc
Summary: NetBSD renames symbols for historical and compat reasons. Add required symbol renames in sanitizer_common_interceptors.inc: - gettimeofday -> __gettimeofday50 - getrusage -> __getrusage50 - shmctl -> __shmctl50 Additionally handle sigaction symbol mangling. Rename the function symbol in the file to SIGACTION_SYMNAME and define it as __sigaction14 for NetBSD and sigaction for !NetBSD. We cannot use simple renaming with the proprocessor, as there are valid fields named sigaction and they must be left intact. Sponsored by <The NetBSD Foundation> Reviewers: joerg, eugenis, vitalybuka, dvyukov Reviewed By: vitalybuka Subscribers: kubamracek, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40766 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319966 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/msan')
-rw-r--r--lib/msan/msan_interceptors.cc38
1 files changed, 21 insertions, 17 deletions
diff --git a/lib/msan/msan_interceptors.cc b/lib/msan/msan_interceptors.cc
index 73d419519..ae9c89494 100644
--- a/lib/msan/msan_interceptors.cc
+++ b/lib/msan/msan_interceptors.cc
@@ -22,6 +22,7 @@
#include "msan_thread.h"
#include "msan_poisoning.h"
#include "sanitizer_common/sanitizer_platform_limits_posix.h"
+#include "sanitizer_common/sanitizer_platform_limits_netbsd.h"
#include "sanitizer_common/sanitizer_allocator.h"
#include "sanitizer_common/sanitizer_allocator_interface.h"
#include "sanitizer_common/sanitizer_allocator_internal.h"
@@ -33,6 +34,11 @@
#include "sanitizer_common/sanitizer_linux.h"
#include "sanitizer_common/sanitizer_tls_get_addr.h"
+#if SANITIZER_NETBSD
+#define gettimeofday __gettimeofday50
+#define getrusage __getrusage50
+#endif
+
#include <stdarg.h>
// ACHTUNG! No other system header includes in this file.
// Ideally, we should get rid of stdarg.h as well.
@@ -1134,21 +1140,6 @@ INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg,
return REAL(__cxa_atexit)(MSanAtExitWrapper, r, dso_handle);
}
-DECLARE_REAL(int, shmctl, int shmid, int cmd, void *buf)
-
-INTERCEPTOR(void *, shmat, int shmid, const void *shmaddr, int shmflg) {
- ENSURE_MSAN_INITED();
- void *p = REAL(shmat)(shmid, shmaddr, shmflg);
- if (p != (void *)-1) {
- __sanitizer_shmid_ds ds;
- int res = REAL(shmctl)(shmid, shmctl_ipc_stat, &ds);
- if (!res) {
- __msan_unpoison(p, ds.shm_segsz);
- }
- }
- return p;
-}
-
static void BeforeFork() {
StackDepotLockAll();
ChainedOriginDepotLockAll();
@@ -1340,7 +1331,7 @@ static int sigaction_impl(int signo, const __sanitizer_sigaction *act,
pnew_act->sigaction = (decltype(pnew_act->sigaction))new_cb;
}
}
- res = REAL(sigaction)(signo, pnew_act, oldact);
+ res = REAL(SIGACTION_SYMNAME)(signo, pnew_act, oldact);
if (res == 0 && oldact) {
uptr cb = (uptr)oldact->sigaction;
if (cb == (uptr)SignalAction || cb == (uptr)SignalHandler) {
@@ -1348,7 +1339,7 @@ static int sigaction_impl(int signo, const __sanitizer_sigaction *act,
}
}
} else {
- res = REAL(sigaction)(signo, act, oldact);
+ res = REAL(SIGACTION_SYMNAME)(signo, act, oldact);
}
if (res == 0 && oldact) {
@@ -1430,6 +1421,19 @@ static int msan_dl_iterate_phdr_cb(__sanitizer_dl_phdr_info *info, SIZE_T size,
return cbdata->callback(info, size, cbdata->data);
}
+INTERCEPTOR(void *, shmat, int shmid, const void *shmaddr, int shmflg) {
+ ENSURE_MSAN_INITED();
+ void *p = REAL(shmat)(shmid, shmaddr, shmflg);
+ if (p != (void *)-1) {
+ __sanitizer_shmid_ds ds;
+ int res = REAL(shmctl)(shmid, shmctl_ipc_stat, &ds);
+ if (!res) {
+ __msan_unpoison(p, ds.shm_segsz);
+ }
+ }
+ return p;
+}
+
INTERCEPTOR(int, dl_iterate_phdr, dl_iterate_phdr_cb callback, void *data) {
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, dl_iterate_phdr, callback, data);