Skip to content

Commit

Permalink
retag the first 16 byte granule upon free
Browse files Browse the repository at this point in the history
  • Loading branch information
struct committed Dec 22, 2023
1 parent 31b50a1 commit df83a0f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/iso_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit df83a0f

Please sign in to comment.