Commit Graph

301 Commits

Author SHA1 Message Date
Kostya Serebryany 712fc9803a [sanitizer] Initial implementation of a Hardened Allocator
Summary:
This is an initial implementation of a Hardened Allocator based on Sanitizer Common's CombinedAllocator.
It aims at mitigating heap based vulnerabilities by adding several features to the base allocator, while staying relatively fast.
The following were implemented:
- additional consistency checks on the allocation function parameters and on the heap chunks;
- use of checksum protected chunk header, to detect corruption;
- randomness to the allocator base;
- delayed freelist (quarantine), to mitigate use after free and overall determinism.
Additional mitigations are in the works.

Reviewers: eugenis, aizatsky, pcc, krasin, vitalybuka, glider, dvyukov, kcc

Subscribers: kubabrecka, filcab, llvm-commits

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

llvm-svn: 271968
2016-06-07 01:20:26 +00:00
Chris Bieneman c0d89826a7 [CMake] Support constructing output paths from LLVM variables
This tweak to constructing output paths allows compiler-rt to use LLVM
output variables if they are set regardless of whether or not the build
is in-tree.

llvm-svn: 271749
2016-06-03 23:15:04 +00:00
Chris Bieneman 648d3bc8c7 [CMake] detect_target_arch needs to be moved to Utils
This macro is called from the base config, so it can't live in config-ix, it needs to be in the utils. I suspect the only reason this hasn't caused problems is that nobody is building the Android builtins from the builtins subdirectory.

llvm-svn: 271693
2016-06-03 17:34:02 +00:00
Etienne Bergeron 00f3f6e296 This patch is activating the build of Asan on Windows 64-bits.
It's fixing compilation errors. The runtime is not yet working.

Missing features:

OverrideFunction for x64
an equiv function for inline asm (atomic_compare_exchange_strong)
shadow memory offset needs to be adjusted
RoundUpToInstrBoundary for x64
They will be implemented by subsequent patches.

Patch by Wei Wang.

Differential revision: http://reviews.llvm.org/D20455

llvm-svn: 271049
2016-05-27 21:29:31 +00:00
Kuba Brecka 6d8873b8bc [sanitizer] Fix a typo in config-ix.cmake causing all Darwin embedded platforms to be built with the 'iossim' SDK.
llvm-svn: 270840
2016-05-26 11:18:22 +00:00
Etienne Bergeron 3df2879232 [compiler-rt] Fix multi-configuration output paths
Summary:
When using a multi-configuration build (i.e. MSVC) the output path where
libraries are dropped is incorrect.

Example:
```
C:\src\llvm\examples>d:\src\llvm\build\Release\bin\clang-cl.exe -fsanitize=address test.cc
LINK : fatal error LNK1181: cannot open input file 'd:\src\llvm\build\Release\bin\..\lib\clang\3.9.0\lib\windows\clang_rt.asan-i386.lib'
```

The dropped executable path contains the configuration 'Release':
```
'd:\src\llvm\build\Release\bin\..\lib\clang\3.9.0\lib\windows\Release\clang_rt.asan-i386.lib'
```


The variable 'RUNTIME_OUTPUT_DIRECTORY' is used to specify the output directory.
But CMAKE is appending the current configuration (i.e. Debug, Release).

see: https://cmake.org/cmake/help/v3.0/prop_tgt/RUNTIME_OUTPUT_DIRECTORY.html
```
"Multi-configuration generators (VS, Xcode) append a per-configuration subdirectory to the specified directory."
```

To avoid this problem, the configuration specific variable must be set:
'RUNTIME_OUTPUT_DIRECTORY_DEBUG', 'RUNTIME_OUTPUT_DIRECTORY_RELEASE', and so on.

Reviewers: ddunbar, chapuni, rnk

Subscribers: kubabrecka, llvm-commits

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

llvm-svn: 269658
2016-05-16 14:58:07 +00:00
Marcin Koscielnicki bcbba8caed Revert "[MSan] Enable on PowerPC64."
This reverts commit r269522.

