summaryrefslogtreecommitdiff
path: root/lib/ubsan/ubsan_handlers_cxx.cc
AgeCommit message (Collapse)Author
2017-09-15ubsan: Unbreak ubsan_cxx runtime library on Windows.Peter Collingbourne
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313391 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02UBSan: crash less often on corrupted Vtables.Ivan Krasin
Summary: This CL adds a weak check for a Vtable prefix: for a well-formed Vtable, we require the prefix to be within [-1<<20; 1<<20]. Practically, this solves most of the known cases when UBSan segfaults without providing any useful diagnostics. Reviewers: pcc Subscribers: kubabrecka Differential Revision: http://reviews.llvm.org/D19750 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@271560 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-03[cfi] Safe handling of unaddressable vtable pointers (compiler-rt).Evgeniy Stepanov
Avoid crashing when printing diagnostics for vtable-related CFI errors. In diagnostic mode, the frontend does an additional check of the vtable pointer against the set of all known vtable addresses and lets the runtime handler know if it is safe to inspect the vtable. http://reviews.llvm.org/D16824 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@259717 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-25[cfi] Cross-DSO CFI diagnostic mode (compiler-rt part)Evgeniy Stepanov
* add __cfi_slowpath_diag with a 3rd parameter which is a pointer to the diagnostic info for the ubsan handlers. *__cfi_check gets a 3rd parameter as well. * unify vcall/cast/etc and icall diagnostic info format, and merge the handlers to have a single entry point (actually two points due to abort/noabort variants). * tests Note that this comes with a tiny overhead in the non-diag mode: cfi_slowpath must pass 0 as the 3rd argument to cfi_check. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@258744 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-18[UBSan] Implement runtime suppressions (PR25066).Alexey Samsonov
Summary: Add the ability to suppress UBSan reports for files/functions/modules at runtime. The user can now pass UBSAN_OPTIONS=suppressions=supp.txt with the contents of the form: signed-integer-overflow:file-with-known-overflow.cpp alignment:function_doing_unaligned_access vptr:shared_object_with_vptr_failures.so Suppression categories match the arguments passed to -fsanitize= flag (although, see below). There is no overhead if suppressions are not provided. Otherwise there is extra overhead for symbolization. Limitations: 1) sometimes suppressions need debug info / symbol table to function properly (although sometimes frontend generates enough info to do the match). 2) it's only possible to suppress recoverable UB kinds - if you've built the code with -fno-sanitize-recover=undefined, suppressions will not work. 3) categories are fine-grained check kinds, not groups like "undefined" or "integer", so you can't write "undefined:file_with_ub.cc". Reviewers: rsmith, kcc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D15363 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@256018 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-09[UBSan] Clarify the way we disable de-duplication of reports from ↵Alexey Samsonov
unrecoverable handlers. Let unrecoverable handlers be responsbile for killing the program with Die(), and let functions which print the error report know if it's going to happen. Re-write the comments to describe the situation. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@255081 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-24[UBSan] Add the ability to print more precise error kind in summary line.Alexey Samsonov
Reviewers: rsmith, pcc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D12215 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245897 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-08CFI: Get check-cfi passing on Windows.Peter Collingbourne
Specifically: - Start using %expect_crash. - Provide an implementation of __ubsan::getDynamicTypeInfoFromVtable for the Microsoft C++ ABI. This is all that is needed for CFI diagnostics; UBSan's -fsanitize=vptr also requires an implementation of __ubsan::checkDynamicType. - Build the sanitizer runtimes against the release version of the C runtime, even in debug builds. - Accommodate demangling differences in tests. Differential Revision: http://reviews.llvm.org/D11029 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@241745 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-19Add control flow integrity diagnosis function to UBSan runtime library.Peter Collingbourne
Also includes execution tests for the feature. Differential Revision: http://reviews.llvm.org/D10269 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@240111 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-26[UBSan] Explicitly list all supported OS/arch pairs supported by UBSan.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@233295 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-20[Sanitizer] Refactor SuppressionContext class.Alexey Samsonov
SuppressionContext is no longer a singleton, shared by all sanitizers, but a regular class. Each of ASan, LSan, UBSan and TSan now have their own SuppressionContext, which only parses suppressions specific to that sanitizer. "suppressions" flag is moved away from common flags into tool-specific flags, so the user now may pass ASAN_OPTIONS=suppressions=asan_supp.txt LSAN_OPIONS=suppressions=lsan_supp.txt in a single invocation. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@230026 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-19[UBSan] Optionally report summary in UBSan error reports.Alexey Samsonov
By default summary is not printed if UBSan is run in a standalone mode, but is printed if it's combined with another sanitizer (like ASan). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@218135 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-22[UBSan] Add support for printing backtraces to all UBSan handlersAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@216289 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-05[UBSan] Allow to suppress reports from vptr checker for specified types.Alexey Samsonov
Based on http://reviews.llvm.org/D4702 by Byoungyoung Lee! git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214833 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-30[UBSan] Introduce ScopedReport object.Alexey Samsonov
This object is used to encapsulate all actions that need to be done before/after printing UBSan diagnostics. Currently these actions are: * locking a mutex to ensure that UBSan diagnostics from several threads won't mix with each other and with other sanitizers' reports * killing a program once the report is printed (if necessary). Use this object in all UBSan handlers. Unify the way we implement fatal and non-fatal handlers by making all the handlers simple one-liners that redirect __ubsan_handle_foo(_abort)? to handleFooImpl(). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214279 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-29[UBSan] Get pc/bp for stack unwinding as early as possible.Alexey Samsonov
This will ensure that stack frames in error reports will not contain internal UBSan failures, and frame #0 will be the actual place in the program where the error happens. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214245 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-23[UBSan] Add the ability to dump call stacks to -fsanitize=vptrAlexey Samsonov
This change introduces the first UBSan-specific runtime flag: print_stacktrace (off by default). It can be set in UBSAN_OPTIONS to unwind and print call stacks in addition to diagnostic messages. For now these stacks are printed only in vptr checker. This change is based on http://reviews.llvm.org/D4410 by Byoungyoung Lee! git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@213783 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-13ubsan: Add checking for invalid downcasts. Per [expr.static.cast]p2 and p11,Richard Smith
base-to-derived casts have undefined behavior if the object is not actually an instance of the derived type. Runtime library part. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@175079 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-09[ubsan] Add deduplication functionality, always enabled.Will Dietz
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@171948 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-18ubsan: Demangle class names, and be more informative when a reinterpret_castRichard Smith
has got us to the wrong offset within an object. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@170423 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-18ubsan: When diagnosing something wrong somewhere in memory, emit a noteRichard Smith
pointing at the bad location and a snippet of nearby memory values. This is strictly best-effort; reading these bytes to display the note could lead to a seg fault, and that's explicitly OK. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@170415 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-02[ubsan] Refactor handlers to have separate entry points for aborting.Will Dietz
If user specifies aborting after a recoverable failed check is appropriate, frontend should emit call to the _abort variant. Test this behavior with newly added -fsanitize-recover flag. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@169113 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-02[ubsan] Replace "fatal error" with "runtime error".Will Dietz
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@169112 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-25-fcatch-undefined-behavior checking for appropriate vptr value: library side.Richard Smith
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@166660 91177308-0d34-0410-b5e6-96231b3b80d8