Commit graph

388 commits

Author SHA1 Message Date
Trevor Radcliffe
391a25d7fa Supporting changes for CFI toolchain features
Mostly exporting variables to Bazel, but also allowlisting a BUILD
file.

Bug: 251217226
Test: Unit tests
Change-Id: Id87015a3cd5d970700c4058ec989bb0c14c36bcb
2023-03-27 18:07:40 +00:00
Colin Cross
b781d23575 Use static asan runtime for musl
Use static asan runtimes for musl binaries to match glibc binaries.
The static asan runtime also requires libclang_rt.asan_cxx.a.  Unlike
most other runtimes the asan runtimes need to expose the symbols
from the runtime to allow intercepting calls to malloc, new etc.

Test: m USE_HOST_MUSL=true aidl_unittests && out/host/linux-x86/testcases/aidl_unittests/x86_64/aidl_unittests
Test: sanitize_test.go
Change-Id: I93da03b1c447fbb01f37262e7a465f165c2d5a18
2023-03-22 12:58:39 -07:00
Colin Cross
e323a793e2 Simplify depending on static sanitizer runtimes
The dependencies on static runtimes are getting compilicated, as they
vary on whether or not they should hide or export symbols from the
runtime.  Instead of setting flags to try to add the right static
runtime later, add them as dependencies immediately with a call to
addStaticDeps.

Test: sanitize_test.go
Change-Id: I5fb3ee29b31ce99d8feac262fcf71d19396dc68d
2023-03-22 12:58:38 -07:00
Elliott Hughes
c214e1ab8a Merge "Allow SCS for riscv64 too." 2023-03-21 22:10:56 +00:00
Florian Mayer
25cd981362 Revert "Re-enable stack frame size errors"
Reason for revert: b/274474681

Change-Id: If4f1eda6a82ce715d8e492292b5c62eb3f5a201f
2023-03-21 17:25:10 +00:00
Florian Mayer
b0c9dd777e Re-enable stack frame size errors
Bug: 229654778
Change-Id: Ib7d0ef98577adbd69b98cac450d3727ab1fdec81
2023-03-14 23:46:15 +00:00
Florian Mayer
1866bbe0d2 Increase BB to explore for reachability analysis
We pass mcpu=cortex-a55 for our build, which increases BB to the point
where the LLVM default of 32 is not enough.

I ran a fullmte build and did not see any slowdown.

Bug: 229654778
Change-Id: Ifbd1e5427101b2f2f39c067ba3ea4d5cb4a3ba0d
2023-03-14 23:45:39 +00:00
Cole Faust
18994c73f1 Replace SortedStringKeys with SortedKeys
Now that we have generics.

Bug: 193460475
Test: presubmits
Change-Id: I1594fd8feb505175d5c09c03ef397e5ffd5b09cb
2023-02-28 16:51:32 -08:00
Elliott Hughes
e4793bc73f Allow SCS for riscv64 too.
Bug: https://github.com/google/android-riscv64/issues/55
Test: treehugger
Change-Id: I319fc662c1dd6083757f78b8d91ec2775ef94a46
2023-02-10 01:53:17 +00:00
Christopher Ferris
2fc8e039ac HWAsan: Increase the malloc fill size.
To match the scudo allocator's always return zero allocation behavior,
set the max malloc fill size larger than the largest size class.
Currently, the largest is 65552, so set the max to 128KB to avoid
needing to change this in the future.

Test: Run test that verifies allocations returned are zero and it passes.
Change-Id: Ie9f0b0d54f846008b1c6d5dc6e55c7031262d29e
2023-01-26 14:19:27 -08:00
Trevor Radcliffe
4f95ee96b8 Export sanitizer vars for use in Bazel
Bug: 265154269
Test: Unit tests
Change-Id: I46584159264476d76079e396c6ec294fb394acff
2023-01-23 20:28:06 +00:00
Justin Yun
08270c6c2d Disable sanitizer for vendor_snapshot_object modules
vendor_snapshot_object modules do not provide sanitizers.
Avoid sanitizer mutation for these modules.

Bug: 234772527
Test: build against the vsdk with SANITIZE_TARGET=hwaddress
Change-Id: Ib4fe4def673aa77a4321f47c09393adcb2fa2964
2022-12-19 23:04:08 +09:00
Justin Yun
8814fc5c20 VSDK: capture hwasan static libs for vsdk snapshot build
When generating vsdk snapshot with SANITIZE_TARGET=hwaddress option,
include hwasan static libraries to the vendor snapshot.

