summaryrefslogtreecommitdiff
path: root/lib/msan/msan_interceptors.cc
AgeCommit message (Collapse)Author
2017-12-06Disable absent functions in MSan/NetBSD interceptorsKamil Rytarowski
Summary: Disable for NetBSD missing functions missing in this OS: - mempcpy, - __libc_memalign, - malloc_usable_size, - stpcpy, - gcvt, - wmempcpy, - fcvt. Sponsored by <The NetBSD Foundation> Reviewers: joerg, dvyukov, eugenis, vitalybuka, kcc Reviewed By: vitalybuka Subscribers: llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40764 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319866 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-05[msan] Fix formattingVitaly Buka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319844 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-05[msan] add strtouq msan interceptorVitaly Buka
Summary: Fixes https://github.com/google/sanitizers/issues/892 Reviewers: eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D40853 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319843 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-30[msan] Fix return type of mbrtowcVitaly Buka
Summary: Fixes https://github.com/google/oss-fuzz/issues/1009 Reviewers: eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D40676 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319484 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-27[msan] Avoid shadowing a variable in common interceptors.Evgeniy Stepanov
"offset" declared in a macro may shadow a variable with the same name in the caller which is used in a macro argument. We are quite lucky that it does not actually happen, but rename the variable anyway to be on the safe side. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319115 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-11[msan] Fix signal chainingVitaly Buka
Return internally stored handlers only if handlers is set to wrapper git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317970 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-10[msan] Remove INTERCEPT_FUNCTION for sigaction and signalVitaly Buka
Already done in InitializeSignalInterceptors() git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317906 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-10[tsan] Use __sanitizer_siginfo from sanitizer_commonVitaly Buka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317872 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-10[msan] Deadly signal handler for msanVitaly Buka
Summary: Part of https://github.com/google/sanitizers/issues/637 Reviewers: eugenis, alekseyshl Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D39826 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317864 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-10[msan] Move sigaction_impl and signal_implVitaly Buka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317863 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-09[msan] Extract signal_impl and sigaction_implVitaly Buka
Summary: Preparation for using interceptor from sanitizer_common. Reviewers: eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D39824 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317844 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-25[msan] Intercept __strxfrm_l.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@316613 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-06[msan] Remove a stale fixme (NFC).Evgeniy Stepanov
It was fixed in 312576. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@312597 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-09-02(NFC) Fix the use of do{}while(0) in a macro.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@312396 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-18[Sanitizers] ASan/MSan/LSan allocators set errno on failure.Alex Shlyapnikov
Summary: ASan/MSan/LSan allocators set errno on allocation failures according to malloc/calloc/etc. expected behavior. MSan allocator was refactored a bit to make its structure more similar with other allocators. Also switch Scudo allocator to the internal errno definitions. TSan allocator changes will follow. Reviewers: eugenis Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D35275 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308344 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-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-05Revert r304285, r304297.Evgeniy Stepanov
r304285 - [sanitizer] Avoid possible deadlock in child process after fork r304297 - [sanitizer] Trying to fix MAC buildbots after r304285 These changes create deadlock when Tcl calls pthread_create from a pthread_atfork child handler. More info in the original review at https://reviews.llvm.org/D33325 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304735 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-31[sanitizer] Avoid possible deadlock in child process after forkMaxim Ostapenko
This patch addresses https://github.com/google/sanitizers/issues/774. When we fork a multi-threaded process it's possible to deadlock if some thread acquired StackDepot or allocator internal lock just before fork. In this case the lock will never be released in child process causing deadlock on following memory alloc/dealloc routine. While calling alloc/dealloc routines after multi-threaded fork is not allowed, most of modern allocators (Glibc, tcmalloc, jemalloc) are actually fork safe. Let's do the same for sanitizers except TSan that has complex locking rules. Differential Revision: https://reviews.llvm.org/D33325 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304285 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-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-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-14[msan] Intercept wcsncpy, wcsnlen.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@297793 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-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-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
2016-09-26[msan] Fix second parameter in MsanReallocate from previous commit.Maxim Ostapenko
It's wrong to pass to MsanReallocate a pointer that MSan allocator doesn't own. Use nullptr instead of ptr to prevent possible (still unlikely) failure. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@282390 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-26[asan, msan] Fix reallocation logic when IsInDlsymAllocPool(ptr) is true.Maxim Ostapenko
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@282389 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-23[msan] Prevent initialization failure with newer (2.23+) glibc in use.Maxim Ostapenko
This patch is pretty the same as http://reviews.llvm.org/D20235 that we used for ASan. Using the same hack for MSan fixes its initialization with newer Glibc in use. Differential Revision: https://reviews.llvm.org/D24736 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@282232 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19Revert "[sanitizer] Move *fstat to the common interceptors"Benjamin Kramer
This reverts commit r269981. Breaks msan tests on linux http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/24019/steps/test%20standalone%20compiler-rt/logs/stdio git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@270076 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18[sanitizer] Move *fstat to the common interceptorsMike Aizatsky
Summary: Adds *fstat to the common interceptors. Removes the now-duplicate fstat interceptor from msan/tsan This adds fstat to asan/esan, which previously did not intercept it. Resubmit of http://reviews.llvm.org/D20318 with ios build fixes. Reviewers: eugenis, vitalybuka, aizatsky Subscribers: zaks.anna, kcc, bruening, kubabrecka, srhines, danalbert, tberghammer Differential Revision: http://reviews.llvm.org/D20350 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269981 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17Revert "[sanitizer] Move *fstat to the common interceptors"Mike Aizatsky
This reverts commit http://reviews.llvm.org/rL269856 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269863 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17[sanitizer] Move *fstat to the common interceptorsMike Aizatsky
Summary: Adds *fstat to the common interceptors. Removes the now-duplicate fstat interceptor from msan/tsan This adds fstat to asan/esan, which previously did not intercept it. Reviewers: eugenis, vitalybuka, aizatsky Subscribers: tberghammer, danalbert, srhines, kubabrecka, bruening, kcc Differential Revision: http://reviews.llvm.org/D20318 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269856 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-11[sanitizer] Move *stat to the common interceptorsEvgeniy Stepanov
Adds *stat to the common interceptors. Removes the now-duplicate *stat interceptor from msan/tsan/esan. This adds *stat to asan, which previously did not intercept it. Patch by Qin Zhao. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269223 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-03[sanitizer] Move stat/__xstat to the common interceptorsMike Aizatsky
Summary: Adds stat/__xstat to the common interceptors. Removes the now-duplicate stat/__xstat interceptor from msan/tsan/esan. This adds stat/__xstat to asan, which previously did not intercept it. Resubmit of http://reviews.llvm.org/D19875 with win build fixes. Reviewers: aizatsky, eugenis Subscribers: tberghammer, llvm-commits, danalbert, vitalybuka, bruening, srhines, kubabrecka, kcc Differential Revision: http://reviews.llvm.org/D19890 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@268466 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-03Revert "[sanitizer] Move stat/__xstat to the common interceptors"Mike Aizatsky
This reverts commit 268440 because it breaks the windows bot. http://lab.llvm.org:8011/builders/sanitizer-windows/builds/21425/steps/build%20compiler-rt/logs/stdio git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@268448 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-03[sanitizer] Move stat/__xstat to the common interceptorsMike Aizatsky
Summary: Adds stat/__xstat to the common interceptors. Removes the now-duplicate stat/__xstat interceptor from msan/tsan/esan. This adds stat/__xstat to asan, which previously did not intercept it. Reviewers: aizatsky, eugenis Subscribers: tberghammer, danalbert, srhines, kubabrecka, llvm-commits, vitalybuka, eugenis, kcc, bruening Differential Revision: http://reviews.llvm.org/D19875 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@268440 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27[sanitizers] Get the proper symbol version when long double transition is ↵Marcin Koscielnicki
involved. On linux, some architectures had an ABI transition from 64-bit long double (ie. same as double) to 128-bit long double. On those, glibc symbols involving long doubles come in two versions, and we need to pass the correct one to dlvsym when intercepting them. A few more functions we intercept are also versioned (all printf, scanf, strtold variants), but there's no need to fix these, as the REAL() versions are never called. Differential Revision: http://reviews.llvm.org/D19555 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267794 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-25[MSan] Use COMMON_INTERCEPTOR_ENTER in libdl interceptors.Marcin Koscielnicki
This fixes fails in test/msan/dlerror.cc - when real dlerror calls strcmp, our strcmp interceptor now skips poison checking, since it's called in interceptor context. Strictly speaking, only the dlerror change is necessary to fix the fail, but let's also change the other two just in case. Differential Revision: http://reviews.llvm.org/D19499 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267486 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-25[sanitizer] Add memset, memmove, and memcpy to the common interceptorsDerek Bruening
Summary: Currently, sanitizer_common_interceptors.inc has an implicit, undocumented assumption that the sanitizer including it has previously declared interceptors for memset and memmove. Since the memset, memmove, and memcpy routines require interception by many sanitizers, we add them to the set of common interceptions, both to address the undocumented assumption and to speed future tool development. They are intercepted under a new flag intercept_intrin. The tsan interceptors are removed in favor of the new common versions. The asan and msan interceptors for these are more complex (they incur extra interception steps and their function bodies are exposed to the compiler) so they opt out of the common versions and keep their own. Reviewers: vitalybuka Subscribers: zhaoqin, llvm-commits, kcc Differential Revision: http://reviews.llvm.org/D18465 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@264451 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-23[sanitizer] Add strnlen to the common interceptorsDerek Bruening
Summary: Adds strnlen to the common interceptors, under the existing flag intercept_strlen. Removes the now-duplicate strnlen interceptor from asan and msan. This adds strnlen to tsan, which previously did not intercept it. Adds a new test of strnlen to the sanitizer_common test cases. Reviewers: samsonov Subscribers: zhaoqin, llvm-commits, kcc Differential Revision: http://reviews.llvm.org/D18397 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@264195 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-11[sanitizer] Add strlen to the common interceptorsAlexey Samsonov
Summary: Adds strlen to the common interceptors, under a new common flag intercept_strlen. This provides better sharing of interception code among sanitizers and cleans up the inconsistent type declarations of the previously duplicated interceptors. Removes the now-duplicate strlen interceptor from asan, msan, and tsan. The entry check semantics are normalized now for msan and asan, whose private strlen interceptors contained multiple layers of checks that included impossible-to-reach code. The new semantics are identical to the old: bypass interception if in the middle of init or if both on Mac and not initialized; else, call the init routine and proceed. Patch by Derek Bruening! Reviewers: samsonov, vitalybuka Subscribers: llvm-commits, kcc, zhaoqin Differential Revision: http://reviews.llvm.org/D18020 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@263177 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-26[MSAN] Fix test SmallPreAllocatedStackThread for MIPSSagar Thakur
Summary: Msan was intercepting version 2.1 of the pthread_create function which was making it to crash in libc because __pthread_create_2_1 modifies the stack attributes of the thread. Intercepting the correct version fixes the test SmallPreAllocatedStackThread. Reviewers: eugenis, samsonov Subscribers: llvm-commits, mohit.bhakkad, jaydeep Differential: http://reviews.llvm.org/D17603 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@261980 91177308-0d34-0410-b5e6-96231b3b80d8