From 70c91f4c3e553bc37e146c9c545a186e4ec02054 Mon Sep 17 00:00:00 2001 From: Dmitry Muhomor Date: Thu, 26 Oct 2023 10:17:21 +0300 Subject: [PATCH] mte: disable write-after-free check for slab allocations when MTE is on Freed slab memory is tagged with a reserved tag value that is never used for live allocations. --- h_malloc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/h_malloc.c b/h_malloc.c index 098eb37..fc36ad7 100644 --- a/h_malloc.c +++ b/h_malloc.c @@ -464,6 +464,12 @@ static void write_after_free_check(const char *p, size_t size) { return; } +#ifdef HAS_ARM_MTE + if (likely(is_memtag_enabled())) { + return; + } +#endif + for (size_t i = 0; i < size; i += sizeof(u64)) { if (unlikely(*(const u64 *)(const void *)(p + i))) { fatal_error("detected write after free");