Commit Graph

37 Commits

Author SHA1 Message Date
Etienne Bergeron 7903382468 [compiler-rt] Add internal wcslen to avoid crashing on windows 64-bits
Summary:
The function wcslen is incorrectly hooked on windows 64-bits.

The interception library is not able to hook without breaking the code.
The function is too small and the interception must be done with
trampoline-hooking which turned out to be incorrect on a small
loop (first few instructions have a backedge).

Reviewers: rnk

Subscribers: wang0109, chrisha, llvm-commits, kubabrecka

Differential Revision: https://reviews.llvm.org/D22363

llvm-svn: 275488
2016-07-14 22:13:41 +00:00
Reid Kleckner 1992ac75db Fix warnings uncovered by building with clang-cl
Move ifdefs to avoid unused static helpers. Move alignment attribute so
that it is respected in GCC and MSVC.

llvm-svn: 265153
2016-04-01 17:09:12 +00:00
Anna Zaks c54cf07fd7 [compiler-rt] Add internal implementations for strlcat and strlcpy
The compiler-rt should make use of strlcpy() rather than strncpy(). Using internal_strncpy() may be fine with appropriate bounds checking or enforcement of nul-termination elsewhere, but it's just good practice these days to avoid using strncpy() in new code.

A patch by Jeremy Sequoia!

Differential Revision: http://reviews.llvm.org/D14714

llvm-svn: 253690
2015-11-20 18:42:05 +00:00
Vedant Kumar f997bd88d7 [compiler-rt] Fix build by wrapping lines to 80 chars (NFC)
llvm-svn: 248973
2015-10-01 00:48:07 +00:00
Vedant Kumar 552c0111f1 [sanitizer_common] Apply modernize-use-nullptr, other minor fixes
- 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

llvm-svn: 248964
2015-09-30 23:52:54 +00:00
Kuba Brecka bb39671516 [compiler-rt] Make MaybeReexec properly process DYLD_INSERT_LIBRARIES when using non-absolute paths
MaybeReexec() in asan_mac.cc checks for presence of the ASan dylib in DYLD_INSERT_LIBRARIES, and if it is there, it will process this env. var. and remove the dylib from its value, so that spawned children don't have this variable set. However, the current implementation only works when using a canonical absolute path to the dylib, it fails to remove the dylib for example when using @executable_path.

This patch changes the processing of DYLD_INSERT_LIBRARIES to comparing values only based on filenames (ignoring directories).

Reviewed at http://reviews.llvm.org/D7160

llvm-svn: 228392
2015-02-06 12:07:29 +00:00
Evgeniy Stepanov f294d5b829 [sanitizer] Flag parser rewrite.
The new parser is a lot stricter about syntax, reports unrecognized
flags, and will make it easier to implemented some of the planned features.

llvm-svn: 226169
2015-01-15 15:13:43 +00:00
Jay Foad e47130e407 [ASan] Get fake stack code working with GCC 4.8.2.
Summary:
TestCases/Linux/heavy_uar_test.cc was failing on my
PowerPC64 box with GCC 4.8.2, because the compiler recognised
a memset-like loop and turned it into a call to memset, which
got intercepted by __asan_memset, which got upset because it was
being called on an address in high shadow memory.

Use break_optimization to stop the compiler from doing this.

Reviewers: kcc, samsonov

Reviewed By: kcc

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D6266

llvm-svn: 222572
2014-11-21 21:25:09 +00:00
Alexey Samsonov 4925fd4b05 Fix -Wcast-qual warnings in sanitizers
llvm-svn: 221936
2014-11-13 22:40:59 +00:00
Dmitry Vyukov a538aac8ce tsan: fix windows build
llvm-svn: 200778
2014-02-04 17:27:29 +00:00
Timur Iskhodzhanov 0d419293e2 [ASan] Follow-up fix: use #if SANITIZER_WINDOWS, not #ifdef
llvm-svn: 195625
2013-11-25 07:56:05 +00:00
Timur Iskhodzhanov 25cc3c55cc [ASan] Un-break the Windows build
llvm-svn: 195624
2013-11-25 07:54:55 +00:00
Kostya Serebryany a2fde9484f [sanitizer] use 16-byte aligned bzero in performance critical place (mostly for lsan)
llvm-svn: 195549
2013-11-23 12:49:19 +00:00
Alexey Samsonov 249c7fb10e Add internal_strchrnul function
llvm-svn: 189797
2013-09-03 13:09:28 +00:00
Will Dietz 1b9b9ec464 Avoid compiler-generated memset by using internal_memset.
Fixes PR17025.

