Commit Graph

83 Commits

Author SHA1 Message Date
Kostya Serebryany 4fca6e8063 [libFuzzer] prepare for __sanitizer_cov_trace_switch in libFuzzer and sanitizer coverage. Also fix pedantic warnings
llvm-svn: 243721
2015-07-31 01:07:12 +00:00
Adhemerval Zanella 4e3b4ac241 [dfsan] Enable dfsan for aarch64
This patch enable DFSan for AArch64 (39-bit VMA).  All tests are passing
but:

 * test/dfsan/custom.cc

Due an invalid access in dl_iterate_phdr instrumentation (commenting out
this function make the testcase to pass).  The test is XFAIL for aarch64
for now.

llvm-svn: 243688
2015-07-30 21:13:21 +00:00
Kostya Serebryany 66a75c54be [sanitizer] add a weak hook for strncmp interceptor, both to dfsan and other sanitizers. Hide the declaration and the calls in better macros
llvm-svn: 243610
2015-07-30 02:32:51 +00:00
Kostya Serebryany c520f17c6f [dfsan/libFuzzer] correctly ignore sanitizer coverage calls in dfsan
llvm-svn: 243362
2015-07-28 00:57:07 +00:00
Evgeniy Stepanov 5a268b10b3 [sanitizer] Implement logging to syslog.
Previously, Android target had a logic of duplicating all sanitizer
output to logcat. This change extends it to all posix platforms via
the use of syslog, controlled by log_to_syslog flag. Enabled by
default on Android, off everywhere else.

A bit of cmake magic is required to allow Printf() to call a libc
function. I'm adding a stub implementation to support no-libc builds
like dfsan and safestack.

This is a second attempt. I believe I've fixed all the issues that
prompted the revert: Mac build, and all kinds of non-CMake builds
(there are 3 of those).

llvm-svn: 243051
2015-07-23 22:05:20 +00:00
Evgeniy Stepanov ffbc4ec790 Revert r242975.
Breaks Mac build.

llvm-svn: 242978
2015-07-23 01:29:26 +00:00
Evgeniy Stepanov 4f03227fa2 [sanitizer] Implement logging to syslog.
Previously, Android target had a logic of duplicating all sanitizer
output to logcat. This change extends it to all posix platforms via
the use of syslog, controlled by log_to_syslog flag. Enabled by
default on Android, off everywhere else.

A bit of cmake magic is required to allow Printf() to call a libc
function. I'm adding a stub implementation to support no-libc builds
like dfsan and safestack.

llvm-svn: 242975
2015-07-22 23:57:19 +00:00
Kostya Serebryany 05425a88cd [dfsan] ignore more __sanitizer callbacks
llvm-svn: 238085
2015-05-23 01:56:39 +00:00
Kostya Serebryany 13c03581ac Add dfsan_weak_hook_memcmp
Summary:
Add a weak hook to be called from dfsan's custom memcmp.
The primary user will be lib/Fuzzer.
If this works well we'll add more hooks (strcmp, etc).

Test Plan: Will be covered by lib/Fuzzer tests.

Reviewers: pcc

Reviewed By: pcc

Subscribers: llvm-commits

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

llvm-svn: 236679
2015-05-07 00:04:39 +00:00
Kostya Serebryany a86398e3fd Add api_list entries for the dfsan-based fuzzer
Summary: Add api_list entries for the dfsan-based fuzzer

Test Plan: covered by check-fuzzer

Reviewers: pcc

Reviewed By: pcc

Subscribers: llvm-commits

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