This broke dtls_test.c on ppc64le buildbots.

llvm-svn: 269532
2016-05-14 02:17:38 +00:00
Marcin Koscielnicki c4743ff313 [MSan] Enable on PowerPC64.
Differential Revision: http://reviews.llvm.org/D20001

llvm-svn: 269522
2016-05-14 00:18:02 +00:00
Chris Bieneman 1455de2171 [CMake] Cache check results and avoid duplicate checks
This caches the result of builtin_check_c_compiler_flag, and removes a duplicate check for C99 flag support.

llvm-svn: 269230
2016-05-11 20:37:43 +00:00
Chris Bieneman c49e5e336b [CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.

This patch contains the following specific changes:

* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration

I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.

This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.

Reviewers: samsonov, iains, jroelofs

Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits

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

llvm-svn: 268977
2016-05-09 21:45:52 +00:00
Chris Bieneman aa3d2c13bf [CMake] NFC. Add support for testing the compiler without testing the linker
Summary:
One of the big limitations we have in the compiler-rt build system today is that we cannot bootstrap building the builtins because you need a fully functional toolchain to pass CMake's tests.

This change adds support for compile only tests.

It is NFC because nothing is using the compile-only tests yet.

I believe this is the last separable part of D16653.

Reviewers: samsonov

Subscribers: llvm-commits

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

llvm-svn: 268427
2016-05-03 19:48:11 +00:00
Chris Bieneman 257fe3ab99 [CMake] Adding another missing include. NFC.
This also works fine today, but will break with my upcoming refactoring.

llvm-svn: 267941
2016-04-28 21:16:45 +00:00
Chris Bieneman 551ccac7e4 [CMake] Updating Apple CMake cache file
Changing the Apple CMake cache file to better match the way Apple Clang builds are built.

llvm-svn: 267913
2016-04-28 18:24:29 +00:00
Chris Bieneman 1dd58a7018 [CMake] Adding some missing CMake includes. NFC.
This happens to be working now because the includes exist in another CMake file that is included before this one. That will change with upcoming refactoring.

llvm-svn: 267912
2016-04-28 18:22:01 +00:00
Mohit K. Bhakkad 3ad70b4b5b [Compiler-rt][CFI] Enabling CFI for MIPS64
Reviewers: eugenis

Subscribers: jaydeep, sagar, Sanitizers

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

llvm-svn: 267674
2016-04-27 05:49:42 +00:00
Chris Bieneman 380ebd0b2c [CMake] [PR27403] Fix COMPILER_RT_ENABLE_IOS when using Xcode from the App Store.
This change modifies find_darwin_sdk_dir to set a variable if a Darwin "Internal" SDK is present which allows CMake to disable components that require internal-only APIs.

This mechanism is then used to disable TSan when an internal SDK is not present.

llvm-svn: 267575
2016-04-26 17:53:25 +00:00
Derek Bruening af7aaae1bc [esan] EfficiencySanitizer base runtime library
Summary:
Adds the initial version of a runtime library for the new
EfficiencySanitizer ("esan") family of tools.  The library includes:

+ Slowpath code via callouts from the compiler instrumentation for
  each memory access.

+ Registration of atexit() to call finalization code.

+ Runtime option flags controlled by the environment variable
  ESAN_OPTIONS.  The common sanitizer flags are supported such as
  verbosity and log_path.

+ An initial simple test.

Still TODO: common code for libc interceptors and shadow memory mapping,
and tool-specific code for shadow state updating.

Reviewers: eugenis, vitalybuka, aizatsky, filcab

Subscribers: filcab, vkalintiris, kubabrecka, llvm-commits, zhaoqin, kcc

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

llvm-svn: 267060
2016-04-21 21:32:25 +00:00
Marcin Koscielnicki b5e4804aee [sanitizer] [SystemZ] Enable UBSan.
sanitizer_common is now in good enough shape on s390x to support UBSan
- all tests passing.  Let's enable it.

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

llvm-svn: 266483
2016-04-15 22:25:04 +00:00
Sean Silva 3e85ddc011 Use `CMAKE_HOST_UNIX` to check the host.
`UNIX` is for the target.

llvm-svn: 265595
2016-04-06 20:19:31 +00:00
Chris Bieneman 17bcc439d6 [CMake] Provide the ability to skip stripping when generating dSYMs
For debugging it is useful to be able to generate dSYM files but not strip the executables. This change adds the ability to skip stripping by setting COMPILER_RT_EXTERNALIZE_DEBUGINFO_SKIP_STRIP=On.

llvm-svn: 265057
2016-03-31 21:17:19 +00:00
Reid Kleckner 747dc2eb61 [cmake] Get the MSVC version by running cl rather than relying on MSVC_VERSION
MSVC_VERSION comes from the _MSC_VER macro, which won't correspond to
the STL version if the host compiler is clang-cl.

llvm-svn: 264901
2016-03-30 18:31:14 +00:00
Reid Kleckner f2be78c07e Move -fms-compatibility-version=19 into target cflags
This reduces cflags duplication and allows us to build
sanitizer_common/tests with clang and the VS 2015 STL.

llvm-svn: 264017
2016-03-22 01:14:36 +00:00
Devin Coughlin 7704720d41 [tsan] Build TSan dylibs for iOS-style simulators
Update the compiler-rt cmake to build TSan dylibs for iOS-style simulators when the
corresponding COMPILER_RT_ENABLE_FOO_OS setting is enabled.

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

Part of rdar://problem/24048382

llvm-svn: 263910
2016-03-20 17:35:45 +00:00
Alexey Samsonov 5c966a2063 [CMake] Remove bash-ism in SanitizerLintCheck
llvm-svn: 263751
2016-03-17 21:41:08 +00:00
Filipe Cabecinhas b08c76f5f8 [cmake] Address Samsonov's post-commit review of r262723
Reviewers: samsonov

Subscribers: llvm-commits

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

llvm-svn: 262770
2016-03-05 10:01:04 +00:00
Mohit K. Bhakkad b87b2ecb4b [Compiler-rt][safestack] Enable for MIPS
Reviewers: samsonov

Subscribers: jaydeep, sagar, llvm-commits

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

llvm-svn: 262690
2016-03-04 06:15:59 +00:00
Alexey Samsonov 2eff7f788a [CMake] Fix a typo in add_compiler_rt_library.
llvm-svn: 262063
2016-02-26 20:59:40 +00:00
Chris Bieneman 497a0ac23f [CMake] Support component-based installation for runtime libraries
This enables targets like "install-ubsan" and "install-asan" to install all associated runtime libraries.

llvm-svn: 261700
2016-02-23 21:55:38 +00:00
Chris Bieneman 86792ea718 [CMake] Assign components and dependencies during add_compiler_rt_resource_file
This makes it so that component-based installations will include resource files (i.e. blacklists). My next patch will add support for component-based installations.

llvm-svn: 261699
2016-02-23 21:50:39 +00:00
Chris Bieneman 953d593cd7 [CMake] Adding a CMake cache file that matches Apple's build configs
This should have no impact on anyone, but we're going to use it from GreenDragon to make our builders match what we ship.

llvm-svn: 261377
2016-02-19 22:59:18 +00:00
Chris Bieneman 5a5b21d5be [CMake] [NFC] Move macro definitions out of config-ix.cmake
This change should have no functional impact, it just moves some macro definitions out of config-ix.cmake into CompilerRTUtils.cmake.

This step will allow these macros to be re-used by the separated builtin build.

llvm-svn: 261108
2016-02-17 16:57:38 +00:00
Chris Bieneman a58d0651cb [CMake] Push the dependency on AddLLVM into the test and unites layers
Compiler-rt only relies on LLVM for lit support. Pushing this dependency down into the test and unitest layers will allow builtin libraries to be built without LLVM.

llvm-svn: 261105
2016-02-17 16:38:54 +00:00
Alexey Samsonov e34c8e8f8a [TSan] Use darwin_filter_host_arch to restrict set of test arch on Mac OS.
This also reverts r259577 which was a quick-fix to fix buildbots.

llvm-svn: 259593
2016-02-02 22:42:25 +00:00
Daniel Sanders f3eb90743c [tsan] Disable x86_64h build that was enabled as part of r259542.
It fails almost every test on clang-stage1-cmake-RA_check.

llvm-svn: 259577
2016-02-02 21:41:17 +00:00
Daniel Sanders 440b8610e6 [compiler-rt] add_custom_libcxx should pass LLVM_PATH and a C++ compiler
Reviewers: samsonov

Subscribers: llvm-commits

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

llvm-svn: 259493
2016-02-02 12:55:28 +00:00
Anna Zaks c77a080bdb [asan] Add iOS support.
llvm-svn: 259451
2016-02-02 02:01:17 +00:00
Alexey Samsonov a7be03d66b [CMake] Use LLVM_MAIN_SRC_DIR instead of LLVM_SOURCE_DIR.
The former will be properly initialized in standalone CMake build of
compiler-rt.

llvm-svn: 259407
2016-02-01 21:08:16 +00:00
Daniel Sanders de098c9767 [compiler-rt] list_union() is actually an intersect operation. Rename it.
Summary:
Given:
  set(T1 a b c)
  set(T2 b c d)
  message("T1=${T1}")
  message("T2=${T2}")
  list_union(T3 T1 T2)
  message("T3=${T3}")
cmake emitted:
  T1=a;b;c
  T2=b;c;d
  T3=b;c

Reviewers: beanz

Subscribers: llvm-commits

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

llvm-svn: 258916
2016-01-27 09:28:01 +00:00
Nico Weber 6a4e0dd1a6 When building without DIA SDK, don't set suppressions.cpp fail
This test requires llvm-symbolizer to be able to convert a stack
address into a function name.  It is only able to do this if the
DIA SDK was found at cmake time.  Add a lit feature for this,
and let the test depend on it.

See also discussion in D15363.

llvm-svn: 258545
2016-01-22 20:26:10 +00:00
Sumanth Gundapaneni b76bf106b1 Fix the cross compilation of unit tests. NFC (second attempt)
With COMPILER_RT_INCLUDE_TESTS turned ON and in a cross compiling
environment, the unit tests fail to link. This patch does the following changes

>Rename COMPILER_RT_TEST_CFLAGS to COMPILER_RT_UNITTEST_CFLAGS to reflect the 
way it's used.
>Add COMPILER_RT_TEST_COMPILER_CFLAGS to COMPILER_RT_UNITTEST_CFLAGS so 
that cross-compiler would be able to build/compile the unit tests
>Add COMPILER_RT_UNITTEST_LINKFLAGS to COMPILER_RT_UNITTEST_CFLAGS so 
that cross-compiler would be able to link the unit tests (if needed)

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

llvm-svn: 257783
2016-01-14 18:18:49 +00:00
Hans Wennborg 7b9d2b6c87 Revert r257686 "With COMPILER_RT_INCLUDE_TESTS turned ON and in a cross compiling"
This broke the build. For example, from
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/1191/steps/cmake%20stage%201/logs/stdio:

	-- Compiler-RT supported architectures: aarch64
	CMake Error at projects/compiler-rt/cmake/Modules/AddCompilerRT.cmake:170 (string):
		string sub-command REPLACE requires at least four arguments.
	Call Stack (most recent call first):
		projects/compiler-rt/lib/CMakeLists.txt:4 (include)

llvm-svn: 257694
2016-01-13 22:50:24 +00:00
Sumanth Gundapaneni 2d2f2b5c80 With COMPILER_RT_INCLUDE_TESTS turned ON and in a cross compiling
environment, the unit tests fail to link. This patch does the following changes

>Rename COMPILER_RT_TEST_CFLAGS to COMPILER_RT_UNITTEST_CFLAGS to reflect the 
way it's used.
>Add COMPILER_RT_TEST_COMPILER_CFLAGS to COMPILER_RT_UNITTEST_CFLAGS so that 
cross-compiler would be able to build/compile the unit tests
>Add COMPILER_RT_UNITTEST_LINKFLAGS to COMPILER_RT_UNITTEST_CFLAGS so that 
cross-compiler would be able to link the unit tests (if needed)

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

llvm-svn: 257686
2016-01-13 22:09:47 +00:00
Dan Gohman 746cd84e3c [WebAssembly] Enable the builtins library for WebAssembly.
llvm-svn: 257619
2016-01-13 16:56:15 +00:00
Chris Bieneman 1a4ae60f5a [CMake] Adding experimental support for tvOS and watchOS
Summary:
* Refactored the iOS config-ix.cmake code to be a more compact loop over supported embedded platforms.
* Added watchOS and tvOS as experimental platforms, they don't currently build so they are disabled by default

Reviewers: zaks.anna, kubabrecka, samsonov

Subscribers: llvm-commits

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

llvm-svn: 257544
2016-01-12 23:51:03 +00:00
Vedant Kumar b626231a50 [cmake] Indentation fix (NFC)
llvm-svn: 257118
2016-01-08 00:07:50 +00:00
Vedant Kumar c5b779cb92 [cmake] Add InstrProfilingWriter to libclang_rt on Darwin
llvmBufferWriter and a few related symbols were missing from libclang_rt
on Darwin (PR26002). This should fix the problem.

Patch by Dan Peebles!

llvm-svn: 257110
2016-01-07 22:54:46 +00:00
Anna Zaks ef9a56faa0 [compiler-rt] On Darwin, link all frameworks with -fapplication-extension
The ASan dylib as well as other compiler-rt dylibs work with app extensions,
so we should add -fapplication-extension to the link line when building them.
This will avoid linker warnings when using the dylibs in app extensions.

(APIs unavailable to app extensions are listed here: https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/ExtensionOverview.html#//apple_ref/doc/uid/TP40014214-CH2-SW6)

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

llvm-svn: 256989
2016-01-06 23:15:04 +00:00
Nathan Slingerland ba86c9279b [PGO] Enable building compiler-rt profile support library on Windows
Summary: This change configures Windows builds to build the complier-rt profile support library (clang_rt.profile-i386.lib). Windows API incompatibilities in the compiler-rt profile lib are also fixed.

Reviewers: davidxl, dnovillo

Subscribers: llvm-commits

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

llvm-svn: 256848
2016-01-05 17:27:01 +00:00
Evgeniy Stepanov da1cf9287c Cross-DSO control flow integrity (compiler-rt part).
This is an initial version of the runtime cross-DSO CFI support
library.

It contains a number of FIXMEs, ex. it does not support the
diagnostic mode nor dlopen/dlclose, but it works and can be tested.
Diagnostic mode, in particular, would require some refactoring (we'd
like to gather all CFI hooks in the UBSan library into one function
so that we could easier pass the diagnostic information down to
__cfi_check). It will be implemented later.

Once the diagnostic mode is in, I plan to create a second test
configuration to run all existing tests in both modes. For now, this
patch includes only a few new cross-DSO tests.

llvm-svn: 255695
2015-12-15 23:00:33 +00:00
Adhemerval Zanella eaf1162687 [compiler-rt] [safestack] Enable for aarch64
This patch enables the safestack for aarch64. The frontend already have
it enabled on all supported architectures and no adjustment is required
in llvm.

The compiler-rt adjustments are basically add on the cmake configuration
to enable the tests and fix the pagesize debug check by getting its
value at runtime (since aarch64 has multiple pagesize depending of
kernel configuration).

llvm-svn: 255345
2015-12-11 17:38:38 +00:00