llvm-svn: 189693
2013-08-30 19:53:55 +00:00
Alexey Samsonov c30e2d6b3a Make InternalAlloc/InternalFree in sanitizer runtimes libc-free by switching to a custom allocator.
llvm-svn: 182836
2013-05-29 09:15:39 +00:00
Dmitry Vyukov 7981ea8baa asan/tsan: fix compilation errors/bugs on Windows where long is 32-bit even in 64-bit mode
llvm-svn: 174312
2013-02-04 08:07:45 +00:00
Kostya Serebryany cb510e50e2 [asan] implement more strict checking for memset/etc parameters. Instead of 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
llvm-svn: 171198
2012-12-28 15:24:16 +00:00
Alexander Potapenko dda4f0b593 Fix a compiler warning in internal_memmove.
llvm-svn: 166775
2012-10-26 13:47:36 +00:00
Alexander Potapenko 2a1925852d Fix the internal_memmove() implementation that used to skip src[0] if dst < src.
llvm-svn: 166774
2012-10-26 13:24:20 +00:00
Kostya Serebryany 278bd2e3a3 [asan] fix lint
llvm-svn: 166006
2012-10-16 04:50:32 +00:00
Alexander Potapenko 7b03290c43 Implement internal_memmove.
Use internal_memmove() and internal_memcpy() in the memcpy() and memmove() wrappers
when building the dynamic runtime (OS X only), to work around a bug in resolver functions wrapping.
See also http://code.google.com/p/address-sanitizer/issues/detail?id=116

llvm-svn: 165939
2012-10-15 15:34:41 +00:00
Alexey Samsonov b92488a549 [Sanitizer] implement internal_strcspn
llvm-svn: 162272
2012-08-21 09:26:26 +00:00
Kostya Serebryany 98390d0b71 [tsan] a bit more lint and Makefile changes to run tests from sanitizer_common
llvm-svn: 158821
2012-06-20 15:19:17 +00:00
Alexey Samsonov 8516014790 [Sanitizer] add internal_strncmp to sanitizer libc
llvm-svn: 158658
2012-06-18 14:34:59 +00:00
Alexey Samsonov 156958dd0c [Sanitizer] move all the rest re-implementations of libc functions from ASan runtime to common sanitizer runtime
llvm-svn: 158519
2012-06-15 13:09:52 +00:00
Alexey Samsonov 3efd6fc26c [Sanitizer] Use DEFINE_REAL macro in TSan runtime to call libc implementations of functions. Move strchr to sanitizer_libc.
llvm-svn: 158517
2012-06-15 12:24:07 +00:00
Alexey Samsonov 96ef49a71e [Sanitizer] Move internal_memcmp to common sanitizer libc
llvm-svn: 158450
2012-06-14 14:04:54 +00:00
Alexey Samsonov 59036d2c06 [Sanitizer] add internal_memset and internal_strrchr to sanitizer_common/
llvm-svn: 158202
2012-06-08 14:11:12 +00:00
Alexey Samsonov 91e1a7eb17 [Sanitizer] move internal_strdup and internal_memcpy to common runtime. Make internal allocations from TSan runtime call InternalAlloc from common runtime
llvm-svn: 158148
2012-06-07 11:54:08 +00:00
Alexey Samsonov ee07290628 [Sanitizer] Move more functions/constants to sanitizer_common.
llvm-svn: 158056
2012-06-06 09:26:25 +00:00
Alexey Samsonov 5bbf8290a7 [Sanitizer] rename sanitizer_defs.h to sanitizer_internal_defs.h
llvm-svn: 158001
2012-06-05 14:25:27 +00:00
Alexey Samsonov 7ac77d6b29 [Sanitizer] add sanitizer_posix.cc. Move more various functions into sanitizer_libc: sscanf, munmap, memchr
llvm-svn: 157994
2012-06-05 09:49:25 +00:00
Alexey Samsonov 3b2f9f4c98 Remove file-type tags in .cc files in tsan/ and sanitizer_common/
llvm-svn: 157928
2012-06-04 13:55:19 +00:00
Alexey Samsonov 90f9630c80 [Sanitizer]: move internal_strcmp to sanitizer_common
llvm-svn: 157926
2012-06-04 13:27:49 +00:00
Alexey Samsonov 06f2cd38c1 [Sanitizer] Move internal_strncpy to sanitizer_libc (and make its behavior conforming to manual)
llvm-svn: 157922
2012-06-04 10:30:16 +00:00
Kostya Serebryany c5bea20e2e [asan,tsan] rename files in sanitizer_common to have a common prefix (sanitizer_).
llvm-svn: 157740
2012-05-31 13:42:53 +00:00