Bug: 234772527
Test: build against the vsdk with SANITIZE_TARGET=hwaddress
Change-Id: I6fdecefaa8557b5c968745487a3ed7c959e682f9
2022-12-19 17:18:22 +09:00
Treehugger Robot
a8ad378abc Merge "Remove workaround for -fexceptions and stack MTE" 2022-12-02 00:52:41 +00:00
Treehugger Robot
6721ab5d40 Merge "Allow hwasan variant for vendor_snapshot_static modules" 2022-12-02 00:27:22 +00:00
Florian Mayer
06aca9b448 Remove workaround for -fexceptions and stack MTE
The upstream change was merged in https://r.android.com/2322236

Bug: 174878242
Change-Id: Ia23d4a9d6ef54ed2c286e0b1becec1f35df75160
2022-12-01 14:23:23 -08:00
Justin Yun
39c303116a Allow hwasan variant for vendor_snapshot_static modules
vendor_snapshot_static modules can define hwasan variant as below:

vendor_snapshot_static {
    name: "libsnapshot",
    vendor: true,
    version: "33",
    arch: {
        arm64: {
            src: "libsnapshot.a",
            hwasan: {
                src: "libsnapshot.hwasan.a",
            },
        },
    },
}

Bug: 234772527
Test: m nothing
Change-Id: I0725028a4fdc302005d86f1e36561b98c0af623b
2022-11-24 17:51:08 +09:00
Liz Kammer
2c1d6aae37 Update sanitize to not modify user properties
Test: m nothing before/after and compare build.ninja (no diff)
Change-Id: Ia165e4beea0b34417f873247b592837a152d45cd
2022-11-22 13:14:39 -05:00
Liz Kammer
fd8a49fb9d Limit propagating san config of shared to fuzzer
Prior to refactoring the sanitizers to use transition mutators, only
fuzzer sanitizer propagated configuration to shared dependencies
https://android-review.googlesource.com/c/platform/build/soong/+/2123434/9/cc/sanitize.go#b1365
However, this expanded to include TSAN in the refactoring
https://android-review.googlesource.com/c/platform/build/soong/+/2123434/9/cc/sanitize.go#1068.

Fortunately, TSAN is never enabled via Android.bp files in AOSP, so
there was no regression, but we should restore to the prevous state.

Test: go tests
Change-Id: I1a5ad8d033f7a9b4f7578393a2eac7c9362ab6f7
2022-11-22 11:46:32 -05:00
Treehugger Robot
26e62c8d74 Merge "Set -fno-emulated-tls for riscv64" 2022-10-21 03:31:38 +00:00
Colin Cross
e127b4d060 Merge "Disable LTO and CFI for riscv64" 2022-10-20 23:47:54 +00:00
Colin Cross
7c376043e0 Merge "Use static libclang_rt.ubsan_standalone runtime for musl" 2022-10-20 21:53:58 +00:00
Colin Cross
2c435a00ff Set -fno-emulated-tls for riscv64
Building for riscv64 fails with link errors on __thread variables.
Set -fno-emulated-tls to fix it.

Bug: 254713216
Test: lunch aosp_riscv64-userdebug && m ALLOW_MISSING_DEPENDENCIES=true ndk_sysroot
Change-Id: I3dca81dfd277d681b6c868a5e8385e3a37335a5f
2022-10-20 14:31:24 -07:00
Colin Cross
ecf4e664e0 Disable LTO and CFI for riscv64
Building with LTO and CFI enabled for riscv64 causes link failures:
ld.lld: error: lto.tmp: cannot link object files with different floating-point ABI
ld.lld: error: undefined symbol: guard variable for android::hardware::BufferedTextOutput::getBuffer() const::ts

Disable them for now.

Test: lunch aosp_riscv64-userdebug && m ALLOW_MISSING_DEPENDENCIES=true ndk_sysroot
Change-Id: I3489952abebeeb3f4de664fd3e436232aac298d7
2022-10-20 13:59:58 -07:00
Colin Cross
e725b4e5e0 Use static libclang_rt.ubsan_standalone runtime for musl
Using a dynamic libclang_rt.ubsan_standalone runtime causes
problems when dalvikvm dlopen's libart.so:
JniInvocation E 10-19 18:25:55 1159447 1159447] Failed to dlopen libart.so: Error relocating /mnt/disks/build-disk/src/android/master/out/host/linux-x86/lib64/libclang_rt.ubsan_standalone-x86_64.so: (null): initial-exec TLS resolves to dynamic definition in /mnt/disks/build-disk/src/android/master/out/host/linux-x86/lib64/libclang_rt.ubsan_standalone-x86_64.so

This seems to be caused by a thread local variable with an
explicit initial-exec TLS model in libclang_rt.ubsan_standalone,
which is then rejected by musl's dynamic loader.  Switching to
a static libclang_rt.ubsan_standalone matches what we are doing
for glibc and fixes musl.

