diff options
author | Kamil Rytarowski <n54@gmx.com> | 2018-10-05 06:58:02 +0000 |
---|---|---|
committer | Kamil Rytarowski <n54@gmx.com> | 2018-10-05 06:58:02 +0000 |
commit | 980b424cbfe276fb48e2b517a139a8e5c7939f7d (patch) | |
tree | 9612eac13ce838645ff0b5dbda9d775e68ae3077 /compiler-rt/lib/sanitizer_common | |
parent | 7c65078f049b9c4d3a5117c8dd8aeb712ac8fe14 (diff) | |
download | bcm5719-llvm-980b424cbfe276fb48e2b517a139a8e5c7939f7d.tar.gz bcm5719-llvm-980b424cbfe276fb48e2b517a139a8e5c7939f7d.zip |
Introduce internal_sysctlbyname in place of sysctlbyname
Summary:
This change will allow to install sysctlbyname() interceptors
more easily in sanitizers.
Reviewers: vitalybuka, joerg
Reviewed By: vitalybuka
Subscribers: kubamracek, llvm-commits, #sanitizers
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D52793
llvm-svn: 343840
Diffstat (limited to 'compiler-rt/lib/sanitizer_common')
4 files changed, 27 insertions, 1 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc index 2e01149ae07..7633b10877a 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc @@ -591,7 +591,7 @@ static void GetArgsAndEnv(char ***argv, char ***envp) { // this information. See also <sys/exec.h>. ps_strings *pss; size_t sz = sizeof(pss); - if (sysctlbyname("kern.ps_strings", &pss, &sz, NULL, 0) == -1) { + if (internal_sysctlbyname("kern.ps_strings", &pss, &sz, NULL, 0) == -1) { Printf("sysctl kern.ps_strings failed\n"); Die(); } @@ -796,6 +796,16 @@ int internal_sysctl(const int *name, unsigned int namelen, void *oldp, return sysctl(name, namelen, oldp, (size_t *)oldlenp, newp, (size_t)newlen); #endif } + +int internal_sysctlbyname(const char *sname, void *oldp, uptr *oldlenp, + const void *newp, uptr newlen) { +#if SANITIZER_OPENBSD + return sysctlbyname(sname, oldp, (size_t *)oldlenp, (void *)newp, + (size_t)newlen); +#else + return sysctlbyname(sname, oldp, (size_t *)oldlenp, newp, (size_t)newlen); +#endif +} #endif #if SANITIZER_LINUX diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc index c9478927568..90bd0881584 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc @@ -219,6 +219,12 @@ int internal_sysctl(const int *name, unsigned int namelen, void *oldp, const_cast<void *>(newp), (size_t)newlen); } +int internal_sysctlbyname(const char *sname, void *oldp, uptr *oldlenp, + const void *newp, uptr newlen) { + return sysctlbyname(sname, oldp, (size_t *)oldlenp, const_cast<void *>(newp), + (size_t)newlen); +} + int internal_forkpty(int *amaster) { int master, slave; if (openpty(&master, &slave, nullptr, nullptr, nullptr) == -1) return -1; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_netbsd.cc b/compiler-rt/lib/sanitizer_common/sanitizer_netbsd.cc index 12316d8c06a..5f4d09f9f73 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_netbsd.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_netbsd.cc @@ -297,6 +297,14 @@ DEFINE_INTERNAL(int, sysctl, const int *name, unsigned int namelen, void *oldp, return __sysctl(name, namelen, oldp, (size_t *)oldlenp, newp, (size_t)newlen); } +DEFINE_INTERNAL(int, sysctlbyname, const char *sname, void *oldp, uptr *oldlenp, + const void *newp, uptr newlen) { + DEFINE__REAL(int, sysctlbyname, const char *a, void *b, size_t *c, + const void *d, size_t e); + return _REAL(sysctlbyname, sname, oldp, (size_t *)oldlenp, newp, + (size_t)newlen); +} + DEFINE_INTERNAL(uptr, sigprocmask, int how, __sanitizer_sigset_t *set, __sanitizer_sigset_t *oldset) { CHECK(&_sys___sigprocmask14); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_posix.h index c81eda61cf1..3075a13b980 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_posix.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix.h @@ -62,6 +62,8 @@ int internal_forkpty(int *amaster); int internal_sysctl(const int *name, unsigned int namelen, void *oldp, uptr *oldlenp, const void *newp, uptr newlen); +int internal_sysctlbyname(const char *sname, void *oldp, uptr *oldlenp, + const void *newp, uptr newlen); // These functions call appropriate pthread_ functions directly, bypassing // the interceptor. They are weak and may not be present in some tools. |