diff options
author | Dmitriy Ivanov <dimitry@google.com> | 2014-05-13 18:34:48 -0700 |
---|---|---|
committer | Dmitriy Ivanov <dimitry@google.com> | 2014-05-13 18:34:48 -0700 |
commit | bc23e530c4db5175a065eeef36553c9c2c78fcf4 (patch) | |
tree | dd0ef72c108a549ef4ac775be8cb4f43034ca29a /linker/linker_allocator.cpp | |
parent | d597d263bc32422402d4810ce4ec070f0227c2f7 (diff) | |
download | android_bionic-bc23e530c4db5175a065eeef36553c9c2c78fcf4.tar.gz android_bionic-bc23e530c4db5175a065eeef36553c9c2c78fcf4.tar.bz2 android_bionic-bc23e530c4db5175a065eeef36553c9c2c78fcf4.zip |
Remove page level mprotects
Freeing block mprotects on the page which it turn
may lead to application crash if linker subsequently
tries to modify another block on the page.
Bug: 14895266
Change-Id: I8ff7f5df467d7be184242de652032b3c84e24b76
Diffstat (limited to 'linker/linker_allocator.cpp')
-rw-r--r-- | linker/linker_allocator.cpp | 12 |
1 files changed, 0 insertions, 12 deletions
diff --git a/linker/linker_allocator.cpp b/linker/linker_allocator.cpp index 805844fc2..60ce1ea47 100644 --- a/linker/linker_allocator.cpp +++ b/linker/linker_allocator.cpp @@ -42,8 +42,6 @@ void LinkerBlockAllocator::init(size_t block_size) { void* LinkerBlockAllocator::alloc() { if (free_block_list_ == nullptr) { create_new_page(); - } else { - protect_page(free_block_list_, PROT_READ | PROT_WRITE); } FreeBlockInfo* block_info = reinterpret_cast<FreeBlockInfo*>(free_block_list_); @@ -82,10 +80,8 @@ void LinkerBlockAllocator::free(void* block) { FreeBlockInfo* block_info = reinterpret_cast<FreeBlockInfo*>(block); - protect_page(block_info, PROT_READ | PROT_WRITE); block_info->next_block = free_block_list_; block_info->num_free_blocks = 1; - protect_page(block_info, PROT_READ); free_block_list_ = block_info; } @@ -98,14 +94,6 @@ void LinkerBlockAllocator::protect_all(int prot) { } } -void LinkerBlockAllocator::protect_page(void* block, int prot) { - LinkerAllocatorPage* page = find_page(block); - if (page == nullptr || mprotect(page, PAGE_SIZE, prot) == -1) { - abort(); - } -} - - void LinkerBlockAllocator::create_new_page() { LinkerAllocatorPage* page = reinterpret_cast<LinkerAllocatorPage*>(mmap(nullptr, PAGE_SIZE, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0)); |