From 59dc7956ff8b8d4f06439ab24eed562db695df8a Mon Sep 17 00:00:00 2001 From: Florian Mayer Date: Fri, 21 Jun 2024 16:15:12 -0700 Subject: [PATCH] [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 --- libc/bionic/heap_tagging.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libc/bionic/heap_tagging.cpp b/libc/bionic/heap_tagging.cpp index cadab3ceb..3d92404da 100644 --- a/libc/bionic/heap_tagging.cpp +++ b/libc/bionic/heap_tagging.cpp @@ -184,6 +184,9 @@ bool SetHeapTaggingLevel(HeapTaggingLevel tag_level) { #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"