Commit graph

379 commits

Author SHA1 Message Date
Florian Mayer
ab97e28bf6 Pass -mllvm flags for memtag-stack correctly to linker
Bug: 309446520
Change-Id: I08519db0323a754c66acaa0ace5c41d962809ac6
2024-05-01 00:36:06 +00:00
Aditya Kumar
c63c4306c0 Merge "Add deps to blocklist path" into main 2024-04-09 23:49:13 +00:00
Cole Faust
8982b1c49e Remove "exported" ninja variables
There was infrastructure to export ninja variables to bazel. Now that
the bazel migration is cancelled, we don't need it anymore.

Bug: 315353489
Test: m nothing
Change-Id: I298cc2ac7ebd004557be3b30d75f7357cab0b7a0
2024-04-09 09:42:37 -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
AdityaK
6e6f52281e Add deps to blocklist path
Change-Id: Ib4e17c497035b071f7c61d9158c58b5c03d919ae
2024-04-03 14:54:24 -07: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
Colin Cross
8ff105860d Remove ConvertWithBp2build implementations
Remove the ConvertWithBp2build implementations from all the module
types, along with the related code.

Bug: 315353489
Test: m blueprint_tests
Change-Id: I212672286686a318893bc7348ddd5a5ec51e77a7
2023-12-08 13:51:05 -08:00
Elliott Hughes
3bba0e4bfe Have the sanitizers trap rather than abort.
abort() seems friendlier, but in practice it puts a couple of irrelevant
libc.so frames on the top of the stack trace and clobbers all the
registers that might have helped remotely debug a sanitizer failure.
Let's switch to trapping directly in the sanitized code instead.

Bug: http://b/298741930
Test: treehugger
Change-Id: I6c971920c8506f97133749aaddd73b8cea6a12bc
2023-10-05 14:51:28 -07:00
Liz Kammer
ba23cb6436 Fix for ndk having sanitizers
Test: go test soong tests
Test: verify no NeuralNetworksTest_random_graph sdk variants in
    build.ninja when aosp_x86 is lunched
Bug: 302093869
Change-Id: I6429aa75518cca6974abcf7330236a6a07135ea1
2023-09-26 17:06:33 -04:00
Sami Tolvanen
ed78fc8553 Reapply "Enable CFI for riscv64"
This reverts commit 49dcf79550.

The previous init crash was caused by the kernel defaulting to Sv57 and
the CFI shadow implementation in bionic assuming a 48-bit virtual
address space. With 5-level paging disabled in cuttlefish, we can again
enable CFI.

Bug: 293884796
Link: https://github.com/google/android-riscv64/issues/45
Test: cuttlefish boots
Change-Id: Ibcc02cf7ca6e396fd58674c648abf9f84daa260e
2023-09-18 13:41:29 -07:00
Treehugger Robot
f3d52683a9 Merge "soong: HWASan exclude path support" into main 2023-09-06 01:14:12 +00:00
Ivan Lozano
5467a39984 rust: Rust sanitized snapshots variations
This adds support for correctly handling Rust sanitized snapshots,
ensuring they only have one variation.

The presence of multiple variations were causing build failures
when a rust_fuzz module for host was defined and a snapshot
build was requested.

This also sets -Z link-native-libraries=no on host modules
(in addition to device modules) to avoid emitting extra linkage
flags due to link attributes.

Bug: 282897366
Test: SOONG_SDK_SNAPSHOT_USE_SRCJAR=true m
Change-Id: Idf980c29145f11c530ad635a4eb5b01a1730ac24
2023-08-25 12:54:56 -04:00
Colin Cross
0df8153267 Fix adding manual ubsan runtime to static glibc binaries
Sanitized glibc binaries get their runtime added by clang, not by
Soong, but unsanitized glibc binaries with sanitized dependencies
need their runtime added manually by Soong.  Fix adding a static
runtime dependency to static glibc binaries.

Fixes: 297250415
Test: TestUbsan
Change-Id: I4913326604f9efebd8ecd4aad2f109fad8b6a80c
2023-08-23 22:39:58 -07:00
Tomislav Novak
f734f00898 soong: HWASan exclude path support
Adds the ability to centrally disable HWASan for multiple modules when
building with SANITIZE_TARGET=hwaddress. Soong version of the patchset.

HWASan takes precedence over CFI and several other sanitizers that it's
incompatible with[1], which can be problematic for modules that require
those sanitizers (e.g. those that depend on vendor prebuilts where only
sanitized variants are provided). This patch adds an easy way to disable
HWASan for such modules while still keeping it globally enabled.

