summaryrefslogtreecommitdiff
path: root/lib/ubsan/ubsan_handlers.h
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
2017-07-29[ubsan] Diagnose invalid uses of builtins (compiler-rt)Vedant Kumar
Differential Revision: https://reviews.llvm.org/D34591 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@309461 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-23[ubsan] Improve diagnostics for return value checks (compiler-rt)Vedant Kumar
Differential Revision: https://reviews.llvm.org/D34298 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@306164 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-01[ubsan] Runtime support for pointer overflow checkingVedant Kumar
Patch by John Regehr and Will Dietz! Differential Revision: https://reviews.llvm.org/D20323 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304461 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-14[ubsan] Add diagnostic handlers for nullability errorsVedant Kumar
Add 'nullability_arg' and 'nullability_return' diagnostic handlers, and also add a TypeCheckKind for null assignments to _Nonnull. With this in place, we can update clang to use the nicer handlers for nullability diagnostics. The alternative to this approach is to update the existing 'nonnull_arg' and 'nonnull_return' handlers to accept a boolean parameter. However, versioning the existing handlers would cause code size bloat, and the complexity cost of introducing new handlers into the runtime is low. I will add tests for this, and all of -fsanitize=nullability, into check-ubsan once the clang side of the changes is in. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@297748 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-06[ubsan] Minimize size of data for type_mismatch (Redo of D19668)Filipe Cabecinhas
Summary: This is the compiler-rt side of D28242. Reviewers: kcc, vitalybuka, pgousseau, gbedwell Subscribers: kubabrecka, llvm-commits Differential Revision: https://reviews.llvm.org/D28244 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@291237 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-09-10CFI: Add diagnostic handler and tests for indirect call checker.Peter Collingbourne
Differential Revision: http://reviews.llvm.org/D11858 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@247239 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-11[compiler-rt] Add SourceLocations for float_cast_overflow data.Filipe Cabecinhas
Summary: Compiler-rt part of http://reviews.llvm.org/D11757 I ended up making UBSan work with both the old version and the new version of the float_cast_overflow data (instead of just erroring with the previous version). The old version will try to symbolize its caller. Now we compile the float_cast_overflow tests without -g, and make sure we have the source file+line+column. If you think I'm trying too hard to make sure we can still use both versions, let me know. Reviewers: samsonov, rsmith Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D11793 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@244567 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-10[UBSan] Add noinline attribute to handlers that should never return.Alexey Samsonov
FIx a problem reported by Jakub Jelinek: don't do early-exit from fatal UBSan handlers: even if source location is disabled (i.e. acquired by some other thread), we should continue the execution to make sure that: a) some thread will print the error report before calling Die(). b) handler marked as noreturn will indeed not return. Explicitly add "Die()" calls at the end of all fatal handlers to be sure UBSan handlers don't introduce UB themselves. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@217542 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-08Remove extra semicolon [-Wpedantic]Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@217407 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-08Report source location of returns_nonnull attribute in UBSan reports.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@217400 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-08Implement nonnull-attribute sanitizerAlexey Samsonov
Summary: This patch implements a new UBSan check, which verifies that function arguments declared to be nonnull with __attribute__((nonnull)) are actually nonnull in runtime. To implement this check, we pass FunctionDecl to CodeGenFunction::EmitCallArgs (where applicable) and if function declaration has nonnull attribute specified for a certain formal parameter, we compare the corresponding RValue to null as soon as it's calculated. Test Plan: regression test suite Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits, rnk Differential Revision: http://reviews.llvm.org/D5082 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@217389 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-13[UBSan] Add returns-nonnull sanitizer.Alexey Samsonov
Summary: This patch adds a runtime check verifying that functions annotated with "returns_nonnull" attribute do in fact return nonnull pointers. It is based on suggestion by Jakub Jelinek: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140623/223693.html. Test Plan: regression test suite Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4849 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@215485 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-20Runtime support for the indirect function call checker.Peter Collingbourne
Differential Revision: http://llvm-reviews.chandlerc.com/D1339 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@193060 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-02Make the InvalidValueData take a SourceLocation.Nick Lewycky
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@191807 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-23ubsan: Runtime handlers for array indexing checks.Richard Smith
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@175948 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-10[ubsan] Move attribute specifier to fix build with gcc.Will Dietz
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@172078 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-10[ubsan] Give entry methods default (not hidden) visibility.Will Dietz
Fixes using ubsan on shared libraries in linux, for example. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@172041 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-13ubsan: Add -fsanitize=bool and -fsanitize=enum, which check for loads ofRichard Smith
bit-patterns which are not valid values for enumerated or boolean types. These checks are the ubsan analogue of !range metadata. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@170107 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-11-27ubsan: Support unsigned overflows, and divide-by-zero int/float split.Will Dietz
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@168700 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-12-fcatch-undefined-behavior: Runtime library support for trapping conversions ↵Richard Smith
to or from a floating-point type where the source value is not in the range of representable values of the destination type. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@165844 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-10-fcatch-undefined-behavior: handler for VLA bound which evaluates to a ↵Richard Smith
non-positive value. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@165582 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-09Add a runtime diagnostics library for Clang's -fcatch-undefined-behavior.Richard Smith
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@165533 91177308-0d34-0410-b5e6-96231b3b80d8