diff options
| author | Mitch Phillips <mitchp@google.com> | 2021-02-04 09:38:40 -0800 |
|---|---|---|
| committer | Mitch Phillips <mitchp@google.com> | 2021-02-04 15:28:07 -0800 |
| commit | b8d053a81567d431c192f030a9acc45b581cd1f5 (patch) | |
| tree | 3b2cf1f52b35d573d63e48c7757c1fe07c0a245b /core/java | |
| parent | 0db5d441ad620d1a1f53b16c2cd0f462fe600827 (diff) | |
[MTE] Parse MTE sysprop in system_server
The system server inherits the ELF note from the Zygote, but should also
be able to be overwritten by the system property. This needs to be
manually parsed.
Bug: 172365548
Test: 'adb shell setprop arm64.memtag.process.system_server 123' \
Test: ... kill the system_server, and and look in logcat for
Test ... "Unknown memory tag level for the system server".
Test: 'adb shell setprop arm64.memtag.process.system_server sync' \
Test: ... kill the system_server, and look in logcat for
Test: ... "SetHeapTaggingLevel: tag level set to 3".
Change-Id: Icda4ff141646086ae85d751b8af9b1fe94bfd7b5
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/com/android/internal/os/Zygote.java | 7 | ||||
| -rw-r--r-- | core/java/com/android/internal/os/ZygoteInit.java | 16 |
2 files changed, 20 insertions, 3 deletions
diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java index 0381a75d722b..395c05561fb5 100644 --- a/core/java/com/android/internal/os/Zygote.java +++ b/core/java/com/android/internal/os/Zygote.java @@ -1103,4 +1103,11 @@ public final class Zygote { * fully-feature Memory Tagging, rather than the static Tagged Pointers. */ public static native boolean nativeSupportsTaggedPointers(); + + /** + * Returns the current native tagging level, as one of the + * MEMORY_TAG_LEVEL_* constants. Returns zero if no tagging is present, or + * we failed to determine the level. + */ + public static native int nativeCurrentTaggingLevel(); } diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index 6335baa97e57..7fde5474ec92 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -791,9 +791,19 @@ public class ZygoteInit { Zygote.applyInvokeWithSystemProperty(parsedArgs); 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; + /* The system server has ASYNC MTE by default, in order to allow + * system services to specify their own MTE level later, as you + * can't re-enable MTE once it's disabled. */ + String mode = SystemProperties.get("arm64.memtag.process.system_server", "async"); + if (mode.equals("async")) { + parsedArgs.mRuntimeFlags |= Zygote.MEMORY_TAG_LEVEL_ASYNC; + } else if (mode.equals("sync")) { + parsedArgs.mRuntimeFlags |= Zygote.MEMORY_TAG_LEVEL_SYNC; + } else if (!mode.equals("off")) { + /* When we have an invalid memory tag level, keep the current level. */ + parsedArgs.mRuntimeFlags |= Zygote.nativeCurrentTaggingLevel(); + Slog.e(TAG, "Unknown memory tag level for the system server: \"" + mode + "\""); + } } else if (Zygote.nativeSupportsTaggedPointers()) { /* Enable pointer tagging in the system server. Hardware support for this is present * in all ARMv8 CPUs. */ |