llvm-svn: 236657
2015-05-06 22:41:34 +00:00
Dimitry Andric 66749021d4 Make check_custom_wrappers.sh work on FreeBSD
Summary:
When running the compiler-rt testsuite on FreeBSD (it didn't matter which version), I always got the same error result:

    FAILED: cd /home/dim/obj/llvm-234092-trunk-freebsd10-amd64-ninja-rel-1/projects/compiler-rt/lib && LLVM_CHECKOUT=/home/dim/src/llvm/trunk SILENT=1 TMPDIR= PYTHON_EXECUTABLE=/usr/local/bin/python2.7 COMPILER_RT=/home/dim/src/llvm/trunk/projects/compiler-rt /home/dim/src/llvm/trunk/projects/compiler-rt/lib/sanitizer_common/scripts/check_lint.sh
    The following differences between the implemented custom wrappers and the tests have been found:
    --- /tmp/tmp.vPFEefvclf 2015-04-04 17:11:44.996734563 +0200
    +++ /tmp/tmp.NbIuvjxKEe 2015-04-04 17:11:45.044734647 +0200
    @@ -1,52 +0,0 @@
    -calloc
    -clock_gettime
    -ctime_r
    -dfsan_set_write_callback
    -dl_iterate_phdr
    -dlopen
    -fgets
    -fstat
    -get_current_dir_name
    -getcwd
    -gethostname
    -getpwuid_r
    -getrlimit
    -getrusage
    -gettimeofday
    -inet_pton
    -localtime_r
    -memchr
    -memcmp
    -memcpy
    -memset
    -nanosleep
    -poll
    -pread
    -pthread_create
    -read
    -sched_getaffinity
    -select
    -sigaction
    -sigemptyset
    -snprintf
    -socketpair
    -sprintf
    -stat
    -strcasecmp
    -strchr
    -strcmp
    -strcpy
    -strdup
    -strlen
    -strncasecmp
    -strncmp
    -strncpy
    -strrchr
    -strstr
    -strtod
    -strtol
    -strtoll
    -strtoul
    -strtoull
    -time
    -write

After some investigation, it turns out to be due to the regex used for search test_ symbols in lib/dfsan/scripts/check_customer_wrappers.sh:

    grep -E "^\\s*test_.*\(\);" ${DFSAN_CUSTOM_TESTS}

This uses \s to search for whitespace at start of line, but support for \s was only introduced in GNU grep v2.5.4-112-gf979ca0, while both FreeBSD and OSX only have grep 2.5.1 (the last version released under GPLv2).

I propose to change \s into [[:space:]], which is the more portable notation.

Test Plan: Run regression tests, and see that they work now. :)

Reviewers: pcc, samsonov, emaste

Reviewed By: emaste

Subscribers: llvm-commits, emaste

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

llvm-svn: 234704
2015-04-12 10:54:46 +00:00
Lorenzo Martignoni 4879003022 Extend s{,n}printf custom wrappers to support '*' in the format specifiers
Differential Revision: http://reviews.llvm.org/D8966

llvm-svn: 234633
2015-04-10 20:58:28 +00:00
Timur Iskhodzhanov ea1f332b79 Split Mprotect into MmapNoAccess and MprotectNoAccess to be more portable
On Windows, we have to know if a memory to be protected is mapped or not.
On POSIX, Mprotect was semantically different from mprotect most people know.

llvm-svn: 234602
2015-04-10 15:02:19 +00:00
Peter Collingbourne 8f9a3f2d7e Revert r234477, "Differential Revision: http://reviews.llvm.org/D7249"
Should unbreak fuzzer buildbot.

llvm-svn: 234542
2015-04-09 22:42:01 +00:00
Timur Iskhodzhanov e8a6fbbfd3 Use WriteToFile instead of internal_write in non-POSIX code
llvm-svn: 234487
2015-04-09 14:11:25 +00:00
Timur Iskhodzhanov 864308a78d Introduce CloseFile to be used instead of internal_close on non-POSIX
llvm-svn: 234481
2015-04-09 12:37:05 +00:00
Lorenzo Martignoni 59886f3c1a Differential Revision: http://reviews.llvm.org/D7249
llvm-svn: 234477
2015-04-09 11:42:33 +00:00
Alexander Potapenko b9c928bd10 [libsanitizer] Fix OpenFile() usage in TSan and DFSan.
This is a follow-up for r232936.

llvm-svn: 232937
2015-03-23 10:32:28 +00:00
Alexey Samsonov d311566e1a Remove support for building sanitizers from Makefile/autoconf build on Linux.
This is a re-application of r229554 restricted to Linux build only.
Apple still uses Makefile/autoconf to build Clang and sanitizers.

