Skip to content

Commit 71ad495

Browse files
committed
Change the android_mallopt(M_SET_HEAP_TAGGING_LEVEL) API.
- Make it apply to every thread, and thus remove the restriction that it must be called while the program is single threaded. - Make it change TCF0 itself (on all threads), instead of requiring callers to do it themselves, which can be error prone. And update all of the call sites. Change the implementation of android_mallopt(M_DISABLE_MEMORY_MITIGATIONS) to call android_mallopt(M_SET_HEAP_TAGGING_LEVEL) internally. This avoids crashes during startup that were observed when the two mallopts updated TCF0 unaware of each other. I wouldn't expect there to be any out-of-tree callers at this point, but it's worth noting that the new interface is backwards compatible with the old one because it strictly expands the set of situations in which the API can be used (i.e. situations where there are multiple threads running or where TCF0 hadn't been updated beforehand). Bug: 135772972 Change-Id: I7746707898ff31ef2e0af01c4f55ba90b72bef51
1 parent 13e33f7 commit 71ad495

File tree

1 file changed

+0
-11
lines changed

1 file changed

+0
-11
lines changed

debuggerd/debuggerd_test.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include <android/set_abort_message.h>
3535
#include <bionic/malloc.h>
3636
#include <bionic/mte.h>
37-
#include <bionic/mte_kernel.h>
3837
#include <bionic/reserved_signals.h>
3938

4039
#include <android-base/cmsg.h>
@@ -386,16 +385,6 @@ TEST_F(CrasherTest, heap_addr_in_register) {
386385

387386
#if defined(__aarch64__) && defined(ANDROID_EXPERIMENTAL_MTE)
388387
static void SetTagCheckingLevelSync() {
389-
int tagged_addr_ctrl = prctl(PR_GET_TAGGED_ADDR_CTRL, 0, 0, 0, 0);
390-
if (tagged_addr_ctrl < 0) {
391-
abort();
392-
}
393-
394-
tagged_addr_ctrl = (tagged_addr_ctrl & ~PR_MTE_TCF_MASK) | PR_MTE_TCF_SYNC;
395-
if (prctl(PR_SET_TAGGED_ADDR_CTRL, tagged_addr_ctrl, 0, 0, 0) != 0) {
396-
abort();
397-
}
398-
399388
HeapTaggingLevel heap_tagging_level = M_HEAP_TAGGING_LEVEL_SYNC;
400389
if (!android_mallopt(M_SET_HEAP_TAGGING_LEVEL, &heap_tagging_level, sizeof(heap_tagging_level))) {
401390
abort();

0 commit comments

Comments
 (0)