Bug: 190084016
Test: m USE_HOST_MUSL=true out/target/common/obj/JAVA_LIBRARIES/ahat-test-dump_intermediates/test-dump-base.hprof
Change-Id: I3e50eae6c22b684fc7bb0ccdfe0379f41d246319
2022-10-20 19:45:53 +00:00
Florian Mayer
7410d28356 [MTE] temporarily disable memtag-stack with exceptions
unwinding through tagged frames is fixed in upstream and cherry-picked
onto Android toolchain in https://r.android.com/2251926. until then, we
can disable stack tagging for code that uses exception, so we can get
some coverage before the toolchain update.

Test: stack_tagging_helper exception_cleanup from https://r.android.com/2175188
      fails with assertion "GetTag(&y) !=
      GetTag(__builtin_frame_address(0))" as expected
Bug: 174878242
Change-Id: I1597b21f64a92874dbccb64ffebbef7bb9bf8214
2022-10-20 11:17:42 -07:00
Florian Mayer
cc9b675f4d Revert "Disable HWASan if UBSan is enabled"
This reverts commit bb158a34c3.

Reason for revert: b/253035046

Change-Id: Id0fc9251283a7fba2eee5e18aecb16ddf80c6253
2022-10-12 19:09:02 +00:00
Florian Mayer
bb158a34c3 Disable HWASan if UBSan is enabled
Test: `atest inputflinger_tests libinput_tests` does not crash
Bug: 251249010
Change-Id: Ic6bab1d2361ecfbad038acf9f124d4b9d4cee6d1
2022-10-10 17:11:30 -07:00
Florian Mayer
1bda246235 [MTE] unset colliding sanitizers for mutators
Bug: 174878242
Test: m device-tests with SANITIZE_TARGET=memtag_stack
Change-Id: Ia8659a90c6c1efd9109324e6c46748b434cbfd24
2022-09-29 15:49:46 -07:00
Florian Mayer
f79b210ddf [memtag-stack] work around stack limit in lld
Change-Id: Iee4a5ba9f9789f684d78e232078e36898e0c16d9
2022-09-09 14:24:11 -07:00
Florian Mayer
1e4f899c1d Work around stack frame size for memtag-stack
The root cause for the warning is fixed in upstream LLVM
(https://reviews.llvm.org/D127917) , working around until
that is submitted.

Test: make libc with memtag-stack
Bug: 174878242
Change-Id: Iae8c85f39bdceb9752b7f2758c5543c1b3f90277
2022-09-08 23:59:23 +00:00
Florian Mayer
d8434a4f3d Revert "Revert "[soong] Add memtag-stack sanitizer, switch to li..."
Revert submission 2201105-revert-2096883-memtag-stack-IGUQFVKYTS

Reason for revert: Reland with fix
Reverted Changes:
I0dac2a6a6:Revert "memtag_stack tests."
I3967151d9:Revert "[soong] Add memtag-stack sanitizer, switch...

Change-Id: Ib827fb8d48192f9e2accc97931e272f713d6cbd0
2022-08-31 15:20:25 -07:00
Florian Mayer
00ab5cfd5e Revert "[soong] Add memtag-stack sanitizer, switch to linker-gen..."
Revert submission 2096883-memtag-stack

Reason for revert: b/244454542
Reverted Changes:
I7fee03d90:memtag_stack tests.
I52d2318c8:[soong] Add memtag-stack sanitizer, switch to link...

Change-Id: I3967151d98514fa07f66804aa8ff403df3962fa3
2022-08-31 18:30:18 +00:00
Evgenii Stepanov
807573d135 [soong] Add memtag-stack sanitizer, switch to linker-generated notes.
This change depends on the following toolchain commit:
https://reviews.llvm.org/D118948

Bug: b/174878242
Test: sanitize_test.go
Test: fvp_mini with SANITIZE_TARGET=memtag_heap,memtag_stack

Change-Id: I52d2318c8e4e06d6da5b74c45226144b880f1577
2022-08-30 21:37:03 +00:00
Colin Cross
6c18d004f2 Pass -fno-sanitize=vptr,function for musl
The prebuilts for musl have the necessary symbols for vptr and function
sanitizers, but enabling them implicitly enables RTTI which causes RTTI
mismatch issues with dependencies.

Bug: 215802826
Test: m USE_HOST_MUSL=true host-native
Change-Id: I93edfd617d99efcac0eca58bb3f3c173c4fa121a
2022-07-01 02:58:25 +00:00
Colin Cross
88a029f710 Reland: Don't use hwasan for non-bionic arm64 targets
Don't use hwasan for non-bionic arm64 targets, including
arm64-linux-musl and arm64 darwin.

This relands I67c07f26f25a9f9807ee21ee79c113ea11f65473 which was
accidentally reverted in I47a9322929baff2492c6e8db989ece01fcbeb133.

Bug: 236052820
Test: build arm64 musl sysroot
Change-Id: I77753ecb6f07aafa1b6e00ad6bf432f9c9744f79
2022-06-28 15:15:40 -07:00
Colin Cross
2bce04f76f Merge "Add linux_musl arm+arm64" 2022-06-27 18:37:07 +00:00
Colin Cross
a9b2aacf07 Add linux_musl arm+arm64
Add toolchains to support cross compiling to aarch64-linux-musl and
arm-linux-musleabihf.

Bug: 236052820
Test: build arm and arm64 musl sysroots
Change-Id: I47a9322929baff2492c6e8db989ece01fcbeb133
2022-06-24 13:46:36 -07:00
Evgenii Stepanov
59012814a6 Revert "Revert "Keep minimal abort when enabling integer overflow check""
This reverts commit c480fbc5ef.

When cherry-picking this change to a branch, make sure that the target:
* either DOES NOT include
  https://android-review.googlesource.com/c/platform/build/soong/+/1980451/
* or includes
  https://android-review.googlesource.com/c/platform/build/soong/+/2130354/

Bug: b/235090315
Bug: b/235181175
Bug: b/233840743
Test: libcutils.so (in symbols) includes more than 0 and less than 10 functions
      with __ubsan_handle in the name, and does not export any.

Change-Id: I4f30b5814b5460468004efcc543cc681ad0022dc
2022-06-24 13:21:40 -07:00
Treehugger Robot
44c20b886f Merge "Don't use hwasan for non-bionic arm64 targets" 2022-06-23 23:51:00 +00:00
Colin Cross
438bd4af48 Don't use hwasan for non-bionic arm64 targets
Don't use hwasan for non-bionic arm64 targets, including
arm64-linux-musl and arm64 darwin.

Bug: 236052820
Test: build arm64 musl sysroot
Change-Id: I67c07f26f25a9f9807ee21ee79c113ea11f65473
2022-06-23 14:53:52 -07:00
Lukács T. Berki
5ad0185b63 Merge "Migrate sanitizers to transition mutators." 2022-06-18 19:26:55 +00:00
Lukacs T. Berki
6c71676d6c Migrate sanitizers to transition mutators.
The logic is not 100% provably the same since HEAD was quite
confusing at some points, but I did make an effort to preserve
functional equivalence.

In case that effort was not enough, it should be pretty easy to
tweak the logic at HEAD since it's still quite malleable.

Bug: 231370928
Test: Presubmits.
Change-Id: I17b2efbfb5c4d0aedd922caed54ff8d857e578df
2022-06-18 06:20:28 +02:00
Treehugger Robot
e11164351a Merge "Reland: Fix -Wl,--exclude-libs for clang runtime libraries" 2022-06-18 01:43:15 +00:00
Colin Cross
3e5e778969 Reland: Fix -Wl,--exclude-libs for clang runtime libraries
The sanitize code was assuming that the names of the clang runtime
library modules were the same as their static library output files,
but that's not true after I39e2cf8ae14edf8510276dab38011afaef85822c.
Use the dependency to get the name of the library to pass to
-Wl,--exclude-libs.

This relands If6ca7838800c76f90105fb02d39e8a68cec96314 with a fix
for skipping tests that don't work on mac.
   
Bug: 235624976
Test: TestUbsan
Change-Id: I32894d10d24473ad48b6afc5663f91fa48a6a0ba
2022-06-17 22:48:22 +00:00
Colin Cross
3bd8c1bb3e Merge "Revert "Fix -Wl,--exclude-libs for clang runtime libraries"" 2022-06-17 22:16:42 +00:00
Colin Cross
567d98346c Revert "Fix -Wl,--exclude-libs for clang runtime libraries"
This reverts commit 59de280a48.

Reason for revert: Broke mac tests
Bug: 235624976

Change-Id: I358bb14ec565f106483378f4798e3fc88c491f8f
2022-06-17 22:15:00 +00:00
Colin Cross
3650bd0a0f Merge "Fix -Wl,--exclude-libs for clang runtime libraries" 2022-06-17 22:03:08 +00:00
Lukacs T. Berki
01a648afa0 Restrict IsSanitizerEnabled() to android.Config().
Turns out, the whole context is not needed and then let's not
plumb it any further than necessary.

Test: Presubmits.
Change-Id: I1a25738e5a6ca20dea0d973c2ce435b5e152399b
2022-06-17 08:59:37 +02:00
Colin Cross
59de280a48 Fix -Wl,--exclude-libs for clang runtime libraries
THe sanitize code was assuming that the names of the clang runtime
library modules were the same as their static library output files,
but that's not true after I39e2cf8ae14edf8510276dab38011afaef85822c.
Use the dependency to get the name of the library to pass to
-Wl,--exclude-libs.

Bug: 235624976
Test: TestUbsan
Change-Id: If6ca7838800c76f90105fb02d39e8a68cec96314
2022-06-13 15:55:06 -07:00
Evgenii Stepanov
c480fbc5ef Revert "Keep minimal abort when enabling integer overflow check"
This reverts commit 34448f2430.

Reason for revert: RAM regression + something mainline related
Bug: b/235090315
Bug: b/235181175
Bug: b/233840743

Change-Id: Ia1d1b1428c19b1e297dc75618d640bdac81713b0
2022-06-10 19:47:26 +00:00
Hang Lu
34448f2430 Keep minimal abort when enabling integer overflow check
Cflag "-fsanitize-trap=all" will override "-fno-sanitize-trap=integer" if "-fsanitize-trap=all" is placed behind. Change the order to make minimal abort work, which will output the abort message to give user a better prompt.

Bug: 233840743
Test: "objdump -dS {CFI enabled so}" to check the instrumented abort instruction
Change-Id: Id85fa8ece3e13d1b21b4fdbf5f4b5124011890ca
2022-06-02 20:47:30 +08:00
Muhammad Haseeb Ahmad
e6567fe56b Make IsSanitizerEnabledForJni return false
Change-Id: I5e1722bc32b63649fc9973d11e9fd5bdea72ddbe
Test: m
2022-05-25 00:13:08 +00:00
Lukacs T. Berki
2da6c3cc86 Keep a "sanitizer dependency" flag for each sanitizer.
This is so that we can avoid mutating state in sanitizerMutator, as
would be necessary if we only had a single bit for every sanitizer
together.

Test: Presubmits.
Change-Id: I5576367c12972fbea64342ab123118ec5a2cfeec
2022-05-19 09:48:57 +02:00
Lukacs T. Berki
8c77ae369a Make java_fuzz_host not implement Sanitizeable.
Also remove a tiny bit of state mutation from sanitizerMutator. Every
little bit helps!

Test: Prebuilts + comparing soong/build.ninja .
 Your branch is up to date with 'aosp/master'.

Change-Id: I73b28b660b572610242765d87b70ab081b0b43df
2022-05-17 11:25:28 +02:00
Muhammad Haseeb Ahmad
7e74405b2d Add jni support to java_fuzz_host
Bug: 219782880
Test: m example_java_fuzzer_with_native_lib, go test -run TestJavaFuzz
Change-Id: I1d05fb449e5378a27a0096869d9c12ca0a1245c6
2022-04-26 18:49:02 +00:00
Colin Cross
ed12a04a3e Enable sanitizers for musl
Now that we provide runtimes built for musl, enable the sanitizers
when targeting musl.

Bug: 215802826
Test: m USE_HOST_MUSL=true host-native
Change-Id: Id17513ee305274874c31e9c99ce4faeff4a1c057
2022-03-29 13:35:17 -07:00
Mitch Phillips
597605603a [HWASan] Enable zero-initialization.
Previously, we use to fill memory with 0xbe bytes. This caused a lot of
problems that necessitated disablement. For example, 0xbe-filled mutexes
are apparently locked, and there were a few instances of
uninitialized-mutex use.

Given that zero-fill is now the default behaviour, enable zero-init in
HWASan as well.

For now, only fill the first page. It would be preferable to fill the
whole allocation, but I don't want to spin for too many cycles filling
huge secondary pages. In future, we might change the behaviour to have
an explicit "zero initialize" option that completely fills the primarily
allocations, and knows it's unnecessary for the secondary.

Bug: 226078464
Test: Boot w/ HWASan (done by presubmit robot)

Change-Id: I7de3a7f9fa2fdeb5116e5bf6586babe4d06fcb91
2022-03-22 18:38:34 +00:00
Treehugger Robot
5c8693f5d7 Merge "Revert "[cc_fuzz] Revert 'disable LTO' patches."" 2022-03-02 05:08:27 +00:00
Mitch Phillips
5007c4a06d Revert "[cc_fuzz] Revert 'disable LTO' patches."
Revert submission 1976512-revert-nolto-fuzzing

Reason for revert: b/222160662
Reverted Changes:
Iacee4fa29:[cc_fuzz] Revert 'disable LTO' patches.
Ic509b00a1:[cc_fuzz] Revert 'disable LTO' patches.
If85931f09:[cc_fuzz] Revert 'disable LTO' patches.

Change-Id: I84e01a4f84145e3331c2955836c8cc9bfa05c36b
2022-03-02 01:25:22 +00:00
Treehugger Robot
6c0de9938e Merge "[cc_fuzz] Revert 'disable LTO' patches." 2022-03-01 23:43:04 +00:00
Florian Mayer
939143a862 Merge "Reland^2 "Enable hwasan use after scope detection."" 2022-02-17 21:19:36 +00:00
Florian Mayer
0b981f54e6 Reland^2 "Enable hwasan use after scope detection."
This CL enables HWASan to detect a new class of bugs, specifically
use-after-scope. An example for a bug like this is

int* y;
{
   int x = 1;
   y = &x;
}
*y = 2;

IF YOU FOUND THIS CL AS A POSSIBLE CULPRIT OF A TEST FAILURE:

While it is possible that there is a bug in HWASan and this CL needs
to be rolled back, please also consider that this might surface
actual problems in either the test code or the code under test. See
https://r.android.com/1956922 for an example of fix for a bug
detected by a previous rollout of this flag.

This reverts commit fd337b3963.

Reason for revert: Once https://r.android.com/1985009 is submitted the bug that caused the revert will be fixed.

Change-Id: Id9e81e8b7c26e044af00bdaeae6bb35abbbd9710
2022-02-17 20:52:15 +00:00
Colin Cross
06c80eb851 Add builtins and minimal runtime as dependencies instead of flags
Use dependencies instead of libflags to link libclang_rt.builtins
and libclang_rt.ubsan_minimal.

Test: m checkbuild
Change-Id: I403cee0fb8cc21c347b42d8f8a3c20d6f43337a4
2022-02-10 11:50:31 -08:00
Mitch Phillips
7fbac74dc9 [cc_fuzz] Revert 'disable LTO' patches.
The toolchain no longer has a problem with sancov + LTO.

Bug: 131771163
Test: make haiku
Change-Id: If85931f092c41336a8a5e0e7999ad39dd8ec3daf
2022-02-08 10:51:35 -08:00
Colin Cross
234b01de96 Use -fno-sanitize-link-runtime for bionic sanitizers
Currently when using sanitizers and building for the device
the -fsanitize= argument is not passed to the linker so that the
linker won't add the runtimes, which have already been added
as explicit dependencies.  Pass -fno-sanitize-link-runtime instead
in case the linker has other behaviors when passed -fsanitize=
besides adding the runtimes.  Also check for bionic instead of host
so that linux bionic gets the same linker behavior as bionic for
the device.

Test: m USE_HOST_MUSL=true host-native
Test: m checkbuild
Change-Id: I0f2966e2fd4ae8adc5cb21eb116c349bcc0c668f
2022-02-08 01:35:23 +00:00
Florian Mayer
fd337b3963 Revert "Reland "Enable hwasan use after scope detection.""
This reverts commit 0edaddf2ce.

Reason for revert: b/http://b/214007768

Change-Id: I60a2e3a5386601992fcb5632c142dd28bdb611b2
2022-01-27 03:31:28 +00:00
Florian Mayer
0edaddf2ce Reland "Enable hwasan use after scope detection."
This reverts commit 77d0035a07.

Reason for revert: Fixing broken test in topic.

Change-Id: Ia09b6768e725af025522a25ad1289e9380b6bbbd
2022-01-20 19:34:36 +00:00
Evgenii Stepanov
4f41536076 Revert "Disable ubsan diagnostics under HWASan."
The original problem has been fixed in LLVM:
https://reviews.llvm.org/rG78f7e6d8d7956cb96d0fa0fd606192ca0218eee1

Bug: 191808836
Bug: 209991446
Test: m net_test_btm_iso with SANITIZE_TARGET=hwaddress

This reverts commit b15a564869.

Change-Id: Ie99a9a204e0a3f7c3ddf3efd74ac7f19db90215a
2021-12-21 16:31:31 -08:00
Pirama Arumuga Nainar
7448392895 [cc/sanitize] Re-enable new pass manager for fuzzer targets
Bug: http://b/133876586

This was turned off but the upstream change fixing this has been long
part of the Android toolchain.

Test: Output of
  m aidl_parser_fuzzer; readelf aidl_parser_fuzzer | grep -c sancov
hasn't changed.

Change-Id: Id7edd7ac5791b0e031fd4af46381acdbb1b80d47
2021-12-01 20:47:52 -08:00
Ivan Lozano
94e8a651fa Merge changes I26198187,Ia904d07b
* changes:
  rust: Support MTE memtag_heap sanitizer
  rust: Support global sanitizers
2021-11-12 19:26:04 +00:00
Ivan Lozano
62cd0388eb rust: Support MTE memtag_heap sanitizer
This CL adds support for the MTE memtag_heap sanitizer. This is
controlled via inclusion of an ELF note.

Bug: 170672854
Test: Heap MTE-enabled Rust test binary triggers MTE
Change-Id: I2619818785e86a94667d02b30d102c83456b7925
2021-11-04 10:51:54 -04:00
Yi Kong
286abc6f17 Pass HWASan workarounds cflags to linker as well
ThinLTO shifts codegen to linking stage. Need to pass the same set of
workaround flags to linker.

Test: m GLOBAL_THINLTO=true; adb shell incident_helper
Bug: 159343917
Bug: 204746309
Change-Id: I1e42bb043d6a86d880054b85e8831386ae4ea7e5
2021-11-04 20:19:57 +08:00
Ivan Lozano
5482d6a991 rust: Support global sanitizers
This CL adds Rust support for the SANITIZE_TARGET options.

This CL includes a couple small fixes to related to HWASAN, ASAN,
ensuring that the Never sanitize property is respected. Notably,
additional llvm-args are passed to ensure that HWASAN-ified Rust/C
interop works correctly.

Bug: 170672854
Bug: 204915322
Test: SANITIZE_TARGET globally applies hwasan to Rust targets
Change-Id: Ia904d07b4618f72cdc95c51f88961905c240ac53
2021-11-03 12:29:01 -04:00
Pirama Arumuga Nainar
582fc2d1dd [cc] Switch to -fsanitize-ignorelist
Upstream added this flag to replace -fsanitize-blacklist.

Test: presubmit
Change-Id: Iad6a1ac47b3a5693ed2107f491cbb36ac9f630ff
2021-08-27 15:12:56 -07:00
Florian Mayer
7c02c0883a Use new pass manager for HWASan builds.
Now that we have rolled to a sufficiently new clang, HWASan also works
with the new pass manager.

Bug: 135298400
Test: introduce memory safety bug and verify HWASan gets triggered.
Change-Id: I497ca6542971569cbcad949780e4c7df5b0bfb44
2021-08-20 10:07:20 +01:00
Elvis Chien
9c99354465 Allow PRODUCT_CFI_INCLUDE_PATHS to work with blueprints also
but disable it for host modules like how it's done for Android.mk

Bug:
179233410

Test:
m -j32

Change-Id: I246cd9163e06997a2b50cd25688370690c8929af
2021-08-04 18:07:51 +08:00
Colin Cross
528d67e523 Reland "Split the x86 host toolchain into glibc and musl variants"
Split the x86 host toolchain into glibc and musl variants

Create new musl toolchains that are based on the existing glibc
toolchains, and add the necessary flags for musl compiles.

This relands Ifc02f9e5afa61ff758be98b0c962f3a4b53d0546 with changes
for I46672e3a096b6ea94ff4c10e1c31e8fd010a163c.

Bug: 190084016
Change-Id: Iaa9f7a50ff601155ecd73acc5701a2c226be66dc
Test: TestArchMutator
2021-07-23 22:25:36 +00:00
Colin Cross
5d6904e1cf Revert "Split the x86 host toolchain into glibc and musl variants"
This reverts commit 4fb4ef2242.

Reason for revert: crossed with aosp/1775072

Change-Id: Ied922850b810d82627ba4f9ee42f672cfe286c91
2021-07-23 22:20:29 +00:00
Colin Cross
4fb4ef2242 Split the x86 host toolchain into glibc and musl variants
Create new musl toolchains that are based on the existing glibc
toolchains, and add the necessary flags for musl compiles.

Bug: 190084016
Test: TestArchMutator
Change-Id: Ifc02f9e5afa61ff758be98b0c962f3a4b53d0546
2021-07-23 08:57:17 -07:00
Colin Cross
b8d69871a8 Merge "Remove Fuchsia support from Soong" 2021-07-23 14:54:49 +00:00
Colin Cross
cb0ac95bde Remove Fuchsia support from Soong
Bug: 194215932
Test: m checkbuild
Change-Id: Id7d3964d9417f8b0938af9b168bb4c00cebe9390
2021-07-21 20:37:46 -07:00
Kiyoung Kim
48f3778cb4 Separate snapshot definition
Current snapshot definition is located in the CC module, so it is
difficult to capture non-CC module (such as prebuilt_etc) to the
snapshot. Separate general snapshot definition from cc so other modules
can also define its own snapshot.

Bug: 192430376
Test: m nothing passed
Change-Id: Ifb69fb3d2ec555b629aa31ec03e7ce5831fd3063
2021-07-19 11:42:32 +09:00
Liz Kammer
75db931843 Iterate over sanitizers
Test: go test soong tests
Change-Id: If89b7d0b04cad79b42a08504d4fcff36e914b7a4
2021-07-08 11:19:15 -04:00
Liz Kammer
7b920b4057 Update memtag code behavior to match comment.
Test: go test soong tests
Change-Id: I630c06f01c90256b1990c37b9236e8967a5fa316
2021-07-08 11:19:15 -04:00
Liz Kammer
75b9b40a56 Add comments to sanitizer properties.
Test: n/a
Change-Id: If71bb4683a4ae969670235c51b3f1b3af2073f91
2021-07-08 11:19:12 -04:00
Liz Kammer
187d5445e8 Remove IsDependencyRoot from interface
This is equivalent to Binary() -- reduce the interface and improve
clarity.

Test: go test soong tests
Change-Id: I770f5ce79fd4d888586d31ec5e67be88153626b6
2021-07-07 16:29:09 -04:00
Liz Kammer
b2fc4700de Delete local boolPtr function
This is defined in proptools, no need to duplicate.

Test: go test soong tests
Change-Id: I32d4417dc4ae73bff98f36360ed22aed572d8c18
2021-07-07 16:29:09 -04:00
Liz Kammer
3b606c8218 Delete unused functions
As they're unused, also removing them from the interface.

Test: go test soong tests
Change-Id: I76e7cbca12876395d8d7eaae4481c5e0d1350d76
2021-06-28 12:29:30 -04:00
Evgenii Stepanov
b15a564869 Disable ubsan diagnostics under HWASan.
This is a workaround for a compiler bug that makes this combination
extremely slow to build.

Bug: 191808836
Test: m net_test_btm_iso with SANITIZE_TARGET=hwaddress
Change-Id: Ide7436bbc564413cb2f29355ada5286976607205
2021-06-23 12:57:46 -07:00
Ivan Lozano
d67a6b0a88 Export cc vendor functions for usage by rust.
This CL exports and refactors some cc vendor-snapshot related functions
so they can be reused by rust modules to support vendor snapshotting.

Bug: 184042776
Test: m nothing
Change-Id: I12706e62ce0ac3b2b4298085fafc1d77b8e0a0c4
2021-06-03 08:31:55 -04:00
Colin Cross
48a2d110b3 Merge "Don't propagate ASAN through shared library dependencies" 2021-05-18 19:20:34 +00:00
Colin Cross
af98f58242 Don't propagate ASAN through shared library dependencies
Propagating enabling ASAN through shared library dependencies
doesn't make much sense, because only the non-ASAN variant is exposed
to Make, leading to an non-installed dependency.

Bug: 186487510
Test: TestAsan
Change-Id: I7d3f20f2d10beac09c66c6b6dcb7a34a513ff3b8
2021-05-13 18:02:57 -07:00
Ivan Lozano
d7586b6526 Refactor vendor snapshot to use LinkableInterface.
Refactors the vendor snapshot support to use the LinkableInterface
so that support can be extended to Rust. This CL does not add
vendor snapshot support for Rust; that is left for a follow-on CL.

Bug: 184042776
Test: m nothing
Change-Id: Id0c4970ca00053484a52677d182153cbc454c301
2021-05-12 14:01:10 -04:00
Tri Vo
eed4716def Merge changes I46e851c8,I2c9eb248
* changes:
  rust: Add HWASan build support
  Export CC HWASan sanitizer type
2021-04-09 22:31:09 +00:00
Tri Vo
6eafc36e60 Export CC HWASan sanitizer type
We need this so that HWASan sanitizer mutator in CC can sanitize Rust.

Bug: 180495975
Test: m nothing
Change-Id: I2c9eb248df4e55a33f5d45083e91588f4c8e3e94
2021-04-08 14:24:06 -07:00
Inseob Kim
253f521dbc Redirect memtag libraries to snapshot
memtag sanitizer libraries are vendor available and can be captured as
snapshots. This change adds a redirection logic for memtag libraries.

This is just a workaround, just like other SnapshotInfoProvider calls.
In the future we need to refactor these codes. So TODO is added to
remind refactoring.

Bug: 178470649
Test: soong test
Change-Id: Id77f1ce94255b56a68f3e1d7446a68189c45ac54
2021-04-08 17:10:31 +09:00
Colin Cross
32f1de3327 Append ".static" to ubsan runtime for static binaries
Bug: 183611452
Test: m BUILD_HOST_static=1 tinyplay2
Change-Id: I8d8ef762781f0583c8b9337ce5876c7d3140f665
2021-03-29 16:47:56 -07:00
Cindy Zhou
34d300ba76 Merge "Enable cfi for 32bit arch" 2021-03-12 12:41:39 +00:00
Cindy Zhou
e0c14678d4 Enable cfi for 32bit arch
Enabling cfi for 32-bit arch; b/35157333 seems to have been resolved in b/67507331.

Bug: 158010610

Test: manual interaction with Wimbley device: youtube video, chrome
navigations, gmail
MPTS testing on Sargo
Change-Id: I9eb034deed9938710f0f7b690fa57108d9bc5669

Change-Id: I434748ede352f998e64a6639de6ba162762ee7f0
2021-03-10 17:14:02 -08:00