Test: build with HWASAN_EXCLUDE_PATHS set and verify with readelf that
      relevant modules have no references to __hwasan symbols

[1] bb31ca1168/core/config_sanitizers.mk (236)

Change-Id: I5824f71f2a400c64cde29e2c7afdd167d851d337
2023-08-22 18:15:14 +00:00
Trevor Radcliffe
24e0b13b9c Merge "Export no sanitize link runtime flag" into main 2023-08-03 20:54:39 +00:00
Trevor Radcliffe
0555acc1f7 Merge "Export Minimal Runtime Flags" into main 2023-08-03 20:39:22 +00:00
Trevor Radcliffe
da64d91d2e Export no sanitize link runtime flag
Bug: 294219797
Test: Unit tests
Change-Id: Id4bbf78e9ba3893fb857b85e6b7261b11404ebf0
2023-08-02 20:24:29 +00:00
Trevor Radcliffe
3876c5a143 Export Minimal Runtime Flags
Bug: 294219797
Test: Unit Tests
Change-Id: Ia6a617378ccecb01bda4951d223b6c99d6c75060
2023-08-02 15:41:50 +00:00
Florian Mayer
f50eda3b9b Reland "[hwasan] remove workaround for fixed toolchain issue"
This reverts commit e72ee14006.

Bug: 293532332
Reason for revert: Test failure fixed in https://r.android.com/2681595

Change-Id: Id40079133e50492a6e2f3e2794012695562c39f6
2023-07-28 21:22:34 +00:00
Mark White
e72ee14006 Revert "[hwasan] remove workaround for fixed toolchain issue"
This reverts commit 07ca220182.

Reason for revert: b/293532332 - bionic unit tests failing

Change-Id: I11412df55d7131ff0bb36dee7258b75a12024100
2023-07-28 13:54:57 +00:00
Florian Mayer
07ca220182 [hwasan] remove workaround for fixed toolchain issue
these two upstream commits fixed the issues in global-isel and fast-isel:

* global-isel: https://reviews.llvm.org/D82615
* fast-isel: https://reviews.llvm.org/D138615

Currently used clang r498229 (defined build/soong/cc/config/global.go)
is based on upstream commit 14f0776550b5a49e1c42f49a00213f7f3fa047bf
which includes these two changes.

Bug: 293297826
Test: build oriole_hwasan and boot
Change-Id: I65fabdf0b5edd248b4bf4e138a999f8142370cd5
2023-07-26 21:17:56 +00:00
AdityaK
111d68053b Enable scs for riscv64
https://github.com/google/android-riscv64/issues/106

Bug: b/277909695

