Commit graph

38 commits

Author SHA1 Message Date
Cole Faust
021bf3d973 Reapply "Make the enabled property configurable"
Previously, I had changed some loadhook-appended property structs
to use selects instead of the "target" property struct. This seems
to not be exactly equivalent because "target" properties are merged
with the regular properties later, at the time the arch mutator runs.

With this reapplication, leave those target property structs alone
to avoid breakages, but I'll have to look into what the issue is
with them later.

This reverts commit ed5276f082.

Ignore-AOSP-First: This cl needs to be in a topic with internal-only projects, will cherrypick to aosp after.
Bug: 323382414
Test: m nothing --no-skip-soong-tests
Change-Id: If355d24506e3f117d27b21442a6c02bca3402dc7
2024-05-02 10:56:36 -07:00
Priyanka Advani
ed5276f082 Revert "Make the enabled property configurable"
Revert submission 27162921-configurable_enabled_property

Reason for revert: Droid-monitor created revert due to Build breakage in b/338253720. Will be verifying through ABTD before submission.

Reverted changes: /q/submissionid:27162921-configurable_enabled_property

Change-Id: I2d144f9d297373a13a1190b173d10c966181ad84
2024-05-01 20:02:41 +00:00
Cole Faust
0e0d749062 Make the enabled property configurable
This allows using select statements with it.

Ignore-AOSP-First: This needs to be in a topic with changes in interal-only repositories, I'll cherrypick to aosp after.
Bug: 323382414
Test: m nothing --no-skip-soong-tests
Change-Id: I6f3efaaa3d82505e38a91ee4ba0e18e404360191
2024-04-30 10:56:12 -07:00
Kiyoung Kim
37693d0a27 Deprecate Snapshot build
Existing snapshot code will no longer work from VNDK deprecation, but it
can give confusion to users if we keep code for the snapshot - and it
adds complexity on existing code while it is not in use. This change
removes all snapshot definition except host snapshot and its usage.

Bug: 330100430
Bug: 332986564
Test: AOSP CF build succeeded
Change-Id: Ieb6fa43d5e38315c662ce997bc305b744b367c24
2024-04-05 01:56:56 +00:00
Ivan Lozano
357433ae73 rust: Re-enable host address sanitizer.
Our toolchain supports a flag "-Z external-clangrt=true" which prevents
rustc from emitting a missing dependency to librust-dev_rt. Instead, we
link in libclang_rt.

Bug: 304507701
Bug: 324826914
Test: SANITIZE_HOST=address m aconfig
Change-Id: I8020c550b7a922c80620f61c22e01848a4f4a349
2024-02-12 14:16:26 -05:00
Colin Cross
ff694a8c88 Convert Provider to generic providers API
Convert all of the callers of Provider/HasProvider to use the type-safe
android.ModuleProvider API.

Bug: 316410648
Test: builds

Change-Id: I73479de1625fa2865b6c73444cd477e50d56dc5a
2023-12-14 16:12:21 -08:00
Ivan Lozano
839b5f9ac5 rust: Temporarily disable ASAN builds for Host
This is breaking sanitized host builds. Disable the sanitizer in Rust
for host targets until this can be resolved.

Bug: 304507701
Test: SANITIZE_HOST=address m rust
Change-Id: I12b0c3e217717de7a89b32198f4c4729709e99b3
2023-10-11 13:18:37 -04:00
Colin Cross
3ef9285ed2 Disable rust sanitizers for linux_musl_x86
rustc 1.71.0 doesn't support any sanitizers for linux_musl_x86, disable
sanitizing for now.

Bug: 257334542
Test: m USE_HOST_MUSL=true host-native
Change-Id: I70819d2175c59bca1ff385d4aee48518d6b702e7
2023-09-05 12:10:54 -07:00
Ivan Lozano
2fcbffa4a1 rust: Add support for host fuzzers.
Adds support for host-based Rust fuzzers.

Bug: 282897366
Test: SANITZE_HOST="address" m <host_fuzzer>
Test: run fuzzer
Change-Id: Ibb951f651ef12e763778ebbf12e66769a7113920
2023-08-10 09:48:13 -04:00
Ivan Lozano
17ac9fa93e Merge "Revert "rust: Add SCS sanitizer option for AArch64"" into main 2023-07-31 18:13:40 +00:00
Ivan Lozano
22823eed4b Revert "rust: Add SCS sanitizer option for AArch64"
This reverts commit 8827113577.

Reason for revert: hwasan builds breaking

Change-Id: I28094e27d5935c6f371fddddf4b6b0334de9b12c
2023-07-31 18:01:26 +00:00
Ivan Lozano
0e403456b0 Merge "rust: Add SCS sanitizer option for AArch64" into main 2023-07-31 17:27:01 +00:00
Ivan Lozano
8827113577 rust: Add SCS sanitizer option for AArch64
SCS has been supported in Rust since 1.64.0.

This adds SCS as a sanitizer option in Rust.

