summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorPeter Collingbourne <pcc@google.com>2020-02-19 17:59:54 -0800
committerPeter Collingbourne <pcc@google.com>2020-04-03 11:04:51 -0700
commitf78e085068639b98f9d6cc0549bfdd6677a8f6d1 (patch)
tree939a66e491ab0f76fe479b758d4826676ebe08d5 /core/java
parent49fa6ba37ff9e71a61e601ab8c1cde3735727223 (diff)
Implement initial policy for memory tag checks.
System apps and the system_server receive async tag checks, while all other app processes have it disabled. Developers may enable async tag checks per application with: $ adb shell am compat 135772972 <app.name> Bug: 135772972 Change-Id: I154623941eec8e79af347453fbca1b062346c85b Merged-In: I154623941eec8e79af347453fbca1b062346c85b
Diffstat (limited to 'core/java')
-rw-r--r--core/java/com/android/internal/os/Zygote.java5
-rw-r--r--core/java/com/android/internal/os/ZygoteInit.java12
2 files changed, 14 insertions, 3 deletions
diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java
index 5f196a0e4c1c..f7ac8e801f36 100644
--- a/core/java/com/android/internal/os/Zygote.java
+++ b/core/java/com/android/internal/os/Zygote.java
@@ -977,4 +977,9 @@ public final class Zygote {
*/
@FastNative
public static native int nativeParseSigChld(byte[] in, int length, int[] out);
+
+ /**
+ * Returns whether the hardware supports memory tagging (ARM MTE).
+ */
+ public static native boolean nativeSupportsMemoryTagging();
}
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
index 300f71af5dd5..9d7d9625a944 100644
--- a/core/java/com/android/internal/os/ZygoteInit.java
+++ b/core/java/com/android/internal/os/ZygoteInit.java
@@ -781,9 +781,15 @@ public class ZygoteInit {
Zygote.applyDebuggerSystemProperty(parsedArgs);
Zygote.applyInvokeWithSystemProperty(parsedArgs);
- /* Enable pointer tagging in the system server unconditionally. Hardware support for
- * this is present in all ARMv8 CPUs; this flag has no effect on other platforms. */
- parsedArgs.mRuntimeFlags |= Zygote.MEMORY_TAG_LEVEL_TBI;
+ if (Zygote.nativeSupportsMemoryTagging()) {
+ /* The system server is more privileged than regular app processes, so it has async
+ * tag checks enabled on hardware that supports memory tagging. */
+ parsedArgs.mRuntimeFlags |= Zygote.MEMORY_TAG_LEVEL_ASYNC;
+ } else {
+ /* Enable pointer tagging in the system server. Hardware support for this is present
+ * in all ARMv8 CPUs; this flag has no effect on other platforms. */
+ parsedArgs.mRuntimeFlags |= Zygote.MEMORY_TAG_LEVEL_TBI;
+ }
if (shouldProfileSystemServer()) {
parsedArgs.mRuntimeFlags |= Zygote.PROFILE_SYSTEM_SERVER;