mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2025-05-24 17:01:21 -04:00
delay allocating slab metadata from reservation
This commit is contained in:
parent
74139112d0
commit
fe30f6c2ea
2 changed files with 13 additions and 5 deletions
6
malloc.c
6
malloc.c
|
@ -176,7 +176,7 @@ static struct slab_metadata *alloc_metadata(struct size_class *c, size_t slab_si
|
|||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
size_t allocate = c->metadata_allocated * 2;
|
||||
size_t allocate = max(c->metadata_allocated * 2, PAGE_SIZE / sizeof(struct slab_metadata));
|
||||
if (allocate > metadata_max) {
|
||||
allocate = metadata_max;
|
||||
}
|
||||
|
@ -825,10 +825,6 @@ COLD static void init_slow_path(void) {
|
|||
if (c->slab_info == NULL) {
|
||||
fatal_error("failed to allocate slab metadata");
|
||||
}
|
||||
c->metadata_allocated = PAGE_SIZE / sizeof(struct slab_metadata);
|
||||
if (memory_protect_rw(c->slab_info, c->metadata_allocated * sizeof(struct slab_metadata))) {
|
||||
fatal_error("failed to allocate initial slab info");
|
||||
}
|
||||
}
|
||||
|
||||
deallocate_pages(rng, sizeof(struct random_state), PAGE_SIZE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue