mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2025-05-25 01:11:21 -04:00
add support for labelling memory regions
This commit is contained in:
parent
ae96835b94
commit
c9df70d934
4 changed files with 31 additions and 0 deletions
15
memory.c
15
memory.c
|
@ -1,6 +1,15 @@
|
|||
#include <errno.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <sys/prctl.h>
|
||||
|
||||
#ifndef PR_SET_VMA
|
||||
#define PR_SET_VMA 0x53564d41
|
||||
#endif
|
||||
|
||||
#ifndef PR_SET_VMA_ANON_NAME
|
||||
#define PR_SET_VMA_ANON_NAME 0
|
||||
#endif
|
||||
|
||||
#include "memory.h"
|
||||
#include "util.h"
|
||||
|
@ -80,3 +89,9 @@ int memory_remap_fixed(void *old, size_t old_size, void *new, size_t new_size) {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void memory_set_name(UNUSED void *ptr, UNUSED size_t size, UNUSED const char *name) {
|
||||
#ifdef LABEL_MEMORY
|
||||
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, ptr, size, name);
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue