summaryrefslogtreecommitdiff
path: root/lib/dfsan
AgeCommit message (Collapse)Author
2017-07-22[sanitizer_common] Move filesystem-related code out of sanitizer_common.ccVitaly Buka
Summary: This is a pure refactoring change. It just moves code that is related to filesystem operations from sanitizer_common.{cc,h} to sanitizer_file.{cc,h}. This makes it cleaner to disable the filesystem-related code for a new port that doesn't want it. Submitted on behalf of Roland McGrath. Reviewers: kcc, eugenis, alekseyshl Reviewed By: alekseyshl Subscribers: vitalybuka, llvm-commits, kubamracek, mgorny, phosek Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D35591 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308819 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-20Revert "[sanitizer_common] Move filesystem-related code out of ↵Vitaly Buka
sanitizer_common.cc" Breaks Windows build. This reverts commit r308640. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308648 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-20[sanitizer_common] Move filesystem-related code out of sanitizer_common.ccAlex Shlyapnikov
This is a pure refactoring change. It just moves code that is related to filesystem operations from sanitizer_common.{cc,h} to sanitizer_file.{cc,h}. This makes it cleaner to disable the filesystem-related code for a new port that doesn't want it. Commiting for mcgrathr. Reviewers: alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35591 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308640 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-31[sanitizer-coverage] remove stale code (old coverage); compiler-rt part Kostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304318 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-19[sanitizer-coverage] remove more unused codeKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300780 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-19[sanitizer-coverage] remove run-time support for ↵Kostya Serebryany
-fsanitize-coverage=indirect-calls git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300775 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-19[sanitizer-coverage] remove run-time support for the deprecated ↵Kostya Serebryany
-fsanitize-coverage=8bit-counters git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300745 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12Revert "[sancov] moving sancov rt to sancov/ directory"Mike Aizatsky
This reverts commit https://reviews.llvm.org/rL291734 Reason: mac breakage http://lab.llvm.org:8080/green//job/clang-stage1-configure-RA_build/28798/consoleFull#1657087648e9a0fee5-ebcc-4238-a641-c5aa112c323e git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@291736 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12[sancov] moving sancov rt to sancov/ directoryMike Aizatsky
Subscribers: kubabrecka, mgorny Differential Revision: https://reviews.llvm.org/D28541 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@291734 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-15[compiler-rt] Do not introduce __sanitizer namespace globallyAnna Zaks
The definitions in sanitizer_common may conflict with definitions from system headers because: The runtime includes the system headers after the project headers (as per LLVM coding guidelines). lib/sanitizer_common/sanitizer_internal_defs.h pollutes the namespace of everything defined after it, which is all/most of the sanitizer .h and .cc files and the included system headers with: using namespace __sanitizer; // NOLINT This patch solves the problem by introducing the namespace only within the sanitizer namespaces as proposed by Dmitry. Differential Revision: https://reviews.llvm.org/D21947 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281657 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-26[CMake] Connect Compiler-RT targets to LLVM Runtimes directoryChris Bieneman
This patch builds on LLVM r279776. In this patch I've done some cleanup and abstracted three common steps runtime components have in their CMakeLists files, and added a fourth. The three steps I abstract are: (1) Add a top-level target (i.e asan, msan, ...) (2) Set the target properties for sorting files in IDE generators (3) Make the compiler-rt target depend on the top-level target The new step is to check if a command named "runtime_register_component" is defined, and to call it with the component name. The runtime_register_component command is defined in llvm/runtimes/CMakeLists.txt, and presently just adds the component to a list of sub-components, which later gets used to generate target mappings. With this patch a new workflow for runtimes builds is supported. The new workflow when building runtimes from the LLVM runtimes directory is: > cmake [...] > ninja runtimes-configure > ninja asan The "runtimes-configure" target builds all the dependencies for configuring the runtimes projects, and runs CMake on the runtimes projects. Running the runtimes CMake generates a list of targets to bind into the top-level CMake so subsequent build invocations will have access to some of Compiler-RT's targets through the top-level build. Note: This patch does exclude some top-level targets from compiler-rt libraries because they either don't install files (sanitizer_common), or don't have a cooresponding `check` target (stats). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@279863 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-25dfsan: Enable 48-bit VMA support on aarch64Adhemerval Zanella
This patch adds 48-bits VMA support for msan on aarch64. As current mappings for aarch64, 48-bit VMA also supports PIE executable. Tested on 39 and 48-bit VMA kernels on aarch64. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@279753 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-18[sanitizer-coverage] add __sanitizer_cov_trace_cmp[1248] to the ↵Kostya Serebryany
sanitizer-coverage interface git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@279026 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-11[compiler-rt] Fix VisualStudio virtual folders layoutEtienne Bergeron
Summary: This patch is a refactoring of the way cmake 'targets' are grouped. It won't affect non-UI cmake-generators. Clang/LLVM are using a structured way to group targets which ease navigation through Visual Studio UI. The Compiler-RT projects differ from the way Clang/LLVM are grouping targets. This patch doesn't contain behavior changes. Reviewers: kubabrecka, rnk Subscribers: wang0109, llvm-commits, kubabrecka, chrisha Differential Revision: http://reviews.llvm.org/D21952 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275111 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27[sanitizer] [SystemZ] Abort if the kernel might be vulnerable to CVE-2016-2143.Marcin Koscielnicki
In short, CVE-2016-2143 will crash the machine if a process uses both >4TB virtual addresses and fork(). ASan, TSan, and MSan will, by necessity, map a sizable chunk of virtual address space, which is much larger than 4TB. Even worse, sanitizers will always use fork() for llvm-symbolizer when a bug is detected. Disable all three by aborting on process initialization if the running kernel version is not known to contain a fix. Unfortunately, there's no reliable way to detect the fix without crashing the kernel. So, we rely on whitelisting - I've included a list of upstream kernel versions that will work. In case someone uses a distribution kernel or applied the fix themselves, an override switch is also included. Differential Revision: http://reviews.llvm.org/D19576 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267747 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-22[sanitizer] rename MmapNoAccess to MmapFixedNoAccess; NFCKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267253 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-18[sancov] common flags initialization.Mike Aizatsky
Summary: Introducing InitializeCommonFlags accross all sanitizers to simplify common flags management. Setting coverage=1 when html_cov_report is requested. Differential Revision: http://reviews.llvm.org/D18273 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@263820 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-05[cmake] Address Samsonov's post-commit review of r262723Filipe Cabecinhas
Reviewers: samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D17896 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@262770 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-27[compiler-rt] [dfsan] Unify aarch64 mappingAdhemerval Zanella
This patch reorganize the platform specific mapping information to export the application mask on a external variable. This exported variable will be used by intrumentation phase to create code to be used on architecture with multiple VMA range. The patch creates a new header, dfsan_platform.h, and move all the mapping information and also create function accessors to the mapping value. Also for aarch64 it initialize application exported mask to the value based on runtime VMA detection. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254197 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-19Tell clang-format that (most) sanitizers are written using Google style guide.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253608 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-01[compiler-rt] Apply modernize-use-nullptr fixes in sanitizersVedant Kumar
- Trim spaces. - Use nullptr in place of 0 for pointer variables. - Use '!p' in place of 'p == 0' for null pointer checks. - Add blank lines to separate function definitions. - Add 'extern "C"' or 'namespace foo' comments after the appropriate closing brackets This is a continuation of work from 409b7b82. The focus here is on the various sanitizers (not sanitizer_common, as before). Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13225 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@248966 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-15[sanitizer] Move CheckVMASize after flag initializationAdhemerval Zanella
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@247684 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-11[compiler-rt] [sanitizers] Add VMA size check at runtimeAdhemerval Zanella
This patch adds a runtime check for asan, dfsan, msan, and tsan for architectures that support multiple VMA size (like aarch64). Currently the check only prints a warning indicating which is the VMA built and expected against the one detected at runtime. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@247413 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-27[CMake] Add ARCHS option to add_sanitizer_rt_symbols.Chris Bieneman
Summary: This is another step in a multi-step refactoring to move add_sanitizer_rt_symbols in the direction of other add_* functions in compiler-rt. Changes to CMakeLists files are all minimal except ubsan which tests the new ARCHS loop. Further cleanup patches will follow. Reviewers: filcab, bogner, kubabrecka, zaks.anna, glider, samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12410 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@246199 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-26[CMake] Converting add_sanitizer_rt_symbols to use cmake_parse_arguments.Chris Bieneman
Summary: This is the first step in a multi-step refactoring to move add_sanitizer_rt_symbols in the direction of other add_* functions in compiler-rt. Reviewers: filcab, bogner, kubabrecka, zaks.anna, glider, samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12386 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@246102 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-25[CMake] merge add_compiler_rt_runtime and add_compiler_rt_darwin_runtime ↵Chris Bieneman
into a single function Summary: This refactoring moves much of the Apple-specific behavior into a function in AddCompilerRT. The next cleanup patch will remove more of the if(APPLE) checks in the outlying CMakeLists. This patch adds a bunch of new functionality to add_compiler_rt_runtime so that the target names don't need to be reconstructed outside the call. It also updates some of the call sites to exercise the new functionality, but does not update all uses fully. Subsequent patches will further update call sites and move to using the new features. Reviewers: filcab, bogner, kubabrecka, zaks.anna, glider, samsonov Subscribers: beanz, rengolin, llvm-commits Differential Revision: http://reviews.llvm.org/D12292 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245970 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-24[Sanitizers] Allow to install several internal Die callbacks.Alexey Samsonov
This is required to properly re-apply r245770: 1) We should be able to dump coverage in __sanitizer::Die() if coverage collection is turned on. 2) We don't want to explicitly do this in every single sanitizer that supports it. 3) We don't want to link in coverage (and therefore symbolization) bits into small sanitizers that don't support it (safestack). The solution is to make InitializeCoverage() register its own Die() callback that would call __sanitizer_cov_dump(). This callback should be executed in addition to another tool-specific die callbacks (if there are any). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245889 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-24[dfsan] Enable DFSan for AArch64/42-bit VMAAdhemerval Zanella
This patch adds support for dfsan on aarch64-linux with 42-bit VMA (current default config for 64K pagesize kernels). The support is enabled by defining the SANITIZER_AARCH64_VMA to 42 at build time for both clang/llvm and compiler-rt. The default VMA is 39 bits. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245841 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-21[DFSan] Remove nolibc build.Alexey Samsonov
It's not used now, as is not even included in "dfsan" target. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245766 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-18[DFSan] Properly initialize and parse common flags in DFSan.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245362 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-05[libFuzzer] add weak hooks for strcmpKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@244083 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-05[libFuzzer/DFSan] add more __sanitizer callbacks to dfsan blacklistKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@244082 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-31[libFuzzer] prepare for __sanitizer_cov_trace_switch in libFuzzer and ↵Kostya Serebryany
sanitizer coverage. Also fix pedantic warnings git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@243721 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-30[dfsan] Enable dfsan for aarch64Adhemerval Zanella
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@243688 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-30[sanitizer] add a weak hook for strncmp interceptor, both to dfsan and other ↵Kostya Serebryany
sanitizers. Hide the declaration and the calls in better macros git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@243610 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-28[dfsan/libFuzzer] correctly ignore sanitizer coverage calls in dfsanKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@243362 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23[sanitizer] Implement logging to syslog.Evgeniy Stepanov
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). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@243051 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23Revert r242975.Evgeniy Stepanov
Breaks Mac build. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@242978 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22[sanitizer] Implement logging to syslog.Evgeniy Stepanov
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@242975 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-23[dfsan] ignore more __sanitizer callbacksKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@238085 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-07Add dfsan_weak_hook_memcmpKostya Serebryany
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@236679 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-06Add api_list entries for the dfsan-based fuzzerKostya Serebryany
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@236657 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-12Make check_custom_wrappers.sh work on FreeBSDDimitry Andric
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234704 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-10Extend s{,n}printf custom wrappers to support '*' in the format specifiersLorenzo Martignoni
Differential Revision: http://reviews.llvm.org/D8966 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234633 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-10Split Mprotect into MmapNoAccess and MprotectNoAccess to be more portableTimur Iskhodzhanov
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234602 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09Revert r234477, "Differential Revision: http://reviews.llvm.org/D7249"Peter Collingbourne
Should unbreak fuzzer buildbot. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234542 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09Use WriteToFile instead of internal_write in non-POSIX codeTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234487 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09Introduce CloseFile to be used instead of internal_close on non-POSIXTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234481 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09Differential Revision: http://reviews.llvm.org/D7249Lorenzo Martignoni
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234477 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-23[libsanitizer] Fix OpenFile() usage in TSan and DFSan.Alexander Potapenko
This is a follow-up for r232936. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@232937 91177308-0d34-0410-b5e6-96231b3b80d8