llvm-svn: 229756
2015-02-18 22:26:49 +00:00
Matthias Braun c0a2279099 Revert "Remove support for building sanitizers from Makefile/autoconf build."
This reverts commit r229556.

Reverting this for now as internal apple builds rely on this
functionality.

llvm-svn: 229585
2015-02-17 23:30:51 +00:00
Alexey Samsonov d907016dd0 Remove support for building sanitizers from Makefile/autoconf build.
They autotools build has a number of missing features, supports less
OS, architectures, build configurations, doesn't have any tests and
is hard to support in sync with CMake build.

llvm-svn: 229556
2015-02-17 21:53:45 +00:00
Alexey Samsonov 1225816a2d [Sanitizer] Change InitializeFlags() signatures. NFC.
These functions are always used to initialize singleton flags(), as
well as other global data (common_flags()).

llvm-svn: 228894
2015-02-12 00:36:42 +00:00
Viktor Kutuzov 07e6c00171 [Sanitizers] Introduce GET_LINK_MAP_BY_DLOPEN_HANDLE() macro
Differential Revision: http://reviews.llvm.org/D7233

llvm-svn: 227570
2015-01-30 12:43:52 +00:00
Evgeniy Stepanov 0540f4141f [dfsan] Use append_no_rtti_flag instead of manually specifying -fno-rtti.
llvm-svn: 226435
2015-01-19 08:26:38 +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
Peter Collingbourne 75e259ed95 [dfsan] Export dfsan_get_label_info function with C linkage.
llvm-svn: 225692
2015-01-12 20:40:30 +00:00
Alexey Samsonov 03499e920b [Sanitizer] Change the runtime flag representation.
This mirrors r225239 to all the rest sanitizers:
ASan, DFSan, LSan, MSan, TSan, UBSan.

Now the runtime flag type, name, default value and
description is located in the single place in the
.inc file.

llvm-svn: 225327
2015-01-07 00:38:00 +00:00
Peter Collingbourne fd860bc41a [DFSAN][MIPS] adding support of DFSAN for MIPS64
Minor changes to enable DFSAN on MIPS64

Patch by Kumar Sukhani!

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

llvm-svn: 223517
2014-12-05 21:22:36 +00:00
Lorenzo Martignoni 101f1d82ff [DFSan] Add flag to dump the labels when the program terminates.
Differential Revision: http://reviews.llvm.org/D6306

llvm-svn: 222425
2014-11-20 10:01:08 +00:00
Alexey Samsonov 4925fd4b05 Fix -Wcast-qual warnings in sanitizers
llvm-svn: 221936
2014-11-13 22:40:59 +00:00
Peter Collingbourne f20091118c [dfsan] Add runtime function for aborting on indirect calls to
uninstrumented vararg functions.

llvm-svn: 221364
2014-11-05 17:21:11 +00:00
Peter Collingbourne 4da39395b0 [dfsan] Add libgo functions to ABI list.
llvm-svn: 221363
2014-11-05 17:21:08 +00:00
Peter Collingbourne 113ff7f309 [dfsan] Upgrade ABI list to Ubuntu 14.04.
This incorporates some of the newer functions used by (e.g.) the Go runtime.

llvm-svn: 221362
2014-11-05 17:21:06 +00:00
Peter Collingbourne 7e3c657f4a [dfsan] Modify build-libc-list.py to filter out local functions in generated
ABI list.

llvm-svn: 221361
2014-11-05 17:21:04 +00:00
Peter Collingbourne b190e1b74b Update __dfsw_s{,n}printf custom functions for new calling convention.
Differential Revision: http://reviews.llvm.org/D6029

llvm-svn: 220907
2014-10-30 13:23:01 +00:00
Kuba Brecka 14c0c5901d [compiler-rt] compiler-rt's CMake append_if function clashes with LLVM's, let's rename it to append_list_if
Doing s/append_if/append_list_if/, no functional change.

http://reviews.llvm.org/D5739

llvm-svn: 219860
2014-10-15 22:47:54 +00:00
Ed Maste e4320f5e6a Remove bashisms and switch to /bin/sh
On a default FreeBSD install Bash is not installed and fdescfs is not
mounted.  Use plain sh functionality instead.

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

