mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2025-05-10 02:05:06 -04:00
label allocate_aligned_pages mappings
This commit is contained in:
parent
c8b948e202
commit
1d62075291
3 changed files with 8 additions and 7 deletions
11
pages.c
11
pages.c
|
@ -27,11 +27,7 @@ void *allocate_pages(size_t usable_size, size_t guard_size, bool unprotect, cons
|
|||
return usable;
|
||||
}
|
||||
|
||||
void deallocate_pages(void *usable, size_t usable_size, size_t guard_size) {
|
||||
memory_unmap((char *)usable - guard_size, usable_size + guard_size * 2);
|
||||
}
|
||||
|
||||
void *allocate_pages_aligned(size_t usable_size, size_t alignment, size_t guard_size) {
|
||||
void *allocate_pages_aligned(size_t usable_size, size_t alignment, size_t guard_size, const char *name) {
|
||||
usable_size = PAGE_CEILING(usable_size);
|
||||
if (unlikely(!usable_size)) {
|
||||
errno = ENOMEM;
|
||||
|
@ -54,6 +50,7 @@ void *allocate_pages_aligned(size_t usable_size, size_t alignment, size_t guard_
|
|||
if (unlikely(real == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
memory_set_name(real, real_alloc_size, name);
|
||||
|
||||
void *usable = (char *)real + guard_size;
|
||||
|
||||
|
@ -82,3 +79,7 @@ void *allocate_pages_aligned(size_t usable_size, size_t alignment, size_t guard_
|
|||
|
||||
return base;
|
||||
}
|
||||
|
||||
void deallocate_pages(void *usable, size_t usable_size, size_t guard_size) {
|
||||
memory_unmap((char *)usable - guard_size, usable_size + guard_size * 2);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue