San: Rename 'guard' to 'san'
This prepares the foundation for more sanitizer-related work in the future.
This commit is contained in:
parent
d9bbf539ff
commit
62f9c54d2a
@ -119,7 +119,7 @@ C_SRCS := $(srcroot)src/jemalloc.c \
|
|||||||
$(srcroot)src/extent_dss.c \
|
$(srcroot)src/extent_dss.c \
|
||||||
$(srcroot)src/extent_mmap.c \
|
$(srcroot)src/extent_mmap.c \
|
||||||
$(srcroot)src/fxp.c \
|
$(srcroot)src/fxp.c \
|
||||||
$(srcroot)src/guard.c \
|
$(srcroot)src/san.c \
|
||||||
$(srcroot)src/hook.c \
|
$(srcroot)src/hook.c \
|
||||||
$(srcroot)src/hpa.c \
|
$(srcroot)src/hpa.c \
|
||||||
$(srcroot)src/hpa_hooks.c \
|
$(srcroot)src/hpa_hooks.c \
|
||||||
@ -219,7 +219,7 @@ TESTS_UNIT := \
|
|||||||
${srcroot}test/unit/fb.c \
|
${srcroot}test/unit/fb.c \
|
||||||
$(srcroot)test/unit/fork.c \
|
$(srcroot)test/unit/fork.c \
|
||||||
${srcroot}test/unit/fxp.c \
|
${srcroot}test/unit/fxp.c \
|
||||||
${srcroot}test/unit/guard.c \
|
${srcroot}test/unit/san.c \
|
||||||
$(srcroot)test/unit/hash.c \
|
$(srcroot)test/unit/hash.c \
|
||||||
$(srcroot)test/unit/hook.c \
|
$(srcroot)test/unit/hook.c \
|
||||||
$(srcroot)test/unit/hpa.c \
|
$(srcroot)test/unit/hpa.c \
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define JEMALLOC_INTERNAL_ECACHE_H
|
#define JEMALLOC_INTERNAL_ECACHE_H
|
||||||
|
|
||||||
#include "jemalloc/internal/eset.h"
|
#include "jemalloc/internal/eset.h"
|
||||||
#include "jemalloc/internal/guard.h"
|
#include "jemalloc/internal/san.h"
|
||||||
#include "jemalloc/internal/mutex.h"
|
#include "jemalloc/internal/mutex.h"
|
||||||
|
|
||||||
typedef struct ecache_s ecache_t;
|
typedef struct ecache_s ecache_t;
|
||||||
|
@ -13,15 +13,16 @@
|
|||||||
extern size_t opt_san_guard_large;
|
extern size_t opt_san_guard_large;
|
||||||
extern size_t opt_san_guard_small;
|
extern size_t opt_san_guard_small;
|
||||||
|
|
||||||
void guard_pages(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata, emap_t *emap);
|
void san_guard_pages(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata,
|
||||||
void unguard_pages(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata,
|
emap_t *emap);
|
||||||
|
void san_unguard_pages(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata,
|
||||||
emap_t *emap);
|
emap_t *emap);
|
||||||
/*
|
/*
|
||||||
* Unguard the extent, but don't modify emap boundaries. Must be called on an
|
* Unguard the extent, but don't modify emap boundaries. Must be called on an
|
||||||
* extent that has been erased from emap and shouldn't be placed back.
|
* extent that has been erased from emap and shouldn't be placed back.
|
||||||
*/
|
*/
|
||||||
void unguard_pages_pre_destroy(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata,
|
void san_unguard_pages_pre_destroy(tsdn_t *tsdn, ehooks_t *ehooks,
|
||||||
emap_t *emap);
|
edata_t *edata, emap_t *emap);
|
||||||
void tsd_san_init(tsd_t *tsd);
|
void tsd_san_init(tsd_t *tsd);
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
@ -30,7 +31,7 @@ san_enabled(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
large_extent_decide_guard(tsdn_t *tsdn, ehooks_t *ehooks, size_t size,
|
san_large_extent_decide_guard(tsdn_t *tsdn, ehooks_t *ehooks, size_t size,
|
||||||
size_t alignment) {
|
size_t alignment) {
|
||||||
if (opt_san_guard_large == 0 || ehooks_guard_will_fail(ehooks) ||
|
if (opt_san_guard_large == 0 || ehooks_guard_will_fail(ehooks) ||
|
||||||
tsdn_null(tsdn)) {
|
tsdn_null(tsdn)) {
|
||||||
@ -60,7 +61,7 @@ large_extent_decide_guard(tsdn_t *tsdn, ehooks_t *ehooks, size_t size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
slab_extent_decide_guard(tsdn_t *tsdn, ehooks_t *ehooks) {
|
san_slab_extent_decide_guard(tsdn_t *tsdn, ehooks_t *ehooks) {
|
||||||
if (opt_san_guard_small == 0 || ehooks_guard_will_fail(ehooks) ||
|
if (opt_san_guard_small == 0 || ehooks_guard_will_fail(ehooks) ||
|
||||||
tsdn_null(tsdn)) {
|
tsdn_null(tsdn)) {
|
||||||
return false;
|
return false;
|
@ -6,7 +6,7 @@
|
|||||||
#include "jemalloc/internal/ehooks.h"
|
#include "jemalloc/internal/ehooks.h"
|
||||||
#include "jemalloc/internal/extent_dss.h"
|
#include "jemalloc/internal/extent_dss.h"
|
||||||
#include "jemalloc/internal/extent_mmap.h"
|
#include "jemalloc/internal/extent_mmap.h"
|
||||||
#include "jemalloc/internal/guard.h"
|
#include "jemalloc/internal/san.h"
|
||||||
#include "jemalloc/internal/mutex.h"
|
#include "jemalloc/internal/mutex.h"
|
||||||
#include "jemalloc/internal/rtree.h"
|
#include "jemalloc/internal/rtree.h"
|
||||||
#include "jemalloc/internal/safety_check.h"
|
#include "jemalloc/internal/safety_check.h"
|
||||||
@ -328,7 +328,7 @@ arena_extent_alloc_large(tsdn_t *tsdn, arena_t *arena, size_t usize,
|
|||||||
szind_t szind = sz_size2index(usize);
|
szind_t szind = sz_size2index(usize);
|
||||||
size_t esize = usize + sz_large_pad;
|
size_t esize = usize + sz_large_pad;
|
||||||
|
|
||||||
bool guarded = large_extent_decide_guard(tsdn, arena_get_ehooks(arena),
|
bool guarded = san_large_extent_decide_guard(tsdn, arena_get_ehooks(arena),
|
||||||
esize, alignment);
|
esize, alignment);
|
||||||
edata_t *edata = pa_alloc(tsdn, &arena->pa_shard, esize, alignment,
|
edata_t *edata = pa_alloc(tsdn, &arena->pa_shard, esize, alignment,
|
||||||
/* slab */ false, szind, zero, guarded, &deferred_work_generated);
|
/* slab */ false, szind, zero, guarded, &deferred_work_generated);
|
||||||
@ -829,7 +829,7 @@ arena_slab_alloc(tsdn_t *tsdn, arena_t *arena, szind_t binind, unsigned binshard
|
|||||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||||
WITNESS_RANK_CORE, 0);
|
WITNESS_RANK_CORE, 0);
|
||||||
|
|
||||||
bool guarded = slab_extent_decide_guard(tsdn, arena_get_ehooks(arena));
|
bool guarded = san_slab_extent_decide_guard(tsdn, arena_get_ehooks(arena));
|
||||||
edata_t *slab = pa_alloc(tsdn, &arena->pa_shard, bin_info->slab_size,
|
edata_t *slab = pa_alloc(tsdn, &arena->pa_shard, bin_info->slab_size,
|
||||||
/* alignment */ PAGE, /* slab */ true, /* szind */ binind,
|
/* alignment */ PAGE, /* slab */ true, /* szind */ binind,
|
||||||
/* zero */ false, guarded, &deferred_work_generated);
|
/* zero */ false, guarded, &deferred_work_generated);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "jemalloc/internal/jemalloc_preamble.h"
|
#include "jemalloc/internal/jemalloc_preamble.h"
|
||||||
#include "jemalloc/internal/jemalloc_internal_includes.h"
|
#include "jemalloc/internal/jemalloc_internal_includes.h"
|
||||||
|
|
||||||
#include "jemalloc/internal/guard.h"
|
#include "jemalloc/internal/san.h"
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ecache_init(tsdn_t *tsdn, ecache_t *ecache, extent_state_t state, unsigned ind,
|
ecache_init(tsdn_t *tsdn, ecache_t *ecache, extent_state_t state, unsigned ind,
|
||||||
|
@ -1013,7 +1013,7 @@ extent_dalloc_wrapper(tsdn_t *tsdn, pac_t *pac, ehooks_t *ehooks,
|
|||||||
/* Restore guard pages for dalloc / unmap. */
|
/* Restore guard pages for dalloc / unmap. */
|
||||||
if (edata_guarded_get(edata)) {
|
if (edata_guarded_get(edata)) {
|
||||||
assert(ehooks_are_default(ehooks));
|
assert(ehooks_are_default(ehooks));
|
||||||
unguard_pages(tsdn, ehooks, edata, pac->emap);
|
san_unguard_pages(tsdn, ehooks, edata, pac->emap);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Deregister first to avoid a race with other allocating
|
* Deregister first to avoid a race with other allocating
|
||||||
@ -1063,7 +1063,7 @@ extent_destroy_wrapper(tsdn_t *tsdn, pac_t *pac, ehooks_t *ehooks,
|
|||||||
WITNESS_RANK_CORE, 0);
|
WITNESS_RANK_CORE, 0);
|
||||||
|
|
||||||
if (edata_guarded_get(edata)) {
|
if (edata_guarded_get(edata)) {
|
||||||
unguard_pages_pre_destroy(tsdn, ehooks, edata, pac->emap);
|
san_unguard_pages_pre_destroy(tsdn, ehooks, edata, pac->emap);
|
||||||
}
|
}
|
||||||
edata_addr_set(edata, edata_base_get(edata));
|
edata_addr_set(edata, edata_base_get(edata));
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "jemalloc/internal/extent_dss.h"
|
#include "jemalloc/internal/extent_dss.h"
|
||||||
#include "jemalloc/internal/extent_mmap.h"
|
#include "jemalloc/internal/extent_mmap.h"
|
||||||
#include "jemalloc/internal/fxp.h"
|
#include "jemalloc/internal/fxp.h"
|
||||||
#include "jemalloc/internal/guard.h"
|
#include "jemalloc/internal/san.h"
|
||||||
#include "jemalloc/internal/hook.h"
|
#include "jemalloc/internal/hook.h"
|
||||||
#include "jemalloc/internal/jemalloc_internal_types.h"
|
#include "jemalloc/internal/jemalloc_internal_types.h"
|
||||||
#include "jemalloc/internal/log.h"
|
#include "jemalloc/internal/log.h"
|
||||||
|
2
src/pa.c
2
src/pa.c
@ -1,7 +1,7 @@
|
|||||||
#include "jemalloc/internal/jemalloc_preamble.h"
|
#include "jemalloc/internal/jemalloc_preamble.h"
|
||||||
#include "jemalloc/internal/jemalloc_internal_includes.h"
|
#include "jemalloc/internal/jemalloc_internal_includes.h"
|
||||||
|
|
||||||
#include "jemalloc/internal/guard.h"
|
#include "jemalloc/internal/san.h"
|
||||||
#include "jemalloc/internal/hpa.h"
|
#include "jemalloc/internal/hpa.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "jemalloc/internal/jemalloc_internal_includes.h"
|
#include "jemalloc/internal/jemalloc_internal_includes.h"
|
||||||
|
|
||||||
#include "jemalloc/internal/pac.h"
|
#include "jemalloc/internal/pac.h"
|
||||||
#include "jemalloc/internal/guard.h"
|
#include "jemalloc/internal/san.h"
|
||||||
|
|
||||||
static edata_t *pac_alloc_impl(tsdn_t *tsdn, pai_t *self, size_t size,
|
static edata_t *pac_alloc_impl(tsdn_t *tsdn, pai_t *self, size_t size,
|
||||||
size_t alignment, bool zero, bool guarded, bool *deferred_work_generated);
|
size_t alignment, bool zero, bool guarded, bool *deferred_work_generated);
|
||||||
@ -146,7 +146,7 @@ pac_alloc_new_guarded(tsdn_t *tsdn, pac_t *pac, ehooks_t *ehooks, size_t size,
|
|||||||
if (edata != NULL) {
|
if (edata != NULL) {
|
||||||
/* Add guards around it. */
|
/* Add guards around it. */
|
||||||
assert(edata_size_get(edata) == size_with_guards);
|
assert(edata_size_get(edata) == size_with_guards);
|
||||||
guard_pages(tsdn, ehooks, edata, pac->emap);
|
san_guard_pages(tsdn, ehooks, edata, pac->emap);
|
||||||
}
|
}
|
||||||
assert(edata == NULL || (edata_guarded_get(edata) &&
|
assert(edata == NULL || (edata_guarded_get(edata) &&
|
||||||
edata_size_get(edata) == size));
|
edata_size_get(edata) == size));
|
||||||
@ -253,7 +253,7 @@ pac_dalloc_impl(tsdn_t *tsdn, pai_t *self, edata_t *edata,
|
|||||||
if (!edata_slab_get(edata) || !maps_coalesce) {
|
if (!edata_slab_get(edata) || !maps_coalesce) {
|
||||||
assert(edata_size_get(edata) >= SC_LARGE_MINCLASS ||
|
assert(edata_size_get(edata) >= SC_LARGE_MINCLASS ||
|
||||||
!maps_coalesce);
|
!maps_coalesce);
|
||||||
unguard_pages(tsdn, ehooks, edata, pac->emap);
|
san_unguard_pages(tsdn, ehooks, edata, pac->emap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "jemalloc/internal/assert.h"
|
#include "jemalloc/internal/assert.h"
|
||||||
#include "jemalloc/internal/ehooks.h"
|
#include "jemalloc/internal/ehooks.h"
|
||||||
#include "jemalloc/internal/guard.h"
|
#include "jemalloc/internal/san.h"
|
||||||
#include "jemalloc/internal/tsd.h"
|
#include "jemalloc/internal/tsd.h"
|
||||||
|
|
||||||
/* The sanitizer options. */
|
/* The sanitizer options. */
|
||||||
@ -11,7 +11,7 @@ size_t opt_san_guard_large = SAN_GUARD_LARGE_EVERY_N_EXTENTS_DEFAULT;
|
|||||||
size_t opt_san_guard_small = SAN_GUARD_SMALL_EVERY_N_EXTENTS_DEFAULT;
|
size_t opt_san_guard_small = SAN_GUARD_SMALL_EVERY_N_EXTENTS_DEFAULT;
|
||||||
|
|
||||||
void
|
void
|
||||||
guard_pages(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata, emap_t *emap) {
|
san_guard_pages(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata, emap_t *emap) {
|
||||||
emap_deregister_boundary(tsdn, emap, edata);
|
emap_deregister_boundary(tsdn, emap, edata);
|
||||||
|
|
||||||
size_t size_with_guards = edata_size_get(edata);
|
size_t size_with_guards = edata_size_get(edata);
|
||||||
@ -33,8 +33,8 @@ guard_pages(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata, emap_t *emap) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unguard_pages_impl(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata, emap_t *emap,
|
san_unguard_pages_impl(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata,
|
||||||
bool reg_emap) {
|
emap_t *emap, bool reg_emap) {
|
||||||
/* Remove the inner boundary which no longer exists. */
|
/* Remove the inner boundary which no longer exists. */
|
||||||
if (reg_emap) {
|
if (reg_emap) {
|
||||||
assert(edata_state_get(edata) == extent_state_active);
|
assert(edata_state_get(edata) == extent_state_active);
|
||||||
@ -68,15 +68,16 @@ unguard_pages_impl(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata, emap_t *emap,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
unguard_pages(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata, emap_t *emap) {
|
san_unguard_pages(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata,
|
||||||
unguard_pages_impl(tsdn, ehooks, edata, emap, /* reg_emap */ true);
|
emap_t *emap) {
|
||||||
|
san_unguard_pages_impl(tsdn, ehooks, edata, emap, /* reg_emap */ true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
unguard_pages_pre_destroy(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata,
|
san_unguard_pages_pre_destroy(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata,
|
||||||
emap_t *emap) {
|
emap_t *emap) {
|
||||||
emap_assert_not_mapped(tsdn, emap, edata);
|
emap_assert_not_mapped(tsdn, emap, edata);
|
||||||
unguard_pages_impl(tsdn, ehooks, edata, emap, /* reg_emap */ false);
|
san_unguard_pages_impl(tsdn, ehooks, edata, emap, /* reg_emap */ false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
@ -2,7 +2,7 @@
|
|||||||
#include "jemalloc/internal/jemalloc_internal_includes.h"
|
#include "jemalloc/internal/jemalloc_internal_includes.h"
|
||||||
|
|
||||||
#include "jemalloc/internal/assert.h"
|
#include "jemalloc/internal/assert.h"
|
||||||
#include "jemalloc/internal/guard.h"
|
#include "jemalloc/internal/san.h"
|
||||||
#include "jemalloc/internal/mutex.h"
|
#include "jemalloc/internal/mutex.h"
|
||||||
#include "jemalloc/internal/rtree.h"
|
#include "jemalloc/internal/rtree.h"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "test/jemalloc_test.h"
|
#include "test/jemalloc_test.h"
|
||||||
#include "test/guard.h"
|
#include "test/san.h"
|
||||||
|
|
||||||
#include "jemalloc/internal/safety_check.h"
|
#include "jemalloc/internal/safety_check.h"
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "test/jemalloc_test.h"
|
#include "test/jemalloc_test.h"
|
||||||
|
|
||||||
#include "jemalloc/internal/guard.h"
|
#include "jemalloc/internal/san.h"
|
||||||
#include "jemalloc/internal/spin.h"
|
#include "jemalloc/internal/spin.h"
|
||||||
|
|
||||||
static unsigned arena_ind;
|
static unsigned arena_ind;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "test/jemalloc_test.h"
|
#include "test/jemalloc_test.h"
|
||||||
#include "test/arena_decay.h"
|
#include "test/arena_decay.h"
|
||||||
#include "test/guard.h"
|
#include "test/san.h"
|
||||||
|
|
||||||
#include "jemalloc/internal/guard.h"
|
#include "jemalloc/internal/san.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
verify_extent_guarded(tsdn_t *tsdn, void *ptr) {
|
verify_extent_guarded(tsdn_t *tsdn, void *ptr) {
|
Loading…
Reference in New Issue
Block a user