[MTE] fix longjmp handling

untag_memory didn't correctly handle the case where from = to, and would
always untag the first byte.

not changing the assembly for now to make this more obvious for
cherry-picking purposes.

Test: atest bionic-unit-tests-static
Bug: 348142687
(cherry picked from https://android-review.googlesource.com/q/commit:6b174efa140304f857547e3058baff445dd2f17f)
Merged-In: I47c635897e0b50bbe4367a869d9b53fa45be0dc0
Change-Id: I47c635897e0b50bbe4367a869d9b53fa45be0dc0
This commit is contained in:
Florian Mayer 2024-06-21 16:15:12 -07:00 committed by Android Build Coastguard Worker
parent 0ccd76cbb6
commit 59dc7956ff

View file

@ -184,6 +184,9 @@ bool SetHeapTaggingLevel(HeapTaggingLevel tag_level) {
#ifdef __aarch64__ #ifdef __aarch64__
static inline __attribute__((no_sanitize("memtag"))) void untag_memory(void* from, void* to) { static inline __attribute__((no_sanitize("memtag"))) void untag_memory(void* from, void* to) {
if (from == to) {
return;
}
__asm__ __volatile__( __asm__ __volatile__(
".arch_extension mte\n" ".arch_extension mte\n"
"1:\n" "1:\n"