Commit graph

325 commits

Author SHA1 Message Date
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