summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_posix.h
AgeCommit message (Collapse)Author
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-08-28Add NetBSD specific version of sanitizer_platform_limits_posixKamil Rytarowski
Summary: NetBSD is an Open-Source POSIX-like BSD Operating System. Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas. Sponsored by <The NetBSD Foundation> Reviewers: joerg, kcc, vitalybuka, filcab, fjricci Reviewed By: kcc Subscribers: llvm-commits, kubamracek, mgorny, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D37193 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@311933 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-13Don't assume PTHREAD_CREATE_JOINABLE is 0 on all systemsFrancis Ricci
Summary: Lsan was using PTHREAD_CREATE_JOINABLE/PTHREAD_CREATE_DETACHED as truthy values, which works on Linux, where the values are 0 and 1, but this fails on OS X, where the values are 1 and 2. Set PTHREAD_CREATE_DETACHED to the correct value for a given system. Reviewers: kcc, glider, kubamracek, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31883 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300221 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06[esan|wset] Ensure SIGSEGV is not blockedDerek Bruening
Summary: Adds interception of sigprocmask and pthread_sigmask to esan so that the working set tool can prevent SIGSEGV from being blocked. A blocked SIGSEGV results in crashes due to our lazy shadow page allocation scheme. Adds new sanitizer helper functions internal_sigemptyset and internal_sigismember. Adds a test to workingset-signal-posix.cpp. Reviewers: aizatsky Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka Differential Revision: http://reviews.llvm.org/D22063 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@274672 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03[esan] Ensure internal_sigaction() bypasses interceptorsDerek Bruening
Summary: Implements real_sigaction() which it turns out is required for internal_sigaction() to bypass the libc interceptors. Without real_sigaction(), our internal_sigaction() calls during init happen to work due to the EsanDuringInit check in COMMON_INTERCEPTOR_ENTER (though even here it does not feel right for an "internal_" call to go through the interceptor). The real problem is when we call internal_sigaction() after we're initialized, which only happens on an unhandled SIGSEGV for which the app has no handler: then we'll spin in an infinite loop as our attempts to remove our own handler repeatedly fail. It's not easy to add a test for that, unfortunately. Reviewers: aizatsky Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka Differential Revision: http://reviews.llvm.org/D20832 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@271626 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-26[sanitizers] extracted process management functionsMike Aizatsky
Differential Revision: http://reviews.llvm.org/D16546 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@258849 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-15[tsan] Use internal_sigfillset to replace REAL(sigfillset).Yabin Cui
Summary: Android doesn't intercept sigfillset, so REAL(sigfillset) is null. And we can use internal_sigfillset() for all cases. Reviewers: kcc, eugenis, kubabrecka, dvyukov Subscribers: llvm-commits, tberghammer, danalbert Differential Revision: http://reviews.llvm.org/D15296 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@257862 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-20[sanitizer] Implement internal_fork and internal_forkpty for OS XKuba Brecka
On Linux, we have internal_fork that forks without invoking user's pthread_atfork handlers, which is important for spawning external symbolizers. Let's implement this for OS X as well (using __fork). This patch also adds internal_forkpty which re-implements forkpty and uses __fork in it as well. Differential Revision: http://reviews.llvm.org/D14869 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253666 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-03Reapply r251918 ("[tsan] Fix build errors for TSan on OS X").Kuba Brecka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251920 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-31Re-commit r243686 - [Sanitizers] [Bug 24151] Generalize type of offset in ↵Daniel Sanders
internal_mmap The builder remains broken in the same way without this patch so this patch is innocent. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@243744 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-31Revert r243686 - [Sanitizers] [Bug 24151] Generalize type of offset in ↵Daniel Sanders
internal_mmap It's implicated in a buildbot failure and while the failure looks unrelated, this commit is the only probably candidate in the blamelist. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@243740 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-30[Sanitizers] [Bug 24151] Generalize type of offset in internal_mmapDaniel Sanders
Summary: Using u64 as type for offset changes its value, changing starting address for map in file. This patch solves Bug 24151, which raises issue while mapping file in mips32. Patch by Mohit Bhakkad Reviewers: dsanders, kcc Subscribers: hans, llvm-commits, samsonov, nitesh.jain, sagar, bhushan, jaydeep Differential Revision: http://reviews.llvm.org/D11588 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@243686 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-10Split Mprotect into MmapNoAccess and MprotectNoAccess to be more portableTimur Iskhodzhanov
On Windows, we have to know if a memory to be protected is mapped or not. On POSIX, Mprotect was semantically different from mprotect most people know. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234602 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09Use RenameFile instead of internal_rename in non-POSIX codeTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234490 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09Use WriteToFile instead of internal_write in non-POSIX codeTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234487 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09Use ReadFromFile instead of internal_read in non-POSIX codeTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234485 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09Move more POSIX-specific functions to sanitizer_posix.hTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234482 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09Introduce CloseFile to be used instead of internal_close on non-POSIXTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234481 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-08Move some POSIX-specific functions from sanitizer_libc.h to a new ↵Timur Iskhodzhanov
sanitizer_posix.h git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234418 91177308-0d34-0410-b5e6-96231b3b80d8