ARM メモリタグ付け拡張機能(MTE)は、メモリの安全性に関する問題に対処するのに役立ちます。MTE は、スタック、ヒープ、グローバルの各メモリ割り当ての 56~59 番目のアドレスビットをタグ付けすることで機能します。ハードウェアと命令セットは、メモリアクセス時に正しいタグが使用されているかどうかを自動的に確認します。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-27 UTC。"],[],[],null,["# Tagged pointers\n\nStarting in Android 11, for 64-bit processes, all heap allocations have\nan implementation defined tag set in the top byte of the pointer on devices with\nkernel support for ARM Top-byte Ignore (TBI). Any app that modifies this\ntag is terminated when the tag is checked during deallocation. This is necessary\nfor future hardware with [ARM Memory Tagging Extension](https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/enhancing-memory-safety) (MTE) support.\n\nTop-byte ignore\n---------------\n\nARM's Top-byte Ignore feature is available for 64-bit code in all Armv8 AArch64 hardware.\nThis feature means that the hardware ignores the top byte of a pointer when\naccessing memory.\n\nTBI requires a [compatible\nkernel](https://www.kernel.org/doc/html/latest/arm64/tagged-address-abi.html#id1) that correctly handles tagged pointers passed from userspace.\nAndroid Common Kernels from 4.14 (Pixel 4) and higher feature the required [TBI\npatches](https://android-review.googlesource.com/c/kernel/common/+/1132334/).\n\nDevices with the TBI support in the kernel are dynamically detected at\nprocess start time and an implementation-dependent tag is inserted into the top\nbyte of the pointer for all heap allocations. After this, a check is run to\nensure the tag hasn't been truncated when deallocating the memory.\n\nMemory Tagging Extension readiness\n----------------------------------\n\nARM's Memory Tagging Extension (MTE) helps address memory safety issues. MTE\nworks by **tagging** the 56th-59th address bits of each memory\nallocation on the stack, heap, and globals. The hardware and instruction set\nautomatically checks that the correct tag is used upon every memory access.\n\nAndroid apps that incorrectly store information in the top byte of the\npointer are **guaranteed to break on an MTE-enabled device**.\nTagged pointers make it easier to detect and reject incorrect uses of the top\nbyte of the pointer before MTE devices are available.\n\nDeveloper support\n-----------------\n\n| **Note:** You'll need to test the 64-bit version of your app to be able to reproduce tagged pointer issues.\n\nIf your app crashed and you were prompted with this link, it could mean\none of the following:\n\n1. The app tried to free a pointer that wasn't allocated by the system's heap allocator.\n2. Something in your app modified the top byte of a pointer. The top byte of the pointer can't be modified and your code needs to be changed to fix this issue.\n\nExamples of the top byte pointer being incorrectly used or modified.\n\n- Pointers to a particular type have app specific metadata stored in the top 16 address bits.\n- A pointer cast to double and then back, losing the lower address bits.\n- Code computing the difference between the addresses of local variables from different stack frames as a way to measure recursion depth.\n\nSome apps may depend on libraries that behave incorrectly when the\ntop byte of the pointer is set. We recognize that it might be\nnontrivial to fix these underlying problems in libraries quickly. As such,\napps that use `targetSdkLevel \u003c 30`\nwon't have pointer tagging enabled by default. We also provide an escape\nhatch for apps built with `targetSdkLevel \u003e= 30`\nto ease the transitional period.\n\nThe escape hatch is used by adding the following to your\n`AndroidManifest.xml` file: \n\n```text\n \u003capplication android:allowNativeHeapPointerTagging=\"false\"\u003e\n ...\n \u003c/application\u003e\n```\n\nThis disables the Pointer Tagging feature for your\napp. This does **not** address the\nunderlying code health problem. This escape hatch will disappear in future\nversions of Android, because issues of this nature will be incompatible with\n[MTE](https://security.googleblog.com/2019/08/adopting-arm-memory-tagging-extension.html)."]]