mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2025-08-18 11:17:50 -04:00
label allocate_pages mappings
This commit is contained in:
parent
65311a5df2
commit
45337ebe07
3 changed files with 6 additions and 6 deletions
3
pages.c
3
pages.c
|
@ -8,7 +8,7 @@ static uintptr_t alignment_ceiling(uintptr_t s, uintptr_t alignment) {
|
|||
return ((s) + (alignment - 1)) & ((~alignment) + 1);
|
||||
}
|
||||
|
||||
void *allocate_pages(size_t usable_size, size_t guard_size, bool unprotect) {
|
||||
void *allocate_pages(size_t usable_size, size_t guard_size, bool unprotect, const char *name) {
|
||||
size_t real_size;
|
||||
if (unlikely(__builtin_add_overflow(usable_size, guard_size * 2, &real_size))) {
|
||||
errno = ENOMEM;
|
||||
|
@ -18,6 +18,7 @@ void *allocate_pages(size_t usable_size, size_t guard_size, bool unprotect) {
|
|||
if (unlikely(real == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
memory_set_name(real, real_size, name);
|
||||
void *usable = (char *)real + guard_size;
|
||||
if (unprotect && unlikely(memory_protect_rw(usable, usable_size))) {
|
||||
memory_unmap(real, real_size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue