mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2024-10-01 01:36:01 -04:00
configuration for guard region sizes
This commit is contained in:
parent
d18b05eaf4
commit
4ee12e64e0
1
config.h
1
config.h
@ -8,5 +8,6 @@
|
|||||||
#define SLOT_RANDOMIZE true
|
#define SLOT_RANDOMIZE true
|
||||||
#define ZERO_ON_FREE true
|
#define ZERO_ON_FREE true
|
||||||
#define SLAB_CANARY true
|
#define SLAB_CANARY true
|
||||||
|
#define GUARD_SIZE_DIVISOR 2
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
2
malloc.c
2
malloc.c
@ -729,7 +729,7 @@ COLD __attribute__((constructor(101))) static void trigger_early_init(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static size_t get_guard_size(struct random_state *state, size_t size) {
|
static size_t get_guard_size(struct random_state *state, size_t size) {
|
||||||
return (get_random_u64_uniform(state, size / PAGE_SIZE / 2) + 1) * PAGE_SIZE;
|
return (get_random_u64_uniform(state, size / PAGE_SIZE / GUARD_SIZE_DIVISOR) + 1) * PAGE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *allocate(size_t size) {
|
static void *allocate(size_t size) {
|
||||||
|
Loading…
Reference in New Issue
Block a user