summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/ubsan
Commit message (Collapse)AuthorAgeFilesLines
...
* OpenBSD UBsan support / ubsan partKamil Rytarowski2018-03-021-1/+2
| | | | | | | | | | | | | | | | Summary: UBsan, enable OpenBSD platform Patch by: David CARLIER Reviewers: krytarowski, kettenis, visa, vitalybuka Reviewed By: vitalybuka Subscribers: kubamracek, fedor.sergeev, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D43894 llvm-svn: 326543
* Recognize all NetBSD architectures in UBSanKamil Rytarowski2018-02-171-7/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Use uniform accessors for Program Pointer, Stack Pointer and Frame Pointer. Remove CPU check in UBSan supported platforms and rely only on the OS type. This adds NetBSD support in GetPcSpBp() for: - ARM - ARM64 - HPPA - PowerPC/PowerPC64 - SPARC/SPARC64 - MIPS - DEC Alpha AXP - DEC VAX - M68K and M68010 - SH3 - IA64 - OR1K - RISCV Sponsored by <The NetBSD Foundation> Reviewers: joerg, vitalybuka, ro Reviewed By: vitalybuka Subscribers: aemerson, jyknight, sdardis, kubamracek, arichardson, llvm-commits, kristof.beyls, fedor.sergeev, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D43021 llvm-svn: 325431
* [ubsan] Add preinit initializer for ubsanFrancis Ricci2018-01-233-2/+48
| | | | | | | | | | | | | | | | | | | | Summary: Now that ubsan does function interception (for signals), we need to ensure that ubsan is initialized before any library constructors are called. Otherwise, if a constructor calls sigaction, ubsan will intercept in an unitialized state, which will cause a crash. This patch is a partial revert of r317757, which removed preinit arrays for ubsan. Reviewers: vitalybuka, eugenis, pcc Subscribers: kubamracek, mgorny, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D42389 llvm-svn: 323249
* [ubsan] Disable signal handling on Android.Evgeniy Stepanov2018-01-221-4/+19
| | | | | | | | | | | | Summary: See rationale in the comments. Reviewers: vitalybuka Subscribers: srhines, llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D42329 llvm-svn: 323142
* -fsanitize=vptr warnings on bad static types in dynamic_cast and typeidStephan Bergmann2017-12-281-1/+2
| | | | | | | | | | | | | | | | ...when such an operation is done on an object during con-/destruction. (This adds a test case to compiler-rt/test/ubsan/TestCases/TypeCheck/vptr.cpp that, unlike the existing test cases there, wants to detect multiple UBSan warnings in one go. Therefore, that file had to be changed from globally using -fno-sanitize-recover to individually using halt_on_error only where appropriate.) This is the compiler-rt part of a patch covering both cfe and compiler-rt. Differential Revision: https://reviews.llvm.org/D40295 llvm-svn: 321518
* [ubsan] Diagnose noreturn functions which return (compiler-rt)Vedant Kumar2017-12-211-1/+1
| | | | | | | | This is paired with the clang change: https://reviews.llvm.org/D40698 Differential Revision: https://reviews.llvm.org/D40700 llvm-svn: 321232
* Revert r320977 "No -fsanitize=function warning when calling noexcept ↵Stephan Bergmann2017-12-182-50/+9
| | | | | | | | | | | | | function through non-noexcept pointer in C++17" At least <http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/ builds/6013/steps/annotate/logs/stdio> complains about __ubsan::__ubsan_handle_function_type_mismatch_abort (compiler-rt lib/ubsan/ubsan_handlers.cc) returning now despite being declared 'noreturn', so looks like a different approach is needed for the function_type_mismatch check to be called also in cases that may ultimately succeed. llvm-svn: 320981
* No -fsanitize=function warning when calling noexcept function through ↵Stephan Bergmann2017-12-182-9/+50
| | | | | | | | | | | | | | | | | | | | | | | non-noexcept pointer in C++17 As discussed in the mail thread <https://groups.google.com/a/isocpp.org/forum/ #!topic/std-discussion/T64_dW3WKUk> "Calling noexcept function throug non- noexcept pointer is undefined behavior?", such a call should not be UB. However, Clang currently warns about it. There is no cheap check whether two function type_infos only differ in noexcept,so pass those two type_infos as additional data to the function_type_mismatch handler (with the optimization of passing a null "static callee type" info when that is already noexcept, so the additional check can be avoided anyway). For the Itanium ABI (which appears to be the only one that happens to be used on platforms that support -fsanitize=function, and which appears to only record noexcept information for pointer-to-function type_infos, not for function type_infos themselves), we then need to check the mangled names for occurrence of "Do" representing "noexcept". This is the compiler-rt part of a patch covering both cfe and compiler-rt. Differential Revision: https://reviews.llvm.org/D40720 llvm-svn: 320977
* [Sanitizers] Basic sanitizer Solaris support (PR 33274)Kamil Rytarowski2017-12-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 320740
* [sanitizers] Rename GetStackTraceWithPcBpAndContextVitaly Buka2017-11-093-11/+8
| | | | | | Name does not need to enumerate arguments. llvm-svn: 317774
* ubsan: Allow programs to use setenv to configure ubsan_standalone.Peter Collingbourne2017-11-093-40/+4
| | | | | | | | | | | | | | | | | | | | | | Previously ubsan_standalone used the GetEnv function to read the environment variables UBSAN_OPTIONS and UBSAN_SYMBOLIZER_PATH. The problem with GetEnv is that it does not respect changes to the environment variables made using the libc setenv function, which prevents clients from setting environment variables to configure ubsan before loading ubsan-instrumented libraries. The reason why we have GetEnv is that some runtimes need to read environment variables while they initialize using .preinit_array, and getenv does not work while .preinit_array functions are being called. However, it is unnecessary for ubsan_standalone to initialize that early. So this change switches ubsan_standalone to using getenv and removes the .preinit_array entry. The static version of the runtime still ends up being initialized using a C++ constructor that exists to support the shared runtime. Differential Revision: https://reviews.llvm.org/D39827 llvm-svn: 317757
* [sanitizer] Don't intercept signal and sigaction on FuchsiaPetr Hosek2017-10-091-0/+4
| | | | | | | | | Fuchsia doesn't support signals, so don't use interceptors for signal or sigaction. Differential Revision: https://reviews.llvm.org/D38669 llvm-svn: 315227
* [ubsan] Add a static runtime on DarwinVedant Kumar2017-10-071-0/+12
| | | | | | | | As a follow-up to r315142, this makes it possible to use ubsan with a static runtime on Darwin. I've also added a new StandaloneStatic testing configuration so the new setup can be tested. llvm-svn: 315143
* [sanitizer] Move cxx-abi library earlier in link flags.Evgeniy Stepanov2017-10-041-3/+1
| | | | | | | | | | | | | | | | | | | | Summary: This change moves cxx-abi library in asan/ubsan/dd link command line ahead of other libraries, such as pthread/rt/dl/c/gcc. Given that cxx-abi may be the full libstdc++/libc++, it makes sense for it to be ahead of libc and libgcc, at least. The real motivation is Android, where in the arm32 NDK toolchain libstdc++.a is actually a linker script that tries to sneak LLVM's libunwind ahead of libgcc's. Wrong library order breaks unwinding. Reviewers: srhines, danalbert Subscribers: aemerson, kubamracek, mgorny, kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D38520 llvm-svn: 314948
* [ubsan] Merge ubsan_standalone_cxx shared library.Evgeniy Stepanov2017-09-281-12/+1
| | | | | | | | | | | | | | Summary: Link everything, including the C++ bits, in the single ubsan_standalone SHARED library. This matches ASan setup. Reviewers: vitalybuka Subscribers: kubamracek, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D38340 llvm-svn: 314369
* [ubsan] Replace CommonSanitizerReportMutex with ScopedErrorReportLockVitaly Buka2017-09-232-6/+12
| | | | | | | | | | Reviewers: eugenis, alekseyshl Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D38194 llvm-svn: 314053
* [ubsan] Support signal specific options in ubsanVitaly Buka2017-09-235-2/+98
| | | | | | | | | | | | | | | | Summary: Part of https://github.com/google/sanitizers/issues/637 Standalone ubsan needs signal and sigaction handlers and interceptors. Plugin mode should rely on parent tool. Reviewers: eugenis, alekseyshl Subscribers: kubamracek, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D37895 llvm-svn: 314052
* [ubsan] Split ubsan_init_standaloneVitaly Buka2017-09-214-38/+41
| | | | | | | | | | | | | | Summary: On Linux we may need preinit_array in static lib and ubsan_standalone_initializer in shared lib. Reviewers: eugenis Subscribers: kubamracek, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D38013 llvm-svn: 313851
* Revert "[ubsan] Split ubsan_init_standalone"Vitaly Buka2017-09-183-38/+10
| | | | | | | | Breaks build. This reverts commit r313583 and r313584. llvm-svn: 313585
* [ubsan] Add file missing from r313583Vitaly Buka2017-09-181-0/+26
| | | | llvm-svn: 313584
* [ubsan] Split ubsan_init_standaloneVitaly Buka2017-09-182-10/+12
| | | | | | | On Linux we may need preinit_array in static lib and ubsan_standalone_initializer in shared lib. llvm-svn: 313583
* [ubsan] Fix conflict with previous declaration on MacVitaly Buka2017-09-181-3/+2
| | | | llvm-svn: 313572
* [ubsan] Fix interface_symbols_windows testVitaly Buka2017-09-181-0/+2
| | | | | | | | | | | | | | | Summary: 1. Update ubsan_interface.inc to make the test happy. 2. Switch interface_symbols_linux and interface_symbols_darwin to C++ to import __ubsan_handle_dynamic_type_cache_miss 3. Switch interface_symbols_windows to C++ for consistency. Reviewers: rnk, zturner Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D37986 llvm-svn: 313551
* Revert "[ubsan] Add RTUbsan_standalone into UBSAN standalone shared"Vitaly Buka2017-09-181-1/+0
| | | | | | | | Error: .preinit_array section is not allowed in DSO This reverts commit r313519. llvm-svn: 313520
* [ubsan] Add RTUbsan_standalone into UBSAN standalone sharedVitaly Buka2017-09-181-0/+1
| | | | | | | | Same as for Apple. This also fixes flags related tests on Android as without this flags are not initialized. llvm-svn: 313519
* Revert "[ubsan] Update ubsan_interface.inc"Vitaly Buka2017-09-161-2/+0
| | | | | | | | This brakes interface_symbols_linux.c test. This reverts commit r313432. llvm-svn: 313439
* [ubsan] Update ubsan_interface.incVitaly Buka2017-09-161-0/+2
| | | | llvm-svn: 313432
* Try to fix check-asan.Peter Collingbourne2017-09-151-0/+1
| | | | llvm-svn: 313423
* ubsan: Unbreak ubsan_cxx runtime library on Windows.Peter Collingbourne2017-09-153-8/+32
| | | | | | | | | | | | | | | | This was originally broken by r258744 which introduced a weak reference from ubsan to ubsan_cxx. This reference does not work directly on Windows because COFF has no direct concept of weak symbols. The fix is to use /alternatename to create a weak external reference to ubsan_cxx. Also fix the definition (and the name, so that we drop cached values) of the cmake flag that controls whether to build ubsan_cxx. Now the user-controllable flag is always on, and we turn it off internally depending on whether we support building it. Differential Revision: https://reviews.llvm.org/D37882 llvm-svn: 313391
* ubsan: Stop building the DLL version of the runtime library on Windows.Peter Collingbourne2017-09-151-23/+23
| | | | | | | | As far as I know we never use it. Differential Revision: https://reviews.llvm.org/D37884 llvm-svn: 313378
* [ubsan] Extract GetStackTraceWithPcBpAndContext similar to asan versionVitaly Buka2017-09-152-8/+16
| | | | llvm-svn: 313350
* [ubsan] Make ubsan version of __sanitizer_print_stack_trace consistent with ↵Vitaly Buka2017-09-111-2/+3
| | | | | | | | | | | | | | other sanitizers Summary: Other sanitizers include __sanitizer_print_stack_trace into stack trace. Reviewers: eugenis, alekseyshl Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D37657 llvm-svn: 312954
* [ubsan] Save binary name before parsing optionsVitaly Buka2017-09-111-1/+1
| | | | | | | | | | | | Summary: To parser "include" we may need to do binary name substitution. Reviewers: eugenis, alekseyshl Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D37658 llvm-svn: 312953
* Revert "[ubsan] Save binary name before parsing options"Vitaly Buka2017-09-111-1/+1
| | | | | | | | Patch was corrupted by rebase. This reverts commit r312933 llvm-svn: 312952
* [compiler-rt] Cleanup decoratorsVitaly Buka2017-09-111-5/+3
| | | | | | | | | | | | | | Summary: Removed redundant End*() methods which defined same way. Removed redundant Warning() methods. Reviewers: eugenis Subscribers: kubamracek, llvm-commits, dberris Differential Revision: https://reviews.llvm.org/D37549 llvm-svn: 312950
* [ubsan] Save binary name before parsing optionsVitaly Buka2017-09-111-1/+1
| | | | | | | | | | | | Summary: To parser "include" we may need to do binary name substitution. Reviewers: eugenis, alekseyshl Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D37658 llvm-svn: 312933
* Reland r311842 - [cmake] Remove i686 target that is duplicate to i386Michal Gorny2017-08-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Remove the explicit i686 target that is completely duplicate to the i386 target, with the latter being used more commonly. 1. The runtime built for i686 will be identical to the one built for i386. 2. Supporting both -i386 and -i686 suffixes causes unnecessary confusion on the clang end which has to expect either of them. 3. The checks are based on wrong assumption that __i686__ is defined for all newer x86 CPUs. In fact, it is only declared when -march=i686 is explicitly used. It is not available when a more specific (or newer) -march is used. Curious enough, if CFLAGS contain -march=i686, the runtime will be built both for i386 and i686. For any other value, only i386 variant will be built. Differential Revision: https://reviews.llvm.org/D26764 llvm-svn: 311924
* Revert r311842 - [cmake] Remove i686 target that is duplicate to i386Michal Gorny2017-08-271-1/+1
| | | | | | | The required change in clang is being reverted because of the Android build bot failure. llvm-svn: 311859
* [cmake] Remove i686 target that is duplicate to i386Michal Gorny2017-08-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Remove the explicit i686 target that is completely duplicate to the i386 target, with the latter being used more commonly. 1. The runtime built for i686 will be identical to the one built for i386. 2. Supporting both -i386 and -i686 suffixes causes unnecessary confusion on the clang end which has to expect either of them. 3. The checks are based on wrong assumption that __i686__ is defined for all newer x86 CPUs. In fact, it is only declared when -march=i686 is explicitly used. It is not available when a more specific (or newer) -march is used. Curious enough, if CFLAGS contain -march=i686, the runtime will be built both for i386 and i686. For any other value, only i386 variant will be built. Differential Revision: https://reviews.llvm.org/D26764 llvm-svn: 311842
* Enable ubsan on NetBSDKamil Rytarowski2017-08-081-3/+4
| | | | | | | | | | | | | | | | | | | Summary: 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, vitalybuka, kcc, filcab, fjricci Reviewed By: fjricci Subscribers: srhines, kubamracek, mgorny, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36483 llvm-svn: 310412
* [ubsan] Enable UBSan build for FuchsiaVitaly Buka2017-08-011-1/+1
| | | | | | | | | | | | | | | | Submitted on behalf of Roland McGrath. Reviewers: vitalybuka, alekseyshl, kcc Reviewed By: vitalybuka Subscribers: srhines, kubamracek, mgorny, phosek, filcab, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36033 llvm-svn: 309742
* [ubsan] Diagnose invalid uses of builtins (compiler-rt)Vedant Kumar2017-07-294-0/+42
| | | | | | Differential Revision: https://reviews.llvm.org/D34591 llvm-svn: 309461
* Support libc++abi in addition to libstdc++Petr Hosek2017-07-281-1/+2
| | | | | | | | | | | This change adds sanitizer support for LLVM's libunwind and libc++abi as an alternative to libstdc++. This allows using the in tree version of libunwind and libc++abi which is useful when building a toolchain for different target. Differential Revision: https://reviews.llvm.org/D34501 llvm-svn: 309362
* Support compiler-rt builtinsPetr Hosek2017-07-281-0/+5
| | | | | | | | | This change adds support for compiler-rt builtins as an alternative compiler runtime to libgcc. Differential Revision: https://reviews.llvm.org/D35165 llvm-svn: 309361
* Add liblog to ubsan `UBSAN_DYNAMIC_LIBS`Leo Li2017-07-261-2/+3
| | | | | | | | | | | | Summary: liblog is still required to create ubsan runtimes on Android when __ANDROID_API__ < 21. Reviewers: eugenis, vsk Subscribers: kubamracek, mgorny, pirama, srhines, llvm-commits Differential Revision: https://reviews.llvm.org/D35915 llvm-svn: 309180
* Revert "[sanitizer] Support compiler-rt builtins"Petr Hosek2017-07-261-5/+0
| | | | | | This reverts commit fd63314d6770e0da62572a3fea2c41c4cc0fc58a. llvm-svn: 309083
* Revert "[sanitizer] Support libc++abi in addition to libstdc++"Petr Hosek2017-07-261-2/+1
| | | | | | This reverts commit d1997bff31cf6b484eb59c2ee1fc3155442e338c. llvm-svn: 309082
* [sanitizer] Support libc++abi in addition to libstdc++Petr Hosek2017-07-261-1/+2
| | | | | | | | | | | This change adds sanitizer support for LLVM's libunwind and libc++abi as an alternative to libstdc++. This allows using the in tree version of libunwind and libc++abi which is useful when building a toolchain for different target. Differential Revision: https://reviews.llvm.org/D34501 llvm-svn: 309074
* [sanitizer] Support compiler-rt builtinsPetr Hosek2017-07-251-0/+5
| | | | | | | | | This change adds support for compiler-rt builtins as an alternative compiler runtime to libgcc. Differential Revision: https://reviews.llvm.org/D35165 llvm-svn: 309060
* [ubsan] Teach the pointer overflow check that "p - <unsigned> <= p" ↵Vedant Kumar2017-07-131-5/+10
| | | | | | | | (compiler-rt) Compiler-rt changes associated with: D34121 llvm-svn: 307956
OpenPOWER on IntegriCloud