Bug: 168914033
Test: Built module with sanitize: { scs: true }
Change-Id: Ie54ac4693286878b98704cf052649a267777d764
2023-07-28 14:34:28 -04:00
Ivan Lozano
408d37319a rust: Pass ASAN/HWASAN flags alongside fuzzers
'-Z sanitizer={hw}address' was not being passed if the fuzzer sanitizer
property was also set. Additionally, trying to use the fuzzer sanitizer
with the address sanitizer incorrectly linked in the hwasan runtime.

Bug: 293466009
Test: SANITIZE_TARGET="fuzzer address" m android_logger_fuzzer
Test: SANITIZE_TARGET="fuzzer hwaddress" m android_logger_fuzzer
Test: ldd <fuzzer_on_device> # ensure correct libraries linked
Test: Check build flags
Change-Id: I6b01c8808af07c642217b642af128ebf934f4bc6
2023-07-27 14:00:07 -04:00
Ivan Lozano
f9780422b3 Revert "rust: Add SCS sanitizer option."
This reverts commit 447f5b1ea9.

Reason for revert: b/293445283

Change-Id: Iadc6c7ed196be2a65329f86423730ba7f851002c
2023-07-27 14:52:20 +00:00
Ivan Lozano
447f5b1ea9 rust: Add SCS sanitizer option.
SCS has been supported in Rust since 1.64.0.

This adds SCS as a sanitizer option in Rust.

Bug: 168914033
Test: Built module with sanitize: { scs: true }
Change-Id: Ibdc116a335339af6d0b0d6dd0bb82c0358fa9087
2023-07-26 13:34:55 -04:00
Ivan Lozano
1247b3c8a0 rust: Fix flags for Rust libfuzzer fuzzers
Rust libfuzzer flags have changed upstream, so update our set of flags.

This fixes the following fuzzer error:

  ERROR: The size of coverage PC tables does not match the
  number of instrumented PCs. This might be a compiler bug,
  please contact the libFuzzer developers.

Bug: 249551848
Test: SANITIZE_TARGET="hwaddress fuzzer" m <fuzz_target>
Test: Test running the fuzzer.
Change-Id: I4f7df1fbe636133c646dfb0bd12757c947995ffe
2023-06-12 15:08:45 -04:00
Ivan Lozano
7f9d7cbb75 rust: Support sanitizers in rust_ffi modules
Don't automatically assume that HWASAN or ASAN is enabled if Fuzzer is
enabled.

Bug: 178365482
Test: m bluetooth_stack_with_facade
Test: SANITIZE_TARGET=fuzzer m bluetooth_stack_with_facade
Test: SANITIZE_TARGET=address m bluetooth_stack_with_facade
Test: SANITIZE_TARGET=hwaddress m bluetooth_stack_with_facade
Test: SANITIZE_TARGET="fuzzer address" m bluetooth_stack_with_facade
Test: SANITIZE_TARGET="fuzzer hwaddress" m bluetooth_stack_with_facade
Change-Id: Ief8c0f899837c5889a8035782616025f1b0d54e7
2023-05-24 20:15:52 +00:00
Florian Mayer
296d595260 Driveby: remove duplicate condition
Change-Id: I8deddf40542d92a69d87334a292d6d1c038ae69a
2022-10-12 19:30:15 +00:00
Colin Cross
1faf82305a Add rust musl arm and arm64 toolchains
Add rust toolchain configurations for arm-linux-musleabihf and
aarch64-linux-musl.

Bug: 236052820
Test: builds with linux musl arm64 host cross configured
Change-Id: Icfa73a75eac710e955f71a073cb4b7bb1cdfcc7a
2022-06-28 15:16:15 -07: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
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
Charisee
5ddec43280 Update RustDefaultVersion to 1.59.0
bug: 215232614
Test: TreeHugger and compiling with m rust
Change-Id: Ia60c77637ab2e41844010e021656fad0870013ac
2022-03-02 19:54:47 +00:00
Ivan Lozano
92a89ed1c5 Merge "rust: Skip global 'fuzzer' sanitizer static bins" 2021-11-15 19:17:54 +00:00
Ivan Lozano
6c5b8f4e02 rust: Skip global 'fuzzer' sanitizer static bins
The 'fuzzer' sanitizer enables 'hwasan', which is not supported for Rust
static binaries. Make sure we skip applying this sanitizer to those
binaries.

Bug: 204776996
Test: SANITIZE_TARGET=fuzzer m <static_rust_executable>
Change-Id: I619cfab32b46c0811590973344eb5cdbe3f1a119
2021-11-15 09:35:12 -05:00
Ivan Lozano
f3e8fc3f0b rust: Only apply hwasan flags once to fuzz targets
On HWASAN global sanitized builds, fuzz targets had hwasanFlags applied
twice. Rust only allows llvm-args flags to be passed in once however, so
this broke compilation.

Bug: 204915322
Test: SANITIZE_TARGET='hwaddress fuzzer' m <fuzzer>
Change-Id: I4f6c35e04bc4c891d9c66e8a53c3dcb88e8670cf
2021-11-13 07:46:05 -05: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
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
Ivan Lozano
21fa0a5844 rust: Add common interface for binaries
Structs embedding binaryDecorator (rust_test, rust_benchmark, rust_fuzz)
are binaries as well, but won't pass checks against *binaryDecorator,
such as the check in StaticExecutable().

