aboutsummaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/Android.bp3
-rw-r--r--libc/arch-arm64/dynamic_function_dispatch.cpp28
-rw-r--r--libc/bionic/heap_tagging.cpp21
-rw-r--r--libc/platform/bionic/mte.h3
-rw-r--r--libc/platform/bionic/mte_kernel.h59
5 files changed, 15 insertions, 99 deletions
diff --git a/libc/Android.bp b/libc/Android.bp
index ae07c6bc4..10f431159 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -93,9 +93,6 @@ cc_defaults {
ldflags: ["-Wl,-z,muldefs"],
product_variables: {
- experimental_mte: {
- cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
- },
malloc_zero_contents: {
cflags: ["-DSCUDO_ZERO_CONTENTS"],
},
diff --git a/libc/arch-arm64/dynamic_function_dispatch.cpp b/libc/arch-arm64/dynamic_function_dispatch.cpp
index 0fd331f79..83e5ca4da 100644
--- a/libc/arch-arm64/dynamic_function_dispatch.cpp
+++ b/libc/arch-arm64/dynamic_function_dispatch.cpp
@@ -26,25 +26,15 @@
* SUCH DAMAGE.
*/
-#include <platform/bionic/mte_kernel.h>
#include <private/bionic_ifuncs.h>
#include <stddef.h>
#include <sys/auxv.h>
extern "C" {
-static bool supports_mte(unsigned long hwcap2) {
-#ifdef ANDROID_EXPERIMENTAL_MTE
- return hwcap2 & HWCAP2_MTE;
-#else
- (void)hwcap2;
- return false;
-#endif
-}
-
typedef void* memchr_func(const void*, int, size_t);
DEFINE_IFUNC_FOR(memchr) {
- if (supports_mte(arg->_hwcap2)) {
+ if (arg->_hwcap2 & HWCAP2_MTE) {
RETURN_FUNC(memchr_func, __memchr_aarch64_mte);
} else {
RETURN_FUNC(memchr_func, __memchr_aarch64);
@@ -53,7 +43,7 @@ DEFINE_IFUNC_FOR(memchr) {
typedef int stpcpy_func(char*, const char*);
DEFINE_IFUNC_FOR(stpcpy) {
- if (supports_mte(arg->_hwcap2)) {
+ if (arg->_hwcap2 & HWCAP2_MTE) {
RETURN_FUNC(stpcpy_func, __stpcpy_aarch64_mte);
} else {
RETURN_FUNC(stpcpy_func, __stpcpy_aarch64);
@@ -62,7 +52,7 @@ DEFINE_IFUNC_FOR(stpcpy) {
typedef char* strchr_func(const char*, int);
DEFINE_IFUNC_FOR(strchr) {
- if (supports_mte(arg->_hwcap2)) {
+ if (arg->_hwcap2 & HWCAP2_MTE) {
RETURN_FUNC(strchr_func, __strchr_aarch64_mte);
} else {
RETURN_FUNC(strchr_func, __strchr_aarch64);
@@ -71,7 +61,7 @@ DEFINE_IFUNC_FOR(strchr) {
typedef char* strchrnul_func(const char*, int);
DEFINE_IFUNC_FOR(strchrnul) {
- if (supports_mte(arg->_hwcap2)) {
+ if (arg->_hwcap2 & HWCAP2_MTE) {
RETURN_FUNC(strchrnul_func, __strchrnul_aarch64_mte);
} else {
RETURN_FUNC(strchrnul_func, __strchrnul_aarch64);
@@ -80,7 +70,7 @@ DEFINE_IFUNC_FOR(strchrnul) {
typedef int strcmp_func(const char*, const char*);
DEFINE_IFUNC_FOR(strcmp) {
- if (supports_mte(arg->_hwcap2)) {
+ if (arg->_hwcap2 & HWCAP2_MTE) {
RETURN_FUNC(strcmp_func, __strcmp_aarch64_mte);
} else {
RETURN_FUNC(strcmp_func, __strcmp_aarch64);
@@ -89,7 +79,7 @@ DEFINE_IFUNC_FOR(strcmp) {
typedef int strcpy_func(char*, const char*);
DEFINE_IFUNC_FOR(strcpy) {
- if (supports_mte(arg->_hwcap2)) {
+ if (arg->_hwcap2 & HWCAP2_MTE) {
RETURN_FUNC(strcpy_func, __strcpy_aarch64_mte);
} else {
RETURN_FUNC(strcpy_func, __strcpy_aarch64);
@@ -98,7 +88,7 @@ DEFINE_IFUNC_FOR(strcpy) {
typedef size_t strlen_func(const char*);
DEFINE_IFUNC_FOR(strlen) {
- if (supports_mte(arg->_hwcap2)) {
+ if (arg->_hwcap2 & HWCAP2_MTE) {
RETURN_FUNC(strlen_func, __strlen_aarch64_mte);
} else {
RETURN_FUNC(strlen_func, __strlen_aarch64);
@@ -107,7 +97,7 @@ DEFINE_IFUNC_FOR(strlen) {
typedef int strncmp_func(const char*, const char*, int);
DEFINE_IFUNC_FOR(strncmp) {
- if (supports_mte(arg->_hwcap2)) {
+ if (arg->_hwcap2 & HWCAP2_MTE) {
RETURN_FUNC(strncmp_func, __strncmp_aarch64_mte);
} else {
RETURN_FUNC(strncmp_func, __strncmp_aarch64);
@@ -116,7 +106,7 @@ DEFINE_IFUNC_FOR(strncmp) {
typedef char* strrchr_func(const char*, int);
DEFINE_IFUNC_FOR(strrchr) {
- if (supports_mte(arg->_hwcap2)) {
+ if (arg->_hwcap2 & HWCAP2_MTE) {
RETURN_FUNC(strrchr_func, __strrchr_aarch64_mte);
} else {
RETURN_FUNC(strrchr_func, __strrchr_aarch64);
diff --git a/libc/bionic/heap_tagging.cpp b/libc/bionic/heap_tagging.cpp
index bf73d4afd..49b02daf7 100644
--- a/libc/bionic/heap_tagging.cpp
+++ b/libc/bionic/heap_tagging.cpp
@@ -32,7 +32,6 @@
#include <bionic/pthread_internal.h>
#include <platform/bionic/malloc.h>
-#include <platform/bionic/mte_kernel.h>
extern "C" void scudo_malloc_disable_memory_tagging();
extern "C" void scudo_malloc_set_track_allocation_stacks(int);
@@ -54,7 +53,7 @@ void SetDefaultHeapTaggingLevel() {
(0xffull << CHECK_SHIFT) | (0xffull << UNTAG_SHIFT);
});
break;
-#if defined(ANDROID_EXPERIMENTAL_MTE) && defined(USE_SCUDO)
+#if defined(USE_SCUDO)
case M_HEAP_TAGGING_LEVEL_SYNC:
scudo_malloc_set_track_allocation_stacks(1);
break;
@@ -62,14 +61,13 @@ void SetDefaultHeapTaggingLevel() {
case M_HEAP_TAGGING_LEVEL_NONE:
scudo_malloc_disable_memory_tagging();
break;
-#endif // ANDROID_EXPERIMENTAL_MTE
+#endif // USE_SCUDO
default:
break;
}
#endif // aarch64
}
-#ifdef ANDROID_EXPERIMENTAL_MTE
static bool set_tcf_on_all_threads(int tcf) {
static int g_tcf;
g_tcf = tcf;
@@ -89,7 +87,6 @@ static bool set_tcf_on_all_threads(int tcf) {
},
nullptr);
}
-#endif
pthread_mutex_t g_heap_tagging_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -118,13 +115,9 @@ bool SetHeapTaggingLevel(void* arg, size_t arg_size) {
// tagged and checks no longer happen.
globals->heap_pointer_tag = static_cast<uintptr_t>(0xffull << UNTAG_SHIFT);
});
- } else {
-#if defined(ANDROID_EXPERIMENTAL_MTE)
- if (!set_tcf_on_all_threads(PR_MTE_TCF_NONE)) {
- error_log("SetHeapTaggingLevel: set_tcf_on_all_threads failed");
- return false;
- }
-#endif
+ } else if (!set_tcf_on_all_threads(PR_MTE_TCF_NONE)) {
+ error_log("SetHeapTaggingLevel: set_tcf_on_all_threads failed");
+ return false;
}
#if defined(USE_SCUDO)
scudo_malloc_disable_memory_tagging();
@@ -148,16 +141,12 @@ bool SetHeapTaggingLevel(void* arg, size_t arg_size) {
}
if (tag_level == M_HEAP_TAGGING_LEVEL_ASYNC) {
-#if defined(ANDROID_EXPERIMENTAL_MTE)
set_tcf_on_all_threads(PR_MTE_TCF_ASYNC);
-#endif
#if defined(USE_SCUDO)
scudo_malloc_set_track_allocation_stacks(0);
#endif
} else if (tag_level == M_HEAP_TAGGING_LEVEL_SYNC) {
-#if defined(ANDROID_EXPERIMENTAL_MTE)
set_tcf_on_all_threads(PR_MTE_TCF_SYNC);
-#endif
#if defined(USE_SCUDO)
scudo_malloc_set_track_allocation_stacks(1);
#endif
diff --git a/libc/platform/bionic/mte.h b/libc/platform/bionic/mte.h
index 1e393eb0c..b11b1a678 100644
--- a/libc/platform/bionic/mte.h
+++ b/libc/platform/bionic/mte.h
@@ -29,10 +29,9 @@
#pragma once
#include <sys/auxv.h>
-#include <bionic/mte_kernel.h>
inline bool mte_supported() {
-#if defined(__aarch64__) && defined(ANDROID_EXPERIMENTAL_MTE)
+#if defined(__aarch64__)
static bool supported = getauxval(AT_HWCAP2) & HWCAP2_MTE;
#else
static bool supported = false;
diff --git a/libc/platform/bionic/mte_kernel.h b/libc/platform/bionic/mte_kernel.h
deleted file mode 100644
index d81480aa7..000000000
--- a/libc/platform/bionic/mte_kernel.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#pragma once
-
-// Defines constants used as part of the interface in an experimental MTE branch
-// of the Linux kernel, which may be found at:
-//
-// https://github.com/pcc/linux/tree/android-experimental-mte
-//
-// This interface should not be considered to be stable.
-
-#ifdef ANDROID_EXPERIMENTAL_MTE
-
-#define HWCAP2_MTE (1 << 18)
-#define PROT_MTE 0x20
-
-#define PR_MTE_TCF_SHIFT 1
-#define PR_MTE_TCF_NONE (0UL << PR_MTE_TCF_SHIFT)
-#define PR_MTE_TCF_SYNC (1UL << PR_MTE_TCF_SHIFT)
-#define PR_MTE_TCF_ASYNC (2UL << PR_MTE_TCF_SHIFT)
-#define PR_MTE_TCF_MASK (3UL << PR_MTE_TCF_SHIFT)
-#define PR_MTE_TAG_SHIFT 3
-#define PR_MTE_TAG_MASK (0xffffUL << PR_MTE_TAG_SHIFT)
-
-#define SEGV_MTEAERR 8
-#define SEGV_MTESERR 9
-
-#define PTRACE_PEEKMTETAGS 33
-#define PTRACE_POKEMTETAGS 34
-
-#define NT_ARM_TAGGED_ADDR_CTRL 0x409
-
-#endif