From df83a0f89834c6ed807f25614d30a3d4a45653fc Mon Sep 17 00:00:00 2001 From: struct Date: Fri, 22 Dec 2023 16:11:24 -0500 Subject: [PATCH] retag the first 16 byte granule upon free --- src/iso_alloc.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/iso_alloc.c b/src/iso_alloc.c index d8b49d2..068b972 100644 --- a/src/iso_alloc.c +++ b/src/iso_alloc.c @@ -1420,9 +1420,6 @@ INTERNAL_HIDDEN void _iso_free_from_zone(void *p, iso_alloc_zone_t *zone, bool p #if ARM_MTE if(_root->arm_mte_enabled == true) { - /* We want to catch immediate use-after-free without waiting - * for chunks to be free'd from the quarantine so we set a new - * random tag for the first 16 byte granule at this address */ p = iso_mte_create_tag(p, 0x0); iso_mte_set_tag(p); } @@ -1488,6 +1485,16 @@ INTERNAL_HIDDEN void _iso_free(void *p, bool permanent) { return; } +#if ARM_MTE + if(_root->arm_mte_enabled == true) { + /* We want to catch immediate use-after-free without waiting + * for chunks to be free'd from the quarantine so we set a new + * random tag for the first 16 byte granule at this address */ + p = iso_mte_create_tag(p, 0x0); + iso_mte_set_tag(p); + } +#endif + LOCK_ROOT(); if(_root->chunk_quarantine_count >= CHUNK_QUARANTINE_SZ) {