diff --git a/Makefile.in b/Makefile.in index abd361fd..8f96a992 100644 --- a/Makefile.in +++ b/Makefile.in @@ -119,7 +119,7 @@ C_SRCS := $(srcroot)src/jemalloc.c \ $(srcroot)src/extent_dss.c \ $(srcroot)src/extent_mmap.c \ $(srcroot)src/fxp.c \ - $(srcroot)src/guard.c \ + $(srcroot)src/san.c \ $(srcroot)src/hook.c \ $(srcroot)src/hpa.c \ $(srcroot)src/hpa_hooks.c \ @@ -219,7 +219,7 @@ TESTS_UNIT := \ ${srcroot}test/unit/fb.c \ $(srcroot)test/unit/fork.c \ ${srcroot}test/unit/fxp.c \ - ${srcroot}test/unit/guard.c \ + ${srcroot}test/unit/san.c \ $(srcroot)test/unit/hash.c \ $(srcroot)test/unit/hook.c \ $(srcroot)test/unit/hpa.c \ diff --git a/include/jemalloc/internal/ecache.h b/include/jemalloc/internal/ecache.h index dd1bc320..71cae3e3 100644 --- a/include/jemalloc/internal/ecache.h +++ b/include/jemalloc/internal/ecache.h @@ -2,7 +2,7 @@ #define JEMALLOC_INTERNAL_ECACHE_H #include "jemalloc/internal/eset.h" -#include "jemalloc/internal/guard.h" +#include "jemalloc/internal/san.h" #include "jemalloc/internal/mutex.h" typedef struct ecache_s ecache_t; diff --git a/include/jemalloc/internal/guard.h b/include/jemalloc/internal/san.h similarity index 83% rename from include/jemalloc/internal/guard.h rename to include/jemalloc/internal/san.h index 8e578168..b3d0304c 100644 --- a/include/jemalloc/internal/guard.h +++ b/include/jemalloc/internal/san.h @@ -13,15 +13,16 @@ extern size_t opt_san_guard_large; extern size_t opt_san_guard_small; -void guard_pages(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata, emap_t *emap); -void unguard_pages(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata, +void san_guard_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); /* * 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. */ -void unguard_pages_pre_destroy(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata, - emap_t *emap); +void san_unguard_pages_pre_destroy(tsdn_t *tsdn, ehooks_t *ehooks, + edata_t *edata, emap_t *emap); void tsd_san_init(tsd_t *tsd); static inline bool @@ -30,7 +31,7 @@ san_enabled(void) { } 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) { if (opt_san_guard_large == 0 || ehooks_guard_will_fail(ehooks) || tsdn_null(tsdn)) { @@ -60,7 +61,7 @@ large_extent_decide_guard(tsdn_t *tsdn, ehooks_t *ehooks, size_t size, } 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) || tsdn_null(tsdn)) { return false; diff --git a/src/arena.c b/src/arena.c index 811f0edc..19e4e85a 100644 --- a/src/arena.c +++ b/src/arena.c @@ -6,7 +6,7 @@ #include "jemalloc/internal/ehooks.h" #include "jemalloc/internal/extent_dss.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/rtree.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); 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); edata_t *edata = pa_alloc(tsdn, &arena->pa_shard, esize, alignment, /* 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_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, /* alignment */ PAGE, /* slab */ true, /* szind */ binind, /* zero */ false, guarded, &deferred_work_generated); diff --git a/src/ecache.c b/src/ecache.c index 26fc2112..a242227d 100644 --- a/src/ecache.c +++ b/src/ecache.c @@ -1,7 +1,7 @@ #include "jemalloc/internal/jemalloc_preamble.h" #include "jemalloc/internal/jemalloc_internal_includes.h" -#include "jemalloc/internal/guard.h" +#include "jemalloc/internal/san.h" bool ecache_init(tsdn_t *tsdn, ecache_t *ecache, extent_state_t state, unsigned ind, diff --git a/src/extent.c b/src/extent.c index a79e1c72..7112d3a8 100644 --- a/src/extent.c +++ b/src/extent.c @@ -1013,7 +1013,7 @@ extent_dalloc_wrapper(tsdn_t *tsdn, pac_t *pac, ehooks_t *ehooks, /* Restore guard pages for dalloc / unmap. */ if (edata_guarded_get(edata)) { 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 @@ -1063,7 +1063,7 @@ extent_destroy_wrapper(tsdn_t *tsdn, pac_t *pac, ehooks_t *ehooks, WITNESS_RANK_CORE, 0); 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)); diff --git a/src/jemalloc.c b/src/jemalloc.c index 521f4ea4..e707f9f9 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -10,7 +10,7 @@ #include "jemalloc/internal/extent_dss.h" #include "jemalloc/internal/extent_mmap.h" #include "jemalloc/internal/fxp.h" -#include "jemalloc/internal/guard.h" +#include "jemalloc/internal/san.h" #include "jemalloc/internal/hook.h" #include "jemalloc/internal/jemalloc_internal_types.h" #include "jemalloc/internal/log.h" diff --git a/src/pa.c b/src/pa.c index 779e672b..9004cc90 100644 --- a/src/pa.c +++ b/src/pa.c @@ -1,7 +1,7 @@ #include "jemalloc/internal/jemalloc_preamble.h" #include "jemalloc/internal/jemalloc_internal_includes.h" -#include "jemalloc/internal/guard.h" +#include "jemalloc/internal/san.h" #include "jemalloc/internal/hpa.h" static void diff --git a/src/pac.c b/src/pac.c index 176b181a..e53de80f 100644 --- a/src/pac.c +++ b/src/pac.c @@ -2,7 +2,7 @@ #include "jemalloc/internal/jemalloc_internal_includes.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, 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) { /* Add guards around it. */ 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) && 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) { assert(edata_size_get(edata) >= SC_LARGE_MINCLASS || !maps_coalesce); - unguard_pages(tsdn, ehooks, edata, pac->emap); + san_unguard_pages(tsdn, ehooks, edata, pac->emap); } } diff --git a/src/guard.c b/src/san.c similarity index 80% rename from src/guard.c rename to src/san.c index 4dadc970..139ec5a3 100644 --- a/src/guard.c +++ b/src/san.c @@ -3,7 +3,7 @@ #include "jemalloc/internal/assert.h" #include "jemalloc/internal/ehooks.h" -#include "jemalloc/internal/guard.h" +#include "jemalloc/internal/san.h" #include "jemalloc/internal/tsd.h" /* 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; 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); 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 -unguard_pages_impl(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata, emap_t *emap, - bool reg_emap) { +san_unguard_pages_impl(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata, + emap_t *emap, bool reg_emap) { /* Remove the inner boundary which no longer exists. */ if (reg_emap) { 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 -unguard_pages(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata, emap_t *emap) { - unguard_pages_impl(tsdn, ehooks, edata, emap, /* reg_emap */ true); +san_unguard_pages(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata, + emap_t *emap) { + san_unguard_pages_impl(tsdn, ehooks, edata, emap, /* reg_emap */ true); } 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_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 diff --git a/src/tsd.c b/src/tsd.c index 31ff2f23..4859048e 100644 --- a/src/tsd.c +++ b/src/tsd.c @@ -2,7 +2,7 @@ #include "jemalloc/internal/jemalloc_internal_includes.h" #include "jemalloc/internal/assert.h" -#include "jemalloc/internal/guard.h" +#include "jemalloc/internal/san.h" #include "jemalloc/internal/mutex.h" #include "jemalloc/internal/rtree.h" diff --git a/test/include/test/guard.h b/test/include/test/san.h similarity index 100% rename from test/include/test/guard.h rename to test/include/test/san.h diff --git a/test/unit/double_free.c b/test/unit/double_free.c index f98484c4..12122c1b 100644 --- a/test/unit/double_free.c +++ b/test/unit/double_free.c @@ -1,5 +1,5 @@ #include "test/jemalloc_test.h" -#include "test/guard.h" +#include "test/san.h" #include "jemalloc/internal/safety_check.h" diff --git a/test/unit/retained.c b/test/unit/retained.c index 53cda286..76bda50f 100644 --- a/test/unit/retained.c +++ b/test/unit/retained.c @@ -1,6 +1,6 @@ #include "test/jemalloc_test.h" -#include "jemalloc/internal/guard.h" +#include "jemalloc/internal/san.h" #include "jemalloc/internal/spin.h" static unsigned arena_ind; diff --git a/test/unit/guard.c b/test/unit/san.c similarity index 98% rename from test/unit/guard.c rename to test/unit/san.c index 43381e44..1baa26e9 100644 --- a/test/unit/guard.c +++ b/test/unit/san.c @@ -1,8 +1,8 @@ #include "test/jemalloc_test.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 verify_extent_guarded(tsdn_t *tsdn, void *ptr) { diff --git a/test/unit/guard.sh b/test/unit/san.sh similarity index 100% rename from test/unit/guard.sh rename to test/unit/san.sh