summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
AgeCommit message (Collapse)Author
2017-11-21Correct NetBSD support in pthread_once(3)/TSanKamil Rytarowski
Summary: The pthread_once(3)/NetBSD type is built with the following structure: struct __pthread_once_st { pthread_mutex_t pto_mutex; int pto_done; }; Set the pto_done position as shifted by __sanitizer::pthread_mutex_t_sz from the beginning of the pthread_once struct. This corrects deadlocks when the pthread_once(3) function is used. 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/D40262 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@318742 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-10[tsan] Move out more types to sanitizer_commonVitaly Buka
https://github.com/google/sanitizers/issues/637 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317946 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-02-10Remove struct_rtentry_sz on FreeBSDDimitry Andric
Summary: Since struct rtentry is an internal kernel-only structure on FreeBSD, and SIOCADDRT and SIOCDELRT are not supported anyway, stop including socketvar.h and attempting to get at the definition of struct rtentry, and move the line with struct_rtentry_sz to the SANIZER_LINUX block. Reviewers: kcc, kutuzov.viktor.84, emaste Reviewed By: kcc, emaste Subscribers: emaste, llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D29832 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@294806 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-20Fix build breakage on FreeBSD after rL289878/rL289881Dimitry Andric
Summary: After rL289878/rL289881, the build on FreeBSD is broken, because sanitizer_platform_limits_posix.cc attempts to include <utmp.h> and use `struct utmp`, neither of which are supported anymore on FreeBSD. Fix this by adding `&& !SANITIZER_FREEBSD` in a few places, and stop intercepting utmp functions altogether for FreeBSD. Reviewers: kubabrecka, emaste, eugenis, ed Subscribers: ed, llvm-commits Differential Revision: https://reviews.llvm.org/D27902 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290167 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-15Ifdef out utmp.h on Darwin to un-break the build after r289878 ([msan] ↵Kuba Mracek
Intercept getutent and friends). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@289881 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-09-15[compiler-rt] Do not introduce __sanitizer namespace globallyAnna Zaks
The definitions in sanitizer_common may conflict with definitions from system headers because: The runtime includes the system headers after the project headers (as per LLVM coding guidelines). lib/sanitizer_common/sanitizer_internal_defs.h pollutes the namespace of everything defined after it, which is all/most of the sanitizer .h and .cc files and the included system headers with: using namespace __sanitizer; // NOLINT This patch solves the problem by introducing the namespace only within the sanitizer namespaces as proposed by Dmitry. Differential Revision: https://reviews.llvm.org/D21947 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281657 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26[sanitizer] [SystemZ] Add ptrace support bits.Marcin Koscielnicki
Differential Revision: http://reviews.llvm.org/D19134 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267548 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14[sanitizer] [SystemZ] Add/fix kernel and libc type definitions.Marcin Koscielnicki
This is the first part of upcoming asan support for s390 and s390x. Note that there are bits for 31-bit support in this and subsequent patches - while LLVM itself doesn't support it, gcc should be able to make use of it just fine. Differential Revision: http://reviews.llvm.org/D18888 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266370 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-16[ASAN] Add support for mips/mips64 androidMohit K. Bhakkad
Patch by Duane Sand Reviewers: samsonov Subscribers: duanesand, jaydeep, sagar, llvm-commits, filcab. Differential Revision: http://reviews.llvm.org/D17883 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@263621 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-30[asan] Old Linux kernels (< 3.0) don't define ARM_VFPREGS_SIZE that leads toYury Gribov
build errors on ARM. Define it internally to avoid such errors. Patch by Max Ostapenko. Differential Revision: http://reviews.llvm.org/D14921 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254292 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-11Fix #if tests for PTRACE_GETREGS and others.Jay Foad
Summary: On PowerPC64 Linux PTRACE_GETREGS is a #define and PT_GETREGS is not. On other systems it's the other way round. Extend the #ifs to check for both PTRACE_* and PT_*. This fixes test/sanitizer_common/TestCases/Linux/ptrace.cc when msan is enabled for PowerPC64. Reviewers: zatrazz, kcc, eugenis, samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D14564 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252730 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-26[compiler-rt] Enable ptrace sanitizer for armAdhemerval Zanella
This patch enables the ptrace syscall interceptors for arm and adds support for both PTRACE_GETVFPREGS and PTRACE_SETVFPREGS used to get the VFP register from ARM. The ptrace tests is also updated with arm and PTRACE_GETVFPREGS tests. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251321 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-12[asan] Zero initialize sem_t in sem_init.Evgeniy Stepanov
Old version of sem_init (GLIBC_2.0) fails to initialize parts of sem_t that are used in sem_timedwait. This is fixed in GLIBC_2.1, but since ASan interceptors downgrade sem_* to the oldest available version, this can introduce bugs that are only present in sanitized build. Workaround by zero-initializing sem_t in sem_init. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@250113 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-30[sanitizer_common] Apply modernize-use-nullptr, other minor fixesVedant Kumar
- Trim spaces. - Use nullptr in place of 0 for pointer variables. - Use '!p' in place of 'p == 0' for null pointer checks. Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13310 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@248964 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-16[MSan] Enable MSAN for aarch64Adhemerval Zanella
This patch enabled msan for aarch64 with 39-bit VMA and 42-bit VMA. As defined by lib/msan/msan.h the memory layout used is for 39-bit is: 00 0000 0000 - 40 0000 0000: invalid 40 0000 0000 - 43 0000 0000: shadow 43 0000 0000 - 46 0000 0000: origin 46 0000 0000 - 55 0000 0000: invalid 55 0000 0000 - 56 0000 0000: app (low) 56 0000 0000 - 70 0000 0000: invalid 70 0000 0000 - 80 0000 0000: app (high) And for 42-bit VMA: 000 0000 0000 - 100 0000 0000: invalid 100 0000 0000 - 11b 0000 0000: shadow 11b 0000 0000 - 120 0000 0000: invalid 120 0000 0000 - 13b 0000 0000: origin 13b 0000 0000 - 2aa 0000 0000: invalid 2aa 0000 0000 - 2ab 0000 0000: app (low) 2ab 0000 0000 - 3f0 0000 0000: invalid 3f0 0000 0000 - 400 0000 0000: app (high) Most of tests are passing with exception of: * Linux/mallinfo.cc * chained_origin_limits.cc * dlerror.cc * param_tls_limit.cc * signal_stress_test.cc * nonnull-arg.cpp The 'Linux/mallinfo.cc' is due the fact AArch64 returns the sret in 'x8' instead of default first argument 'x1'. So a function prototype that aims to mimic (by using first argument as the return of function) won't work. For GCC one can make a register alias (register var asm ("r8")), but for clang it detects is an unused variable and generate wrong code. The 'chained_origin_limits' is probably due a wrong code generation, since it fails only when origin memory is used (-fsanitize-memory-track-origins=2) and only in the returned code (return buf[50]). The 'signal_streess_test' and 'nonnull-arg' are due currently missing variadic argument handling in memory sanitizer code instrumentation on LLVM side. Both 'dlerror' and 'param_tls_test' are unknown failures that require further investigation. All the failures are XFAIL for aarch64 for now. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@247809 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-10Unbreak building on FreeBSD.Roman Divacky
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@247347 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-08[msan] Unpoison dlpi_phdr in dl_iterate_phdr.Evgeniy Stepanov
In some cases, PHDR table is allocated with malloc() by the linker instead of being mapped from file. It needs to be unpoisoned in the dl_iterate_phdr callback then. This happens when program headers are not part of any loadable ELF segment. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@247100 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-25[msan] Teach sanitizers about the PPC64 ptrace syscallJay Foad
Summary: This fixes test/msan/Linux/syscalls.cc, and should also fix the ppc64 sanitizer buildbots which are currently failing in "make check-sanitizer". Reviewers: samsonov, wschmidt, eugenis Reviewed By: eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D10734 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@240692 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-23Working on reconciling out-of-tree patches to compiler-rt for building for iOS.Chris Bieneman
Summary: This is one of many changes needed for compiler-rt to get it building on iOS. This change ifdefs out headers and functionality that aren't available on iOS. Note: this change does not enable building for iOS, as there are more changes to come. Reviewers: glider, kubabrecka, bogner, samsonov Reviewed By: samsonov Subscribers: samsonov, llvm-commits Differential Revision: http://reviews.llvm.org/D10514 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@240468 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-19[msan] Intercept fopencookie.Evgeniy Stepanov
https://code.google.com/p/memory-sanitizer/issues/detail?id=86 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@240107 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09[ASan] Only include rpc headers if they are available.Yury Gribov
Reviewed at http://reviews.llvm.org/D8698 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234470 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-24Allow sanitizer to work with "old" kernel headersRenato Golin
Sanitizers work on ancient kernels and were depending on types existing. When those types were removed, the sanitizer build broke. See bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59009 for more information. This patch fixes it by isolating the need for those types only when the feature is actually needed, thus allowing one to compile the kernel with or without that change, irrespective of its version. Patch by Christophe Lyon. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@230324 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-18[MSan][MIPS] Fix for some failing tests on MIPS64Mohit K. Bhakkad
Enabling internal ptrace for mips, which fixes some ptrace related tests. Along with this fixing some other failures. Reviewers: Reviewers: eugenis, kcc, samsonov Subscribers: dsanders, sagar, lldb-commits Differential Revision: http://reviews.llvm.org/D7332 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@229656 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-17Remove inclusion of netinet/ip_compat.h for FreeBSD. This header is notDimitry Andric
always available, and nothing in sanitizer_platform_limits_posix.cc uses any of its definitions. See also: https://svnweb.freebsd.org/changeset/base/277201 Reviewers: kcc, kutuzov.viktor.84, samsonov Reviewed By: samsonov Differential Revision: http://reviews.llvm.org/D7486 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@229518 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-21[sanitizer] Fix aarch64 sanitizer build with recent glibcKostya Serebryany
glibc recently changed ABI on aarch64-linux: https://sourceware.org/git/?p=glibc.git;a=commit;h=5c40c3bab2fddaca8cfe12d75944d1fef8adf1a4 Instead of having unsigned short mode; unsigned short __pad1; it now has unsigned int mode; field in ipc_perm structure. This patch allows to build against the recent glibc and disables the ipc_perm.mode verification for older versions of glibc. I think it shouldn't be a big deal even for older glibcs, I couldn't find any place which would actually care about the exact mode field, rather than the whole structure, appart from the CHECK_SIZE_AND_OFFSET macro. Patch by Jakub Jelinek git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226637 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-10[sanitizer] Disable compile-time checks for __kernel_old_uid_t size on aarch64.Evgeniy Stepanov
Should fix PR21476. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@223925 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-21[sanitizer] Fix build with _FILE_OFFSET_BITS=64.Evgeniy Stepanov
Sanitizer source is not affected by _FILE_OFFSET_BITS in general, but this one file must be built with 32-bit off_t. More details in the code. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@220328 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-14Fix compiler-rt build on FreeBSD 10.1Ed Maste
We have to #define _WANT_RTENTRY to get struct rtentry, and add headers that it depends on. SIOCADDRT and SIOCDELRT also do not exist in FreeBSD 10.1 and were removed in FreeBSD rev. 263203: Garbage collect long time obsoleted (or never used) stuff from routing API. Differential Revision: http://reviews.llvm.org/D5703 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@219722 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-16[sanitizer] Fix global constructor warning in sanitizer; patch by Samuel F ↵Kostya Serebryany
Antao git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@217904 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-03[asan] i686-linux-android support.Evgeniy Stepanov
Large part of this change is required due to https://code.google.com/p/android/issues/detail?id=61799 dlsym() crashes when symbol resolution fails, which means we have to limit the interceptor list instead of relying on runtime detection. There are minor differencies in system headers, too. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@212273 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-19[sanitizer] Intercept pthread_*attr_get*.Evgeniy Stepanov
This is a resubmit of r211166 reverted due to osx breakage. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@211264 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-18Revert "[sanitizer] Intercept pthread_*attr_get*."Arnold Schwaighofer
This reverts commit r211166. It broke public mac os x bots. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@211206 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-18[sanitizer] Intercept pthread_*attr_get*.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@211166 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-16[sanitizer] Support PTRACE_GETEVENTMSG in the ptrace() interceptor.Sergey Matveev
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@211022 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-05Remove's uses of sys/timeb.h for Android.Dan Albert
Android is removing sys/timeb.h because it was removed in POSIX 2008. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@210235 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-15[sanitizer] Remove the definition of xdr_ops.Evgeniy Stepanov
User-visible instances of xdr_ops always seem to be allocated statically, and don't need unpoisoning. Also, it's size differs between platforms. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208851 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-08Fixup for r208066. Properly get values of PTRACE_GETREGSET/PTRACE_SETREGSET.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208363 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-07[sanitizer] Intercept obstack.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208196 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-06[sanitizer] fix build with glibc 2.4, patch by Sandra LoosemoreKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208066 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-25[sanitizer] Intercept a bunch of stdio calls.Evgeniy Stepanov
Add move fopen/freopen interceptors from TSan to common. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@207224 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-04[sanitizer] Intercept a subset of sunrpc interface (xdr_*).Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@205627 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-28[sanitizer] Intercept fgetpwent / fgetgrent.Evgeniy Stepanov
These interceptors require deep unpoisoning of return values. While at it, we do the same for all other pw/gr interceptors to reduce dependency on libc implementation details. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@205004 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-28[sanitizer] Intercept ftime.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204991 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-27[msan] Intercept several malloc-related functions.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204923 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-27[sanitizer] Fix iOS build.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@202374 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-27[sanitizer] Sizes and layouts for sanitizers on FreeBSD.Evgeniy Stepanov
Patch by Viktor Kutuzov. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@202364 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-19[asan] A different way of detectinb stack overflow.Evgeniy Stepanov
Instead of checking stack limits that are not well defined for the main thread, we rely on siginfo::si_code and distance from SP. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@201673 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-10[msan] Return EINVAL instead of crashing from mmap of an invalid address.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@201074 91177308-0d34-0410-b5e6-96231b3b80d8