mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibELF: Use MAP_FIXED_NOREPLACE for address space reservation
This ensures that we don't corrupt our address space if a non-PIE program's requested address space happens to coincide with memory we already use.
This commit is contained in:
parent
77f9272aaf
commit
d1ef8e63f7
Notes:
sideshowbarker
2024-07-17 22:19:24 +09:00
Author: https://github.com/BertalanD Commit: https://github.com/SerenityOS/serenity/commit/d1ef8e63f75 Pull-request: https://github.com/SerenityOS/serenity/pull/11369
@ -292,8 +292,10 @@ void DynamicLoader::load_program_headers()
|
||||
int reservation_mmap_flags = MAP_ANON | MAP_PRIVATE | MAP_NORESERVE;
|
||||
if (m_elf_image.is_dynamic())
|
||||
reservation_mmap_flags |= MAP_RANDOMIZED;
|
||||
#ifdef MAP_FIXED_NOREPLACE
|
||||
else
|
||||
reservation_mmap_flags |= MAP_FIXED;
|
||||
reservation_mmap_flags |= MAP_FIXED_NOREPLACE;
|
||||
#endif
|
||||
|
||||
// First, we make a dummy reservation mapping, in order to allocate enough VM
|
||||
// to hold all regions contiguously in the address space.
|
||||
@ -309,6 +311,8 @@ void DynamicLoader::load_program_headers()
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
VERIFY(requested_load_address == nullptr || reservation == requested_load_address);
|
||||
|
||||
m_base_address = VirtualAddress { reservation };
|
||||
|
||||
// Then we unmap the reservation.
|
||||
|
Loading…
Reference in New Issue
Block a user