diff options
author | Alex Lapenkou <lapenkov@fb.com> | 2021-10-23 00:40:42 (GMT) |
---|---|---|
committer | Alexander Lapenkov <lapenkov.a@yandex.ru> | 2021-12-15 18:39:17 (GMT) |
commit | 62f9c54d2a9035c6bfdbb4c41ecc0dcb040b509e (patch) | |
tree | 898dfb300273391c8a836bc8629d8663d396c3e3 | |
parent | d9bbf539ff9cee5f138e03ad2e7f61263d381c7f (diff) | |
download | jemalloc-62f9c54d2a9035c6bfdbb4c41ecc0dcb040b509e.zip jemalloc-62f9c54d2a9035c6bfdbb4c41ecc0dcb040b509e.tar.gz jemalloc-62f9c54d2a9035c6bfdbb4c41ecc0dcb040b509e.tar.bz2 |
San: Rename 'guard' to 'san'
This prepares the foundation for more sanitizer-related work in the
future.
-rw-r--r-- | Makefile.in | 4 | ||||
-rw-r--r-- | include/jemalloc/internal/ecache.h | 2 | ||||
-rw-r--r-- | include/jemalloc/internal/san.h (renamed from include/jemalloc/internal/guard.h) | 13 | ||||
-rw-r--r-- | src/arena.c | 6 | ||||
-rw-r--r-- | src/ecache.c | 2 | ||||
-rw-r--r-- | src/extent.c | 4 | ||||
-rw-r--r-- | src/jemalloc.c | 2 | ||||
-rw-r--r-- | src/pa.c | 2 | ||||
-rw-r--r-- | src/pac.c | 6 | ||||
-rw-r--r-- | src/san.c (renamed from src/guard.c) | 17 | ||||
-rw-r--r-- | src/tsd.c | 2 | ||||
-rw-r--r-- | test/include/test/san.h (renamed from test/include/test/guard.h) | 0 | ||||
-rw-r--r-- | test/unit/double_free.c | 2 | ||||
-rw-r--r-- | test/unit/retained.c | 2 | ||||
-rw-r--r-- | test/unit/san.c (renamed from test/unit/guard.c) | 4 | ||||
-rw-r--r-- | test/unit/san.sh (renamed from test/unit/guard.sh) | 0 |
16 files changed, 35 insertions, 33 deletions
diff --git a/Makefile.in b/Makefile.in index abd361f..8f96a99 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 dd1bc32..71cae3e 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 index 8e57816..b3d0304 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 811f0ed..19e4e85 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 26fc211..a242227 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 a79e1c7..7112d3a 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 521f4ea..e707f9f 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" @@ -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 @@ -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); } } @@ -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 @@ -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 index 691dc50..691dc50 100644 --- a/test/include/test/guard.h +++ b/test/include/test/san.h diff --git a/test/unit/double_free.c b/test/unit/double_free.c index f98484c..12122c1 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 53cda28..76bda50 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 index 43381e4..1baa26e 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 index 933b4a4..933b4a4 100644 --- a/test/unit/guard.sh +++ b/test/unit/san.sh |