1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-05 19:35:52 +03:00

malloc: Decorate malloc maps

Add anonymous mmap annotations on loader malloc, malloc when it
allocates memory with mmap, and on malloc arena.  The /proc/self/maps
will now print:

   [anon: glibc: malloc arena]
   [anon: glibc: malloc]
   [anon: glibc: loader malloc]

On arena allocation, glibc annotates only the read/write mapping.

Checked on x86_64-linux-gnu and aarch64-linux-gnu.
Reviewed-by: DJ Delorie <dj@redhat.com>
This commit is contained in:
Adhemerval Zanella
2023-11-01 09:56:08 -03:00
parent 6afce56c19
commit fee9e40a8d
6 changed files with 55 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
not, see <https://www.gnu.org/licenses/>. */
#include <stdbool.h>
#include <setvmaname.h>
#define TUNABLE_NAMESPACE malloc
#include <elf/dl-tunables.h>
@@ -436,6 +437,9 @@ alloc_new_heap (size_t size, size_t top_pad, size_t pagesize,
return 0;
}
/* Only considere the actual usable range. */
__set_vma_name (p2, size, " glibc: malloc arena");
madvise_thp (p2, size);
h = (heap_info *) p2;