aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2021-02-04 11:52:14 +0000
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2021-03-26 11:03:06 +0000
commitb9b85be6ea97c126ad6f69f84f056bad6756ee5c (patch)
treec9c8044457c27cd6ff08cbdf4dc92c2cab3f44a2
parent91e5c439d3130a3c5ff3a3b72adedd50f3f72f76 (diff)
downloadglibc-b9b85be6ea97c126ad6f69f84f056bad6756ee5c.tar
glibc-b9b85be6ea97c126ad6f69f84f056bad6756ee5c.tar.gz
glibc-b9b85be6ea97c126ad6f69f84f056bad6756ee5c.tar.bz2
glibc-b9b85be6ea97c126ad6f69f84f056bad6756ee5c.zip
malloc: Avoid taggig mmaped memory on free
Either the memory belongs to the dumped area, in which case we don't want to tag (the dumped area has the same tag as malloc internal data so tagging is unnecessary, but chunks there may not have the right alignment for the tag granule), or the memory will be unmapped immediately (and thus tagging is not useful). Reviewed-by: DJ Delorie <dj@redhat.com>
-rw-r--r--malloc/malloc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 9dd811b26a..339304269c 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -3284,9 +3284,6 @@ __libc_free (void *mem)
p = mem2chunk (mem);
- /* Mark the chunk as belonging to the library again. */
- (void)TAG_REGION (chunk2rawmem (p), CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ);
-
if (chunk_is_mmapped (p)) /* release mmapped memory. */
{
/* See if the dynamic brk/mmap threshold needs adjusting.
@@ -3307,6 +3304,10 @@ __libc_free (void *mem)
{
MAYBE_INIT_TCACHE ();
+ /* Mark the chunk as belonging to the library again. */
+ (void)TAG_REGION (chunk2rawmem (p),
+ CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ);
+
ar_ptr = arena_for_chunk (p);
_int_free (ar_ptr, p, 0);
}