Add a binaryInterface that can be checked instead to simplify these
checks and ensure we catch all binaries.

Bug: 170672854
Test: rust_test, rust_benchmark return true StaticallyLinked
Change-Id: I2373d3663373a6977260785602a02d39a41320fe
2021-11-01 14:57:44 -04:00
Ivan Lozano
aa7c980002 rust: Disable dead stripping for fuzzers.
Without `-C link-dead-code`, Rust fuzzers may fail to start fuzzing.
See the cargo-fuzz issue in the code comment for details. This patch
disables dead stripping for our fuzzers by default.

Bug: 193200135
Test: Flag emitted when building Rust fuzzers.
Test: Fuzzer runs on device.
Change-Id: I530de30e9a57db206bcbf3d2d3d371628eef8934
2021-08-02 11:11:11 -04: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
505b0e8991 rust: Switch rust_fuzz to HWASan
Bug: 180495975
Test: example_rust_fuzzer
Change-Id: I26e6f15136ee2d5f4ed1167be5c1c6a14b19421a
2021-04-13 15:58:44 -07: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
0a74c3e06e rust: Add HWASan build support
HWASan for static Rust executables is not supported yet.

Bug: 180495975
Test: build local test app with HWASan
Change-Id: I46e851c82a16943586ec3a789f09a58651d036e3
2021-04-09 10:59:23 -07:00
Ivan Lozano
20fcfdf489 rust: Remove stack-depth sancov
This flag causes a linkage error between rustc and our libclang_rt. We
can remove it for now and look into reintroducing it in the future.

We'd need to define 'thread_local uintptr_t __sancov_lowest_stack' to
support this. See https://reviews.llvm.org/D36839

Bug: 180495975
Test: m <fuzzer>
Change-Id: I95c9392307b5f20a0eda0fc76eb7ef79e27ae4df
2021-04-09 13:22:27 -04:00
Ivan Lozano
c044f5bce8 rust: Update libfuzzer flags for rust_fuzz
libfuzzer-sys uses different flags in the 0.4.0 update, so update the
flags for rust_fuzz modules to align.

Test: m <example_fuzzer>
Change-Id: I0a1eb140a7843fdaf5266c05a1ecf6d3964e0f5e
2021-04-02 12:43:28 -04:00
Tri Vo
7af79fb49b Remove "-C link-dead-code=y" flag
sysroot no longer builds with this flag.

LLVM ERROR: Cannot select: 0x7f7c39be9b48: v8i8 = AArch64ISD::VSLI 0x7f7c39696120, 0x7f7c39693fc8, 0x7f7c39d86528, prebuilts/rust/linux-x86/1.50.0/src/stdlibs/library/core/src/../../stdarch/crates/core_arch/src/aarch64/neon/mod.rs:2324:5
  0x7f7c39696120: v8i8,ch = CopyFromReg 0x7f7c420b1c98, Register:v8i8 %13, prebuilts/rust/linux-x86/1.50.0/src/stdlibs/library/core/src/../../stdarch/crates/core_arch/src/aarch64/neon/mod.rs:2324:5
    0x7f7c39be90e8: v8i8 = Register %13
  0x7f7c39693fc8: v8i8,ch = load<(dereferenceable load 8 from %ir.b)> 0x7f7c420b1c98, 0x7f7c39694510, undef:i64, prebuilts/rust/linux-x86/1.50.0/src/stdlibs/library/core/src/../../stdarch/crates/core_arch/src/aarch64/neon/mod.rs:2324:19
    0x7f7c39694510: i64,ch = CopyFromReg 0x7f7c420b1c98, Register:i64 %17, prebuilts/rust/linux-x86/1.50.0/src/stdlibs/library/core/src/../../stdarch/crates/core_arch/src/aarch64/neon/mod.rs:2324:19
      0x7f7c39be52d8: i64 = Register %17
    0x7f7c39bea230: i64 = undef
  0x7f7c39d86528: i32,ch = CopyFromReg 0x7f7c420b1c98, Register:i32 %18, prebuilts/rust/linux-x86/1.50.0/src/stdlibs/library/core/src/../../stdarch/crates/core_arch/src/aarch64/neon/mod.rs:2324:5
    0x7f7c39be5ea0: i32 = Register %18
In function: _RNvNtNtNtCsfOHkQPwunBC_4core9core_arch7aarch644neon9vsli_n_s8B7_
11:40:52 ninja failed with: exit status 1

Bug: 147140513
Test: build/run local rust_fuzz executable with asan+sancov.
Change-Id: I00c81f25f562bb9f18169a199eaf95ebeb7dbbe6
2021-03-17 18:00:28 -07:00
Ivan Lozano
6cd99e6ab4 Add Rust fuzzing support.
Add a rust_fuzz module which builds a libfuzzer binary that enabes
asan+sancov. This relies on the libfuzzer-sys crate.

Bug: 147140513
Test: Local rust_fuzz example builds, fuzzes with asan+sancov.
Change-Id: I57db3b8d25869791824ccfab768d13b0bb9d42fa
2021-01-25 11:11:10 -05:00