summaryrefslogtreecommitdiff
path: root/lib/asan/asan_poisoning.cc
AgeCommit message (Collapse)Author
2017-11-13[asan] Remove semicolon after do {} while (0)Tom de Vries
Remove semicolon after "do {} while (0)" in in CHECK_SMALL_REGION git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@318084 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-30Release memory to OS only when the requested range covers the entire pageEvgeniy Stepanov
Summary: The current code was sometimes attempting to release huge chunks of memory due to undesired RoundUp/RoundDown interaction when the requested range is fully contained within one memory page. Reviewers: eugenis Subscribers: kubabrecka, llvm-commits Patch by Aleksey Shlyapnikov. Differential Revision: https://reviews.llvm.org/D27228 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@288271 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-30[asan] Avoid redundant poisoning checks in ↵Maxim Ostapenko
__sanitizer_contiguous_container_find_bad_address. __sanitizer_contiguous_container_find_bad_address computes three regions of a container to check for poisoning: begin, middle, end. The issue is that in current design the first region can be significantly larger than kMaxRangeToCheck. Proposed patch fixes a typo to calculate the first region properly. Patch by Ivan Baravy. Differential Revision: https://reviews.llvm.org/D27061 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@288234 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-29[asan] Remove runtime flag detect_stack_use_after_scopeVitaly Buka
Summary: We are going to use store instructions to poison some allocas. Runtime flag will require branching in instrumented code on every lifetime intrinsic. We'd like to avoid that. Reviewers: eugenis Subscribers: llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D23967 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@279981 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-26[asan] first attempt at releasing free-d memory back to the system using ↵Kostya Serebryany
madvise. Requires quite some tuning. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@279887 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-18[asan] Add __asan_set_shadow_*Vitaly Buka
Summary: We are poisoning small allocas using store instruction from instrumented code. For larger allocas we'd like to insert function calls instead of multiple stores. PR27453 Reviewers: kcc, eugenis Subscribers: llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D23616 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@279019 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-03[compiler-rt] Fix CHECK coding style [NFC]Etienne Bergeron
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277604 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-19Add detect_stack_use_after_scope runtime flagVitaly Buka
Summary: This flag could be used to disable check in runtime. Subscribers: kubabrecka Differential Revision: https://reviews.llvm.org/D22495 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276004 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-21[asan] Fix shifting compiler warnings when compiler in 64-bitsEtienne Bergeron
Summary: The MSVC compiler complains about implicit conversion of 32-bits constant to 64-bit when using this shiting pattern 1 << (<64-bit expr>). Reviewers: rnk Subscribers: kcc, llvm-commits, wang0109, kubabrecka, chrisha Differential Revision: http://reviews.llvm.org/D21524 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@273267 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-04[ASan] Fix the links to bugs and wikipages.Alexander Potapenko
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254735 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-04Asan: utility function to determine first wrongly poisoned byte inMike Aizatsky
container. Differential Revision: http://reviews.llvm.org/D14341 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252071 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-17asan: optimization experimentsDmitry Vyukov
The experiments can be used to evaluate potential optimizations that remove instrumentation (assess false negatives). Instead of completely removing some instrumentation, you set Exp to a non-zero value (mask of optimization experiments that want to remove instrumentation of this instruction). If Exp is non-zero, this pass will emit special calls into runtime (e.g. __asan_report_exp_load1 instead of __asan_report_load1). These calls make runtime terminate the program in a special way (with a different exit status). Then you run the new compiler on a buggy corpus, collect the special terminations (ideally, you don't see them at all -- no false negatives) and make the decision on the optimization. The exact reaction to experiments in runtime is not implemented in this patch. It will be defined and implemented in a subsequent patch. http://reviews.llvm.org/D8198 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@232501 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-02[asan] Demote "trying to poison/unpoison memory region" messages...Sergey Matveev
... to verbosity level 3. Because log spam. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@230974 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20[asan] Allow changing verbosity in activation flags.Evgeniy Stepanov
This change removes some debug output in asan_flags.cc that was reading the verbosity level before all the flags were parsed. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226566 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-17[ASan] Introduce SetCanPoisonMemory() function.Alexey Samsonov
SetCanPoisonMemory()/CanPoisonMemory() functions are now used instead of "poison_heap" flag to determine if ASan is allowed to poison the shadow memory. This allows to hot-patch this value in runtime (e.g. during ASan activation) without introducing a data race. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224395 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-17[asan] the run-time part of intra-object-overflow detector ↵Kostya Serebryany
(-fsanitize-address-field-padding=1). Note that all of this is still experimental; don't use unless you are brave. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@220013 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-29[asan] add a test for array cookie if the operator new is defined inside the ↵Kostya Serebryany
class (the cookie should not be poisoned in such case); update the related comment in asan_poisoning.cc git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@218620 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-05[asan] relax the assertion around array cookie load; still need to extract a ↵Kostya Serebryany
reproducer where this assertion fails... git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@217215 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-28[asan] introduce __asan_load_cxx_array_cookie: check that the array cookie ↵Kostya Serebryany
address is properly poisoned and return the cookie value. If not, return 0 to avoid infinite loop of DTORs (in case of use-after-free). Calls to this function will be inserted by clang (separate change) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@216692 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-04[asan] poison array cookies only on 64-bit archKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214713 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-04[asan] introduce __asan_poison_cxx_array_cookie. This is asan-rt part of ↵Kostya Serebryany
PR19838 (Left OOB accesses on new[]-allocated arrays with array cookies are not detected). No tests yet. They will follow once I commit the clang part. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214711 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-06[asan] introduce interface function __sanitizer_verify_contiguous_container ↵Kostya Serebryany
to verify annotations in vector-like containers git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208092 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-21[asan] add a run-time flag detect_container_overflow=true/falseKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@206753 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-14[asan] don't use bool in public interface, make sure the interface headers ↵Kostya Serebryany
are usable in plain C git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@206160 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-14[asan] provide better reports for cases where memcpy/etc get negative size ↵Kostya Serebryany
parameter. Also fix a typo found by Tetsuo Kiso git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@206158 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-21[asan] relax the checks inside __sanitizer_annotate_contiguous_container: ↵Kostya Serebryany
they are too optimistic due to https://code.google.com/p/address-sanitizer/issues/detail?id=258. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@199715 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-23[asan] convert a CHECK failure in __sanitizer_annotate_contiguous_container ↵Kostya Serebryany
into a proper warning message git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197899 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-11[asan] when a fake stack is being unmapped also flush the corresponding shadowKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197040 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-09Fix Windows build.Sergey Matveev
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@196780 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-09[lsan] Make LSan ignore memory poisoned by ASan.Sergey Matveev
Summary: No more (potenital) false negatives due to red zones or fake stack frames. Reviewers: kcc, samsonov Reviewed By: samsonov CC: llvm-commits, samsonov Differential Revision: http://llvm-reviews.chandlerc.com/D2359 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@196778 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-05[sanitizer] Introduce VReport and VPrintf macros and use them in sanitizer code.Sergey Matveev
Instead of "if (common_flags()->verbosity) Report(...)" we now have macros. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@196497 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-19[asan] remove a fixed FIXME; extend the comment around ↵Kostya Serebryany
__sanitizer_annotate_contiguous_container git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195131 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-19[asan] new shadow poison magic for contiguous-container-buffer-overflow, ↵Kostya Serebryany
addressed Alexey Samsonov's comments for r195011 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195117 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-18[asan] fix Windows buildKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195012 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-18[asan] introduce __sanitizer_annotate_contiguous_containerKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195011 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-15tsan: move verbosity flag to CommonFlagsDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@192701 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-04[sanitizer] Fix __sanitizer_unaligned_* to work with unaligned data types.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@183224 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-10[asan] implement callbacks for unaligned loads/storesKostya Serebryany
Reviewers: samsonov Reviewed By: samsonov CC: samsonov, llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D652 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@179175 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-05[sanitizer] found a bug by code inspection: CHECK(a=b) instead of ↵Kostya Serebryany
CHECK(a==b). Was puzzled why lint did not catch it. Turns out this check was disabled for asan source. fix all cases and enable the check git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@178872 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-28[ASan] Speed-up initialization-order checking: create and use fast versions ↵Alexey Samsonov
of PoisonShadow functions, store copies of __asan_global descriptors in a vector instead of list of pointers. This gives 3x speedup on both benchmarks and real binaries with lots of globals. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@178239 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-31[ASan] Split ASan interface header into private and public parts. Add a test ↵Alexey Samsonov
that makes sure users can include interface header git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@174058 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-18[asan] fix two off-by-one errors that seem to affect only PowerPC because ↵Kostya Serebryany
only there the stack top may be equal to the address space top. Noted by Andreas Schwab in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55975#c11 . Also make swapcontext interceptor a bit more robust git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@172807 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-28[asan] implement more strict checking for memset/etc parameters. Instead of ↵Kostya Serebryany
checking the first and the last byte, we check the entire shadow region. This costs ~10 slowdown for the instrumented functions. Motivated by a nasty memset-buffer-overflow-by-140-bytes in chrome which was reported as a use-after-free or not at all git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@171198 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-20[asan] add a flag poison_heap to allow better allocator benchmarking, ↵Kostya Serebryany
implemenet malloc_stats() on Linux git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@170685 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-14[asan] more asan_allocator2 code: actually un/poison shadow on malloc/free Kostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@170190 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04ASan: add new interface functions - __asan_(un)poison_stack_memory. Calls to ↵Alexey Samsonov
these functions are inserted by the instrumentation pass in use-after-scope mode git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@169201 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-29Relocate the external headers provided by ASan and the common sanitizerChandler Carruth
library. These headers are intended to be available to user code when built with AddressSanitizer (or one of the other sanitizer's in the future) to interface with the runtime library. As such, they form stable external C interfaces, and the headers shouldn't be located within the implementation. I've pulled them out into what seem like fairly obvious locations and names, but I'm wide open to further bikeshedding of these names and locations. I've updated the code and the build system to cope with the new locations, both CMake and Makefile. Please let me know if this breaks anyone's build. The eventual goal is to install these headers along side the Clang builtin headers when we build the ASan runtime and install it. My current thinking is to locate them at: <prefix>/lib/clang/X.Y/include/sanitizer/common_interface_defs.h <prefix>/lib/clang/X.Y/include/sanitizer/asan_interface.h <prefix>/lib/clang/X.Y/include/sanitizer/... But maybe others have different suggestions? Fixing the style of the #include between these headers at least unblocks experimentation with installing them as they now should work when installed in these locations. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@162822 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-09[ASan] Use common flags parsing machinery.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@159933 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-06[ASan] Make printf arguments match format strings better.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158059 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-04Remove file-type tags for .cc files in ASan run-time libraryAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@157927 91177308-0d34-0410-b5e6-96231b3b80d8