llvm-svn: 219333
2014-10-08 18:35:16 +00:00
Lorenzo Martignoni 60ebffc12f Custom wrappers for DFSanitizing sprintf & snprintf.
Differential Revision: http://reviews.llvm.org/D5561

llvm-svn: 219293
2014-10-08 10:01:42 +00:00
Peter Collingbourne 82ff058cf9 DFSan's set label function should avoid writing to the shadow memory when the write would not change the value in memory.
When writing a label to shadow memory, don't write if the value is already set to the value being written.  This dramatically reduces real memory consumption in programs with sparse use of labels.

Test Plan: It would be nice to test that unnecessary writes are skipped, but I do not see how a unit test could do this.

Patch by Sam Kerner!

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

llvm-svn: 215961
2014-08-19 01:47:33 +00:00
Alexey Samsonov f51b9488c6 [DFSan] Fixup for r213980
llvm-svn: 213997
2014-07-26 00:49:36 +00:00
Alexey Samsonov 2178054216 [Sanitizer] Introduce SANITIZER_CAN_USE_PREINIT_ARRAY definition and use it across sanitizers.
Get rid of ASAN_USE_PREINIT_ARRAY and LSAN_USE_PREINIT_ARRAY - just always
use .preinit_array if it's available. This mode seems stable enough, and
we've been relying on default values of these macro for a long time.

llvm-svn: 213980
2014-07-25 22:05:02 +00:00
Peter Collingbourne 8501e39a85 [dfsan] Fix the declaration of dfsan_add_label.
llvm-svn: 210202
2014-06-04 17:54:51 +00:00
Chandler Carruth c42ddde78a The newest versions of CMake require outputs of custom commands be in
DEPENDS rather than SOURCES. The SOURCES just end up looking on the
filesystem and not finding anything. Makes for very hard to debug build
errors. =/

llvm-svn: 207722
2014-04-30 23:31:45 +00:00
Peter Collingbourne 16f2f18105 Add user-defined callback on write() calls.
Add dfsan_set_write_callback(), which sets a callback to be invoked when
a write() call is invoked within DFSan instrumented code.

Patch by Sam Kerner!

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

llvm-svn: 207131
2014-04-24 17:42:16 +00:00
Alexey Samsonov 78a8435fd6 [CMake] Rename add_compiler_rt_static_runtime to add_compiler_rt_runtime.
Soon there will be an option to build compiler-rt parts as shared libraries
on Linux. Extracted from http://llvm-reviews.chandlerc.com/D3042
by Yuri Gribov.

llvm-svn: 205183
2014-03-31 13:45:36 +00:00
Peter Collingbourne 5d167dae7d Add function to get the number of DFSan labels allocated.
Expose the number of DFSan labels allocated by adding function dfsan_get_label_count().

Patch by Sam Kerner!

Differential Revision: http://llvm-reviews.chandlerc.com/D3109

llvm-svn: 204854
2014-03-26 21:09:53 +00:00
Alexander Potapenko 1296436cbf [libsanitizer] Introduce flag descriptions.
Extend ParseFlag to accept the |description| parameter, add dummy values for all existing flags.
As the flags are parsed their descriptions are stored in a global linked list.
The tool can later call __sanitizer::PrintFlagDescriptions() to dump all the flag names and their descriptions.
Add the 'help' flag and make ASan, TSan and MSan print the flags if 'help' is set to 1.

llvm-svn: 204339
2014-03-20 12:52:52 +00:00
Alexey Samsonov 32956d651a [CMake] Make append_if semantics similar to those used in LLVM
llvm-svn: 203773
2014-03-13 09:31:36 +00:00
Alexey Samsonov 98aa08c0e9 Update sanitizers' bash scripts.
* Fix bash scripts to work on FreeBSD (patch by Viktor Kutuzov)
* Update locations of lit tests in check_lint script.

llvm-svn: 202145
2014-02-25 12:09:25 +00:00
Alexey Samsonov 1181a104e6 [CMake] Rename several variables
llvm-svn: 201575
2014-02-18 14:28:53 +00:00