Change-Id: I2ea0d41fd9dc43b3fefb748d10694917034ab586
2023-07-17 22:43:44 +00:00
Mitch Phillips
03d510404c Merge "[MTE] Add memtag_globals as a sanitizer target." 2023-06-26 05:50:11 +00:00
Florian Mayer
c3adf443e7 Merge "Reland "Re-enable stack frame size errors"" 2023-06-22 20:55:48 +00:00
Mitch Phillips
92d19fa306 [MTE] Add memtag_globals as a sanitizer target.
MTE globals needs four pieces:
 1. (done) clang/llvm to produce objfiles with MTE globals metadata
 2. (in flight, https://reviews.llvm.org/D152921) lld to process the metadata in the objfiles, and produce information in each DSO describing the global variables that need to be tagged (alongside some other stuff).
 3. (this patch) android to handle the new sanitizer
 4. (not yet sent) bionic's libc/linker to interpret the information in each DSO, and tag the global variables.

Because #2 will take some time to come through the toolchain rolls, and #3 and #4 can be landed asynchronously, we can land this ahead of time. Should make my life easier by preventing constant rebases.

Bug: N/A
Test: Build {libc, libm, libc++, libm, and libnetd} in internal master
with these patches and an experimental compiler with the lld support.
Also, `SANITIZE_TARGET=memtag_globals m` here with in-tree compiler
without lld support.

Change-Id: Ie7882d474d4d776232de3a3d571a82274df14bf0
2023-06-22 17:04:40 +00:00
Treehugger Robot
f44ac9efc1 Merge changes I6ddb47d7,I3df3d304
* changes:
  [hwasan] Increase BB to explore for reachability
  [hwasan] Also pass use-after-scope flag in LTO
2023-06-21 21:14:52 +00:00
Florian Mayer
c746619feb [hwasan] Increase BB to explore for reachability
We pass mcpu=cortex-a55 for our build, which increases BB to the point
where the LLVM default of 32 is not enough. This caused worse coverage
for use-after-scope detection, and increased stack usage.

Test: build oriole_hwasan
Bug: 229654778
Change-Id: I6ddb47d7224a9c6ddbf2641c043e3430d330c5a9
2023-06-16 17:34:59 -07:00
Florian Mayer
a998446d3e [hwasan] Also pass use-after-scope flag in LTO
Change-Id: I3df3d3047fd5aaa93e6c4b68885d39e20b12ccdb
2023-06-16 17:34:57 -07:00
Florian Mayer
2bddccd837 Reland "Re-enable stack frame size errors"
This reverts commit 25cd981362.

Reason for revert: b/274474681 is fixed.

Bug: 229654778
Change-Id: I4b975ced02ffe0d5a432a3033f05bb61868bec45
2023-06-16 22:34:41 +00:00
Trevor Radcliffe
ded095ce45 Bp2build Sanitizer Blocklist
Bug: 286894426
Test: Unit tests
Change-Id: I382e028410a185a5017dba1fc47c83ad5b2432cf
2023-06-13 20:46:27 +00:00
Trevor Radcliffe
f1836e4728 Add CFI flags to Compile Action
Bug: 261733820
Test: Unit Tests
Change-Id: I7c7cb8ab07da2c66df5d69e1e4af3337e3b24e6d
2023-06-05 18:09:21 +00:00
Colin Cross
390fc746d0 Disable sanitizers that use runtimes for linux_musl arm64
We don't built clang sanitizer runtimes for host arm64 yet,
disable sanitizer that need them when building for linux_musl arm64.

Test: builds
Change-Id: Id4fcb7f9743ac30121157b2294eb60216eaff7b3
2023-05-17 21:59:32 +00:00
Aditya Kumar
1281b99495 Disable LTO and CFI for riscv64
This reverts commit 24870216e9.

Reason for revert: b/282584808

Change-Id: I3808121b4437fdd01db5d305d8f0377e6ad7bd9e
2023-05-16 03:55:41 +00:00
Aditya Kumar
24870216e9 Revert "Disable LTO and CFI for riscv64"
This reverts commit ecf4e664e0.

Reason for revert: Not needed as emultated tls is now globally disabled https://android-review.git.corp.google.com/c/platform/build/soong/+/2431153

Change-Id: Idc3de2771afbbe2d5976f3c7974b3ffd15441b13
2023-05-12 18:46:42 +00:00
Hang Lu
a98aab98c4 Enable HWASan for multiple modules in one place(Soong)
Environment variables HWASAN_INCLUDE_PATHS and
PRODUCT_HWASAN_INCLUDE_PATHS can be used to enable HWASan for multiple
modules, by just adding the module directory to the env variable.

Bug: b/271948407
Test: Set specific module directory to above env variable and check the
assembly codes of output elf files after building, finding hwasan
related symbols inside.

Change-Id: Ic49b515830c4469ca5fa94f547b26c0fb602fc54
2023-04-19 22:59:54 +00:00
Florian Mayer
7de9aa1a7b Merge "Add handling for libc_hwasan to Soong" 2023-04-14 23:27:57 +00:00
Elliott Hughes
7d57090bb3 Merge "Temporarily disable shadow call stack for riscv64." 2023-04-13 01:47:42 +00:00
Elliott Hughes
5beb42fe22 Temporarily disable shadow call stack for riscv64.
We're trying to switch from x18 to gp for shadow call stack, ideally
without breaking anything, so let's disable shadow call stack while we
rearrange things behind the scenes...

Bug: http://b/277909695
Test: treehugger
Change-Id: Ic1a6bceaf0ab20dc66e1903747ebb668232a253a
2023-04-12 13:11:29 -07:00
Trevor Radcliffe
9f4b4769c5 Separate out Cross DSO flag for Bazel
See the other CL in this topic for a description of why.

Bug: 261733820
Test: Unit Tests
Change-Id: I045c2f883258c3f5db9790300d89a7be04d56012
2023-04-11 17:43:15 +00:00
Florian Mayer
95cd6db590 Add handling for libc_hwasan to Soong
libc_hwasan is a new library in the runtime apex that lives in
bionic/hwasan/libc.so and is symlinked to /system/lib64/hwasan/libc.so.
This is chosen by the linker if an app or binary requires HWASan
support.

Bug: 276930343
Change-Id: If331744ad84241ad99a41805ea3110d37cf9b0af
2023-04-06 15:55:50 -07:00
Colin Cross
3f3320cb1c Merge changes I93da03b1,I5fb3ee29
* changes:
  Use static asan runtime for musl
  Simplify depending on static sanitizer runtimes
2023-03-29 17:04:14 +00:00
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