Add android_mallopt to query MTE stack state
Bug: 244364391
Change-Id: Ie6267201f0c2e293b27c71cd160a2311c9de8091
diff --git a/tests/libs/Android.bp b/tests/libs/Android.bp
index 5edf97c..66a902e 100644
--- a/tests/libs/Android.bp
+++ b/tests/libs/Android.bp
@@ -1663,6 +1663,7 @@
memtag_heap: true,
},
},
+ header_libs: ["bionic_libc_platform_headers"],
}
cc_test {
@@ -1677,6 +1678,7 @@
memtag_heap: true,
},
},
+ header_libs: ["bionic_libc_platform_headers"],
}
cc_genrule {
diff --git a/tests/libs/stack_tagging_helper.cpp b/tests/libs/stack_tagging_helper.cpp
index f6739b6..a239dc1 100644
--- a/tests/libs/stack_tagging_helper.cpp
+++ b/tests/libs/stack_tagging_helper.cpp
@@ -26,6 +26,8 @@
#include <unistd.h>
#include <thread>
+#include <bionic/malloc.h>
+
#include "libs_utils.h"
#if defined(__aarch64__)
@@ -252,6 +254,12 @@
t.join();
}
+void test_android_mallopt() {
+ bool memtag_stack;
+ CHECK(android_mallopt(M_MEMTAG_STACK_IS_ON, &memtag_stack, sizeof(memtag_stack)));
+ CHECK(memtag_stack);
+}
+
int main(int argc, char** argv) {
if (argc < 2) {
printf("nothing to do\n");
@@ -283,6 +291,11 @@
return 0;
}
+ if (strcmp(argv[1], "android_mallopt") == 0) {
+ test_android_mallopt();
+ return 0;
+ }
+
printf("unrecognized command: %s\n", argv[1]);
return 1;
}