Reland^2 "[MTE] remap stacks with PROT_MTE when requested by dlopened library"
Also enable stack MTE if main binary links in a library that needs it.
Otherwise the following is possible:
1. a binary doesn't require stack MTE, but links in libraries that use
stg on the stack
2. that binary later dlopens a library that requires stack MTE, and our
logic in dlopen remaps the stacks with MTE
3. the libraries from step 1 now have tagged pointers with missing tags
in memory, so things go wrong
This reverts commit f53e91cc810be2a36377f3b7765f50c89f1f0046.
Reason for revert: Fixed problem detected in b/324568991
Test: atest memtag_stack_dlopen_test with MTE enabled
Test: check crash is gone on fullmte build
Change-Id: I4a93f6814a19683c3ea5fe1e6d455df5459d31e1
diff --git a/tests/libs/Android.bp b/tests/libs/Android.bp
index 039d1e1..06ee132 100644
--- a/tests/libs/Android.bp
+++ b/tests/libs/Android.bp
@@ -234,6 +234,61 @@
}
// -----------------------------------------------------------------------------
+// Libraries and binaries used by memtag_stack_dlopen_test tests
+// -----------------------------------------------------------------------------
+cc_test_library {
+ name: "libtest_simple_memtag_stack",
+ sanitize: {
+ memtag_stack: true,
+ },
+ srcs: ["dlopen_testlib_simple.cpp"],
+}
+
+cc_test_library {
+ name: "libtest_depends_on_simple_memtag_stack",
+ sanitize: {
+ memtag_stack: false,
+ },
+ shared_libs: [
+ "libtest_simple_memtag_stack",
+ ],
+ srcs: ["dlopen_testlib_depends_on_simple.cpp"],
+}
+
+cc_binary {
+ name: "testbinary_is_stack_mte_after_dlopen",
+ sanitize: {
+ memtag_stack: false,
+ memtag_heap: true,
+ },
+ srcs: ["testbinary_is_stack_mte_after_dlopen.cpp"],
+}
+
+cc_binary {
+ name: "testbinary_depends_on_simple_memtag_stack",
+ sanitize: {
+ memtag_stack: false,
+ memtag_heap: true,
+ },
+ shared_libs: [
+ "libtest_simple_memtag_stack",
+ ],
+ srcs: ["testbinary_is_stack_mte.cpp"],
+}
+
+cc_binary {
+ name: "testbinary_depends_on_depends_on_simple_memtag_stack",
+ sanitize: {
+ memtag_stack: false,
+ memtag_heap: true,
+ },
+ shared_libs: [
+ "libtest_depends_on_simple_memtag_stack",
+ ],
+ srcs: ["testbinary_is_stack_mte.cpp"],
+}
+
+// -----------------------------------------------------------------------------
// Libraries used by hwasan_test
// -----------------------------------------------------------------------------
cc_test_library {