mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-06 19:38:41 +03:00
always use non-flat map in secure mode and validate pointers passed to free
This commit is contained in:
parent
09c2b7fdcf
commit
8a66ae818a
5 changed files with 13 additions and 3 deletions
|
@ -123,13 +123,17 @@ typedef int32_t mi_ssize_t;
|
|||
|
||||
// use a flat page-map (or a 2-level one)
|
||||
#ifndef MI_PAGE_MAP_FLAT
|
||||
#if MI_MAX_VABITS <= 40 && !defined(__APPLE__)
|
||||
#if MI_MAX_VABITS <= 40 && !MI_SECURE && !defined(__APPLE__)
|
||||
#define MI_PAGE_MAP_FLAT 1
|
||||
#else
|
||||
#define MI_PAGE_MAP_FLAT 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if MI_PAGE_MAP_FLAT && MI_SECURE
|
||||
#error should not use MI_PAGE_MAP_FLAT with a secure build
|
||||
#endif
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------
|
||||
Builtin's
|
||||
|
|
|
@ -589,7 +589,7 @@ static inline mi_page_t* _mi_checked_ptr_page(const void* p) {
|
|||
|
||||
static inline mi_page_t* _mi_ptr_page(const void* p) {
|
||||
mi_assert_internal(p==NULL || mi_is_in_heap_region(p));
|
||||
#if MI_DEBUG || defined(__APPLE__)
|
||||
#if MI_DEBUG || MI_SECURE || defined(__APPLE__)
|
||||
return _mi_checked_ptr_page(p);
|
||||
#else
|
||||
return _mi_unchecked_ptr_page(p);
|
||||
|
|
|
@ -50,7 +50,7 @@ terms of the MIT license. A copy of the license can be found in the file
|
|||
|
||||
// Define MI_SECURE to enable security mitigations. Level 1 has minimal performance impact,
|
||||
// but protects most metadata with guard pages:
|
||||
// #define MI_SECURE 1 // guard page around metadata
|
||||
// #define MI_SECURE 1 // guard page around metadata; check pointer validity on free
|
||||
//
|
||||
// Level 2 has more performance impact but protect well against various buffer overflows
|
||||
// by surrounding all mimalloc pages with guard pages:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue