[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
Change-Id: I47c635897e0b50bbe4367a869d9b53fa45be0dc0
diff --git a/libc/bionic/heap_tagging.cpp b/libc/bionic/heap_tagging.cpp
index 066ec32..6741be3 100644
--- a/libc/bionic/heap_tagging.cpp
+++ b/libc/bionic/heap_tagging.cpp
@@ -186,6 +186,9 @@
#ifdef __aarch64__
static inline __attribute__((no_sanitize("memtag"))) void untag_memory(void* from, void* to) {
+ if (from == to) {
+ return;
+ }
__asm__ __volatile__(
".arch_extension mte\n"
"1:\n"