summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_common_interceptors.inc
AgeCommit message (Collapse)Author
2017-12-28[msan] Intercept pthread_getname_np.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@321544 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-18[asan] Add interceptor for printf_chkMaxim Ostapenko
There could be a situation when a specific DSO was built with FORTIFY_SOURCE option. In case asan-ed binary link against that DSO, libasan can't handle the possible memory error because it does not have interceptors for spinrtf_chk, snprintf_chk, vprintf_chk, vsnprintf_chk, __fprintf_chk functions. Let's interceptors for them. Patch by Denis Khalikov. Differential Revision: https://reviews.llvm.org/D40951 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@320990 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-14[Sanitizers] Basic sanitizer Solaris support (PR 33274)Kamil Rytarowski
Summary: This is the first mostly working version of the Sanitizer port to 32-bit Solaris/x86. It is currently based on Solaris 11.4 Beta. This part was initially developed inside libsanitizer in the GCC tree and should apply to both. Subsequent parts will address changes to clang, the compiler-rt build system and testsuite. I'm not yet sure what the right patch granularity is: if it's profitable to split the patch up, I'd like to get guidance on how to do so. Most of the changes are probably straightforward with a few exceptions: * The Solaris syscall interface isn't stable, undocumented and can change within an OS release. The stable interface is the libc interface, which I'm using here, if possible using the internal _-prefixed names. * While the patch primarily target 32-bit x86, I've left a few sparc changes in. They cannot currently be used with clang due to a backend limitation, but have worked fine inside the gcc tree. * Some functions (e.g. largefile versions of functions like open64) only exist in 32-bit Solaris, so I've introduced a separate SANITIZER_SOLARIS32 to check for that. The patch (with the subsequent ones to be submitted shortly) was tested on i386-pc-solaris2.11. Only a few failures remain, some of them analyzed, some still TBD: AddressSanitizer-i386-sunos :: TestCases/Posix/concurrent_overflow.cc AddressSanitizer-i386-sunos :: TestCases/init-order-atexit.cc AddressSanitizer-i386-sunos :: TestCases/log-path_test.cc AddressSanitizer-i386-sunos :: TestCases/malloc-no-intercept.c AddressSanitizer-i386-sunos-dynamic :: TestCases/Posix/concurrent_overflow.cc AddressSanitizer-i386-sunos-dynamic :: TestCases/Posix/start-deactivated.cc AddressSanitizer-i386-sunos-dynamic :: TestCases/default_options.cc AddressSanitizer-i386-sunos-dynamic :: TestCases/init-order-atexit.cc AddressSanitizer-i386-sunos-dynamic :: TestCases/log-path_test.cc AddressSanitizer-i386-sunos-dynamic :: TestCases/malloc-no-intercept.c SanitizerCommon-Unit :: ./Sanitizer-i386-Test/MemoryMappingLayout.DumpListOfModules SanitizerCommon-Unit :: ./Sanitizer-i386-Test/SanitizerCommon.PthreadDestructorIterations Maybe this is good enough the get the ball rolling. Reviewers: kcc, alekseyshl Reviewed By: alekseyshl Subscribers: srhines, jyknight, kubamracek, krytarowski, fedor.sergeev, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40898 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@320740 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-13[sanitizer] Introduce a vDSO aware timing functionKostya Kortchinsky
Summary: See D40657 & D40679 for previous versions of this patch & description. A couple of things were fixed here to have it not break some bots. Weak symbols can't be used with `SANITIZER_GO` so the previous version was breakin TsanGo. I set up some additional local tests and those pass now. I changed the workaround for the glibc vDSO issue: `__progname` is initialized after the vDSO and is actually public and of known type, unlike `__vdso_clock_gettime`. This works better, and with all compilers. The rest is the same. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: srhines, kubamracek, krytarowski, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D41121 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@320594 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-11[sanitizer] Revert rL320409Kostya Kortchinsky
Summary: D40679 broke a couple of builds, reverting while investigating. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: srhines, kubamracek, krytarowski, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D41088 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@320417 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-11[sanitizer] Introduce a vDSO aware time function, and use it in the ↵Kostya Kortchinsky
allocator [redo] Summary: Redo of D40657, which had the initial discussion. The initial code had to move into a libcdep file, and things had to be shuffled accordingly. `NanoTime` is a time sink when checking whether or not to release memory to the OS. While reducing the amount of calls to said function is in the works, another solution that was found to be beneficial was to use a timing function that can leverage the vDSO. We hit a couple of snags along the way, like the fact that the glibc crashes when clock_gettime is called from a preinit_array, or the fact that `__vdso_clock_gettime` is mangled (for security purposes) and can't be used directly, and also that clock_gettime can be intercepted. The proposed solution takes care of all this as far as I can tell, and significantly improve performances and some Scudo load tests with memory reclaiming enabled. @mcgrathr: please feel free to follow up on https://reviews.llvm.org/D40657#940857 here. I posted a reply at https://reviews.llvm.org/D40657#940974. Reviewers: alekseyshl, krytarowski, flowerhack, mcgrathr, kubamracek Reviewed By: alekseyshl, krytarowski Subscribers: #sanitizers, mcgrathr, srhines, llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D40679 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@320409 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-09NetBSD ships with POSIX strerror_r(3)Kamil Rytarowski
Summary: Switch NetBSD from GNU to the POSIX strerror_r(3) interceptor. Sponsored by <The NetBSD Foundation> Reviewers: joerg, eugenis, vitalybuka Reviewed By: vitalybuka Subscribers: srhines, kubamracek, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D41019 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@320221 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-04Handle NetBSD symbol renaming in sanitizer_common_interceptors.incKamil Rytarowski
Summary: NetBSD renames symbols for historical and compat reasons. Add required symbol renames in sanitizer_common_interceptors.inc: - clock_gettime -> __clock_gettime50 - clock_getres -> __clock_getres50 - clock_settime -> __clock_settime50 - setitimer -> __setitimer50 - getitimer -> __getitimer50 - opendir -> __opendir30 - readdir -> __readdir30 - time -> __time50 - localtime_r -> __localtime_r50 - gmtime_r -> __gmtime_r50 - gmtime -> __gmtime50 - ctime -> __ctime50 - ctime_r -> __ctime_r50 - mktime -> __mktime50 - getpwnam -> __getpwnam50 - getpwuid -> __getpwuid50 - getpwnam_r -> __getpwnam_r50 - getpwuid_r -> __getpwuid_r50 - getpwent -> __getpwent50 - glob -> __glob30 - wait3 -> __wait350 - wait4 -> __wait450 - readdir_r -> __readdir_r30 - setlocale -> __setlocale50 - scandir -> __scandir30 - sigtimedwait -> __sigtimedwait50 - sigemptyset -> __sigemptyset14 - sigfillset -> __sigfillset14 - sigpending -> __sigpending14 - sigprocmask -> __sigprocmask14 - shmctl -> __shmctl50 - times -> __times13 - stat -> __stat50 - getutent -> __getutent50 - getutxent -> __getutxent50 - getutxid -> __getutxid50 - getutxline -> __getutxline50 Sponsored by <The NetBSD Foundation> Reviewers: joerg, vitalybuka, cryptoad, dvyukov Reviewed By: cryptoad Subscribers: llvm-commits, kubamracek, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40765 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319670 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-29[asan] Don't crash on fclose(NULL)Kuba Mracek
It's explicitly forbidden to call fclose with NULL, but at least on Darwin, this succeeds and doesn't segfault. To maintain binary compatibility, ASan should survice fclose(NULL) as well. Differential Revision: https://reviews.llvm.org/D40053 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319347 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-29[asan] Allow getpwnam(NULL) for binary compatibilityKuba Mracek
Calling getpwnam(NULL) is probably a bug, but at least on Darwin, such a call succeeds without segfaulting. I have some existing code that relies on that. To maintain binary compatibility, ASan should also survive a call to getpwnam with NULL. Differential Revision: https://reviews.llvm.org/D40052 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319344 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-20Correct return types of NetBSD specific functionsKamil Rytarowski
The __libc_mutex_lock, __libc_mutex_unlock and __libc_thr_setcancelstate functions return int, not void. This does not seem to introduce a functional change, however it looks better with fixed the function prototype. Sponsored by <The NetBSD Foundation> git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@318654 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-20Handle NetBSD specific indirection of libpthread functionsKamil Rytarowski
Summary: Correct handling of three libpthread(3) functions on NetBSD: - pthread_mutex_lock(3), - pthread_mutex_unlock(3), - pthread_setcancelstate(3). Code out of the libpthread(3) context uses the libc symbols: - __libc_mutex_lock, - __libc_mutex_unlock, - __libc_thr_setcancelstate. The threading library (libpthread(3)) defines strong aliases: - __strong_alias(__libc_mutex_lock,pthread_mutex_lock) - __strong_alias(__libc_mutex_unlock,pthread_mutex_unlock) - __strong_alias(__libc_thr_setcancelstate,pthread_setcancelstate) This caused that these functions were invisible to sanitizers on NetBSD. Intercept the libc-specific ones and add them as NetBSD-specific aliases for the common pthread(3) ones. NetBSD needs to intercept both functions, as the regularly named ones are used internally in libpthread(3). Sponsored by <The NetBSD Foundation> Reviewers: joerg, dvyukov, vitalybuka Reviewed By: dvyukov Subscribers: llvm-commits, kubamracek, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40241 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@318646 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-06[Sanitizers] Check pthread_setcancel{state|type} interceptor arguments for ↵Alex Shlyapnikov
!= nullptr. Summary: According to man, pthread_setcancelstate's oldstate and pthread_setcanceltype's oldtype parameters can be nullptr. Check these parameters for != nullptr before attempting to access their shadow memory. Reviewers: dvyukov Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D39626 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317494 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-25Add NetBSD improvements in sanitizersKamil Rytarowski
Summary: Changes: * Add initial msan stub support. * Handle NetBSD specific pthread_setname_np(3). * NetBSD supports __attribute__((tls_model("initial-exec"))), define it in SANITIZER_TLS_INITIAL_EXEC_ATTRIBUTE. * Add ReExec() specific bits for NetBSD. * Simplify code and add syscall64 and syscall_ptr for !NetBSD. * Correct bunch of syscall wrappers for NetBSD. * Disable test/tsan/map32bit on NetBSD as not applicable. * Port test/tsan/strerror_r to a POSIX-compliant OSes. * Disable __libc_stack_end on NetBSD. * Disable ReadNullSepFileToArray() on NetBSD. * Define struct_ElfW_Phdr_sz, detected missing symbol by msan. * Change type of __sanitizer_FILE from void to char. This helps to reuse this type as an array. Long term it will be properly implemented along with SANITIZER_HAS_STRUCT_FILE setting to 1. * Add initial NetBSD support in lib/tsan/go/buildgo.sh. * Correct referencing stdout and stderr in tsan_interceptors.cc on NetBSD. * Document NetBSD x86_64 specific virtual memory layout in tsan_platform.h. * Port tests/rtl/tsan_test_util_posix.cc to NetBSD. * Enable NetBSD tests in test/msan/lit.cfg. * Enable NetBSD tests in test/tsan/lit.cfg. Sponsored by <The NetBSD Foundation> Reviewers: joerg, vitalybuka, eugenis, kcc, dvyukov Reviewed By: dvyukov Subscribers: #sanitizers, llvm-commits, kubamracek Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D39124 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@316591 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-26Invalidate symbolizer module list from dlopen/dlclose interceptorsFrancis Ricci
Summary: The module list should only be invalidated by dlopen and dlclose, so the symbolizer should only re-generate it when we've hit one of those functions. Reviewers: kubamracek, rnk, vitalybuka Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D37268 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314219 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-05[msan] Check sigset_t and sigaction arguments.Evgeniy Stepanov
Summary: Check sigset_t arguments in ppoll, sig*wait*, sigprocmask interceptors, and the entire "struct sigaction" in sigaction. This can be done because sigemptyset/sigfullset are intercepted and signal masks should be correctly marked as initialized. Reviewers: vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D37367 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@312576 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-31[sanitizer_common] Rename SI_NOT_WINDOWS to SI_POSIXVitaly Buka
Summary: New systems might be neither Windows nor POSIX. The SI_NOT_WINDOWS macro in sanitizer_platform_interceptors.h was already effectively the same as SI_POSIX, so just use SI_POSIX instead. Submitted on behalf of Roland McGrath. Reviewers: vitalybuka, alekseyshl, kcc Reviewed By: vitalybuka Subscribers: phosek, filcab, llvm-commits, kubamracek Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36038 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@309536 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-06[Sanitizers] Consolidate internal errno definitions.Alex Shlyapnikov
Move internal errno definitions to common to be shared by all sanitizers and to be used by allocators. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@307233 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-29Fix WinASan after moving wcslen interceptor to sanitizer_commonReid Kleckner
Do this by removing SANITIZER_INTERCEPT_WCSLEN and intercept wcslen everywhere. Before this change, we were already intercepting wcslen on Windows, but the interceptor was in asan, not sanitizer_common. After this change, we stopped intercepting wcslen on Windows, which broke asan_dll_thunk.c, which attempts to thunk to __asan_wcslen in the ASan runtime. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@306706 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-27[msan] Intercept wcscat, wcsncat.Evgeniy Stepanov
Also move wcslen, wscnlen to common interceptors. Reviewers: vitalybuka Reviewed By: vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D34656 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@306482 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-07[tsan]: Fix GNU version of strerror_r interceptorVitaly Buka
GNU version of strerror_r returns a result pointer that doesn't match the input buffer. The result pointer is in fact a pointer to some internal storage. TSAN was recording a write to this location, which was incorrect. Fixed https://github.com/google/sanitizers/issues/696 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304858 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-01[asan] Add strndup/__strndup interceptors.Pierre Gousseau
Recommit of r302781 with Vitaly Buka's fix for non zero terminated strings. Differential Revision: https://reviews.llvm.org/D31457 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304399 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-18Revert r302781 and subsequent attempts to disable part of it.Daniel Jasper
The Msan unit tests are still broken and by this point, I think we should start over. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@303339 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-11[asan] Recommit of r301904: Add strndup/__strndup interceptorsPierre Gousseau
Fix undeclared __interceptor_malloc in esan_interceptors.cc Fix undeclared strnlen on OSX Differential Revision: https://reviews.llvm.org/D31457 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@302781 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03[sanitizer] Intercept mcheck and mprobe on LinuxMaxim Ostapenko
This patch addresses https://github.com/google/sanitizers/issues/804. Users can use mcheck and mprobe functions to verify heap state so we should intercept them to avoid breakage of valid code. Differential Revision: https://reviews.llvm.org/D32589 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@302001 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02Revert r301904 causing tsan test failure in x86_64-linux-autoconfPierre Gousseau
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301909 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02[asan] Add strndup/__strndup interceptors if targeting linux.Pierre Gousseau
Differential Revision: https://reviews.llvm.org/D31457 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301904 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-24[asan] Use posix strerror_r interceptor on android.Evgeniy Stepanov
This fixes a regression in r297315. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301243 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-21[asan] Optimize strchr for strict_string_checks=falseVitaly Buka
Summary: strchr interceptor does not need to call strlen if strict_string_checks is not enabled. Unnecessary strlen calls affect python parser performance. Reviewers: eugenis, kcc Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D32264 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301027 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-21Revert r300889, r300906, r300935, r300939Diana Picus
At least one of the ARM bots is still broken: Command Output (stderr): -- /home/buildslave/buildslave/clang-cmake-armv7-a15-full/llvm/projects/compiler-rt/test/asan/TestCases/Posix/strchr.c:31:12: error: expected string not found in input // CHECK: strchr.c:[[@LINE-2]] ^ <stdin>:3:59: note: scanning from here ==16297==ERROR: AddressSanitizer: SEGV on unknown address 0xb5add000 (pc 0xb6dccaa4 bp 0xbe8c19c8 sp 0xbe8c1570 T0) ^ <stdin>:3:59: note: with expression "@LINE-2" equal to "29" ==16297==ERROR: AddressSanitizer: SEGV on unknown address 0xb5add000 (pc 0xb6dccaa4 bp 0xbe8c19c8 sp 0xbe8c1570 T0) ^ <stdin>:5:57: note: possible intended match here #0 0xb6dccaa3 in strlen /build/glibc-f8FFOS/glibc-2.23/string/../sysdeps/arm/armv6t2/strlen.S:82 Try to fix by reverting r300889 and subsequent fixes: Revert "[asan] Fix test by removing "The signal is caused" check." Revert "[asan] Fix test on ppc64le-linux by checking "UNKNOWN memory access"" Revert "[asan] Match BUS and SIGV to fix test on Darwin" Revert "[asan] Optimize strchr for strict_string_checks=false" git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300955 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-20sanitizer: fix crash with textdomain(NULL) interceptorKostya Serebryany
Summary: The textdomain function accepts a NULL parameter (and should then return the current message domain). Add a check for this and include ASAN tests. Link: https://github.com/google/sanitizers/issues/787 Reviewers: m.guseva, kcc Reviewed By: kcc Subscribers: kubamracek Differential Revision: https://reviews.llvm.org/D32318 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300924 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-20[asan] Optimize strchr for strict_string_checks=falseVitaly Buka
Summary: strchr interceptor does not need to call strlen if strict_string_checks is not enabled. Unnecessary strlen calls affect python parser performance. Reviewers: eugenis, kcc Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D32264 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300889 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-12[msan] fix iconv interceptor. before the fix the interceptor failed to mark ↵Kostya Serebryany
memory as initialized if iconv returned -1. Found in a hard way while fuzzing libxml2 :( git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300010 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-30[sanitizer] Move fread and fwrite interceptors to sanitizer_commonMaxim Ostapenko
{M, T, E}San have fread and fwrite interceptors, let's move them to sanitizer_common to enable ASan checks as well. Differential Revision: https://reviews.llvm.org/D31456 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@299061 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-29[sanitizers] Fix get_groups interceptor in sanitizer ↵Kostya Serebryany
(https://reviews.llvm.org/D31332, patch by Martin Liška) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@299036 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-26tsan: add new mutex annotationsDmitry Vyukov
There are several problems with the current annotations (AnnotateRWLockCreate and friends): - they don't fully support deadlock detection (we need a hook _before_ mutex lock) - they don't support insertion of random artificial delays to perturb execution (again we need a hook _before_ mutex lock) - they don't support setting extended mutex attributes like read/write reentrancy (only "linker init" was bolted on) - they don't support setting mutex attributes if a mutex don't have a "constructor" (e.g. static, Java, Go mutexes) - they don't ignore synchronization inside of lock/unlock operations which leads to slowdown and false negatives The new annotations solve of the above problems. See tsan_interface.h for the interface specification and comments. Reviewed in https://reviews.llvm.org/D31093 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298809 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-23[asan] Add an interceptor for strtokAlex Shlyapnikov
Summary: This change addresses https://github.com/google/sanitizers/issues/766. I tested the change with make check-asan and the newly added test case. Reviewers: ygribov, kcc, alekseyshl Subscribers: kubamracek, llvm-commits Patch by mrigger Differential Revision: https://reviews.llvm.org/D30384 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298650 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-16[msan] Intercept getloadavg.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@297923 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-09[sanitizer] Bail out with warning if user dlopens shared library with ↵Maxim Ostapenko
RTLD_DEEPBIND flag People keep hitting on spurious failures in malloc/free routines when using sanitizers with shared libraries dlopened with RTLD_DEEPBIND (see https://github.com/google/sanitizers/issues/611 for details). Let's check for this flag and bail out with warning message instead of failing in random places. Differential Revision: https://reviews.llvm.org/D30504 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@297370 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-08Use correct function signature for strerror_r interceptorFrancis Ricci
There are two possible return values for strerror_r: On OS X, the return value is always `int`. On Linux, the return value can be either `char *` or `int`, depending on the value of: `(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE` Because OS X interceptors require a matching function signature, split out the two cases into separate interceptors, using the above information to determine the correct signature for a given build. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@297315 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-10s390x __tls_get_addr_internal vs. __tls_get_offsetKostya Serebryany
Summary: Symbol __tls_get_addr_internal is a GLIBC_PRIVATE private symbol on s390{,x}, the glibc folks aren't very happy about asan using it. Additionally, only recent glibc versions have it, older versions just have __tls_get_offset and nothing else. The patch doesn't drop the __tls_get_addr_internal interception altogether, but changes it so that it calls real __tls_get_offset function instead (and much more importantly, that __tls_get_offset interception calls the real __tls_get_offset function). This way it should work also on glibc 2.18 and earlier. See http://gcc.gnu.org/PR79341 for further details. Reviewers: kcc, koriakin Reviewed By: kcc, koriakin Subscribers: kubamracek, mehdi_amini Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D29735 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@294790 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-01[sanitizer] Support SANITIZER_INTERCEPTOR_HOOKS on DarwinJustin Bogner
This basically already worked other than weak symbols needing definitions on darwin. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293741 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-27[compiler-rt] Fix compilation error after r290626Vitaly Buka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290629 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-27[compiler-rt] Move logic which replace memcpy interceptor with memmove from ↵Vitaly Buka
asan to sanitizer_common. Reviewers: eugenis Subscribers: kubabrecka, dberris, llvm-commits Differential Revision: https://reviews.llvm.org/D28074 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290626 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-23[compiler-rt] Define COMMON_INTERCEPT_FUNCTION_MEMCPY for tsan and esanVitaly Buka
Reviewers: eugenis Subscribers: kubabrecka, dberris, llvm-commits Differential Revision: https://reviews.llvm.org/D28072 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290396 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-23Fix interceptors setup broken after r290382Vitaly Buka
Summary: We setup these interceptors twice which hangs test on windows. Reviewers: eugenis Subscribers: llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D28070 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290393 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-22Replace WRAP in interceptors with memset, memmove and memcpy implementationVitaly Buka
Summary: According https://reviews.llvm.org/D27659#625093 WRAP adds confusing stack frame. Reviewers: eugenis Subscribers: kubabrecka, llvm-commits Differential Revision: https://reviews.llvm.org/D28039 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290382 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-15[msan] Intercept getutent and friends.Evgeniy Stepanov
Differential Revision: https://reviews.llvm.org/D27791 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@289878 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-15Revert r289690 "[sanitizer] intercept bstring functions, patch by Kuang-che ↵Hans Wennborg
Wu (https://reviews.llvm.org/D27659)" It breaks programs on Mac. See comments on the code review for details. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@289864 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-14[sanitizer] intercept bstring functions, patch by Kuang-che Wu ↵Kostya Serebryany
(https://reviews.llvm.org/D27659) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@289690 91177308-0d34-0410-b5e6-96231b3b80d8