summaryrefslogtreecommitdiff
path: root/lib/dfsan/dfsan.cc
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
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-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
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-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-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-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-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
2015-02-12[Sanitizer] Change InitializeFlags() signatures. NFC.Alexey Samsonov
These functions are always used to initialize singleton flags(), as well as other global data (common_flags()). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@228894 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-15[sanitizer] Flag parser rewrite.Evgeniy Stepanov
The new parser is a lot stricter about syntax, reports unrecognized flags, and will make it easier to implemented some of the planned features. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226169 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12[dfsan] Export dfsan_get_label_info function with C linkage.Peter Collingbourne
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225692 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-07[Sanitizer] Change the runtime flag representation.Alexey Samsonov
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225327 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-05[DFSAN][MIPS] adding support of DFSAN for MIPS64Peter Collingbourne
Minor changes to enable DFSAN on MIPS64 Patch by Kumar Sukhani! Differential Revision: http://reviews.llvm.org/D6437 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@223517 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-20[DFSan] Add flag to dump the labels when the program terminates.Lorenzo Martignoni
Differential Revision: http://reviews.llvm.org/D6306 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@222425 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-05[dfsan] Add runtime function for aborting on indirect calls toPeter Collingbourne
uninstrumented vararg functions. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@221364 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-19DFSan's set label function should avoid writing to the shadow memory when ↵Peter Collingbourne
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@215961 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-26[DFSan] Fixup for r213980Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@213997 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-25[Sanitizer] Introduce SANITIZER_CAN_USE_PREINIT_ARRAY definition and use it ↵Alexey Samsonov
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@213980 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-26Add function to get the number of DFSan labels allocated.Peter Collingbourne
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204854 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-20[libsanitizer] Introduce flag descriptions.Alexander Potapenko
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204339 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-04[DFSan] Change the way labels are propagated when comparing memory through ↵Lorenzo Martignoni
libc functions. Differential Revision: http://llvm-reviews.chandlerc.com/D2252 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@196388 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-17[DFSan] Don't include public headers in dfsan runtime codeAlexey Samsonov
Summary: Definitions we use in public sanitizer headers may slightly conflict with the ones we use in private sanitizer runtimes. Moreover, we generally forbid to include any system headers (like <stdint.h>) in sanitizer runtime headers. This leads to inevitable duplication of selected interface function declarations, but we decided to live with it. Reviewers: pcc Reviewed By: pcc CC: kcc, llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2179 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@194955 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-10[dfsan] Initial set of DFSAN_OPTIONS flags.Peter Collingbourne
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190379 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-15[dfsan] Initial set of custom functions and interceptors for libc.Peter Collingbourne
Differential Revision: http://llvm-reviews.chandlerc.com/D1397 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@188490 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-15[dfsan] Runtime support for -dfsan-debug-nonzero-labels feature.Peter Collingbourne
Reviewers: eugenis CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1406 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@188471 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-14[dfsan] New __dfsan_set_label runtime function.Peter Collingbourne
Differential Revision: http://llvm-reviews.chandlerc.com/D1396 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@188411 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-14[dfsan] Runtime support for ABI list functionality; can now run integration ↵Peter Collingbourne
tests with args ABI. Differential Revision: http://llvm-reviews.chandlerc.com/D1351 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@188401 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-13[dfsan] Introduce dfsan_read_label runtime function.Peter Collingbourne
Differential Revision: http://llvm-reviews.chandlerc.com/D1349 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@188319 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-13[dfsan] Remove the unused __dfsan_memcpy function.Peter Collingbourne
Differential Revision: http://llvm-reviews.chandlerc.com/D1350 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@188238 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-12[dfsan] Begin a private header and move shadow_for there.Peter Collingbourne
Differential Revision: http://llvm-reviews.chandlerc.com/D1348 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@188231 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-12[dfsan] Introduce dfsan_union runtime function.Peter Collingbourne
Differential Revision: http://llvm-reviews.chandlerc.com/D1347 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@188229 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-07DataFlowSanitizer; compiler-rt changes.Peter Collingbourne
DataFlowSanitizer is a generalised dynamic data flow analysis. Unlike other Sanitizer tools, this tool is not designed to detect a specific class of bugs on its own. Instead, it provides a generic dynamic data flow analysis framework to be used by clients to help detect application-specific issues within their own code. Differential Revision: http://llvm-reviews.chandlerc.com/D967 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@187924 91177308-0d34-0410-b5e6-96231b3b80d8