Emulator: Use libc.so bounds to fast-reject non-malloc addresses

The auditing code always starts by checking if we're in one of the
ignored code ranges (malloc, free, realloc, syscall, etc.)

To reduce the number of checks needed, we can cache the bounds of
the LibC text segment. This allows us to fast-reject addresses that
cannot possibly be a LibC function.
This commit is contained in:
Andreas Kling 2021-03-09 14:59:41 +01:00
commit c192b6c61d
Notes: sideshowbarker 2024-07-18 21:34:38 +09:00
2 changed files with 12 additions and 0 deletions

View file

@ -1054,6 +1054,8 @@ u32 Emulator::virt$mmap(u32 params_addr)
} else {
auto region = MmapRegion::create_file_backed(final_address, final_size, params.prot, params.flags, params.fd, params.offset, move(name_str));
if (region->name() == "libc.so: .text") {
m_libc_start = final_address;
m_libc_end = final_address + final_size;
bool rc = find_malloc_symbols(*region);
VERIFY(rc);
}