mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +00:00
UserspaceEmulator: Don't audit accesses in calloc() and libsystem.so
These generate a lot of false positives and nothing of value.
This commit is contained in:
parent
a457b90733
commit
38fc522f5d
3 changed files with 20 additions and 1 deletions
|
@ -1057,6 +1057,10 @@ u32 Emulator::virt$mmap(u32 params_addr)
|
||||||
bool rc = find_malloc_symbols(*region);
|
bool rc = find_malloc_symbols(*region);
|
||||||
VERIFY(rc);
|
VERIFY(rc);
|
||||||
}
|
}
|
||||||
|
if (region->name() == "libsystem.so: .text") {
|
||||||
|
m_libsystem_start = final_address;
|
||||||
|
m_libsystem_end = final_address + final_size;
|
||||||
|
}
|
||||||
mmu().add_region(move(region));
|
mmu().add_region(move(region));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1818,6 +1822,7 @@ bool Emulator::find_malloc_symbols(const MmapRegion& libc_text)
|
||||||
auto malloc_symbol = image.find_demangled_function("malloc");
|
auto malloc_symbol = image.find_demangled_function("malloc");
|
||||||
auto free_symbol = image.find_demangled_function("free");
|
auto free_symbol = image.find_demangled_function("free");
|
||||||
auto realloc_symbol = image.find_demangled_function("realloc");
|
auto realloc_symbol = image.find_demangled_function("realloc");
|
||||||
|
auto calloc_symbol = image.find_demangled_function("calloc");
|
||||||
auto malloc_size_symbol = image.find_demangled_function("malloc_size");
|
auto malloc_size_symbol = image.find_demangled_function("malloc_size");
|
||||||
if (!malloc_symbol.has_value() || !free_symbol.has_value() || !realloc_symbol.has_value() || !malloc_size_symbol.has_value())
|
if (!malloc_symbol.has_value() || !free_symbol.has_value() || !realloc_symbol.has_value() || !malloc_size_symbol.has_value())
|
||||||
return false;
|
return false;
|
||||||
|
@ -1828,6 +1833,8 @@ bool Emulator::find_malloc_symbols(const MmapRegion& libc_text)
|
||||||
m_free_symbol_end = m_free_symbol_start + free_symbol.value().size();
|
m_free_symbol_end = m_free_symbol_start + free_symbol.value().size();
|
||||||
m_realloc_symbol_start = realloc_symbol.value().value() + libc_text.base();
|
m_realloc_symbol_start = realloc_symbol.value().value() + libc_text.base();
|
||||||
m_realloc_symbol_end = m_realloc_symbol_start + realloc_symbol.value().size();
|
m_realloc_symbol_end = m_realloc_symbol_start + realloc_symbol.value().size();
|
||||||
|
m_calloc_symbol_start = calloc_symbol.value().value() + libc_text.base();
|
||||||
|
m_calloc_symbol_end = m_calloc_symbol_start + calloc_symbol.value().size();
|
||||||
m_malloc_size_symbol_start = malloc_size_symbol.value().value() + libc_text.base();
|
m_malloc_size_symbol_start = malloc_size_symbol.value().value() + libc_text.base();
|
||||||
m_malloc_size_symbol_end = m_malloc_size_symbol_start + malloc_size_symbol.value().size();
|
m_malloc_size_symbol_end = m_malloc_size_symbol_start + malloc_size_symbol.value().size();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -64,6 +64,7 @@ public:
|
||||||
|
|
||||||
bool is_in_malloc_or_free() const;
|
bool is_in_malloc_or_free() const;
|
||||||
bool is_in_loader_code() const;
|
bool is_in_loader_code() const;
|
||||||
|
bool is_in_libsystem() const;
|
||||||
|
|
||||||
void did_receive_signal(int signum) { m_pending_signals |= (1 << signum); }
|
void did_receive_signal(int signum) { m_pending_signals |= (1 << signum); }
|
||||||
|
|
||||||
|
@ -189,11 +190,16 @@ private:
|
||||||
FlatPtr m_malloc_symbol_end { 0 };
|
FlatPtr m_malloc_symbol_end { 0 };
|
||||||
FlatPtr m_realloc_symbol_start { 0 };
|
FlatPtr m_realloc_symbol_start { 0 };
|
||||||
FlatPtr m_realloc_symbol_end { 0 };
|
FlatPtr m_realloc_symbol_end { 0 };
|
||||||
|
FlatPtr m_calloc_symbol_start { 0 };
|
||||||
|
FlatPtr m_calloc_symbol_end { 0 };
|
||||||
FlatPtr m_free_symbol_start { 0 };
|
FlatPtr m_free_symbol_start { 0 };
|
||||||
FlatPtr m_free_symbol_end { 0 };
|
FlatPtr m_free_symbol_end { 0 };
|
||||||
FlatPtr m_malloc_size_symbol_start { 0 };
|
FlatPtr m_malloc_size_symbol_start { 0 };
|
||||||
FlatPtr m_malloc_size_symbol_end { 0 };
|
FlatPtr m_malloc_size_symbol_end { 0 };
|
||||||
|
|
||||||
|
FlatPtr m_libsystem_start { 0 };
|
||||||
|
FlatPtr m_libsystem_end { 0 };
|
||||||
|
|
||||||
sigset_t m_pending_signals { 0 };
|
sigset_t m_pending_signals { 0 };
|
||||||
sigset_t m_signal_mask { 0 };
|
sigset_t m_signal_mask { 0 };
|
||||||
|
|
||||||
|
@ -218,11 +224,17 @@ private:
|
||||||
RangeAllocator m_range_allocator;
|
RangeAllocator m_range_allocator;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ALWAYS_INLINE bool Emulator::is_in_libsystem() const
|
||||||
|
{
|
||||||
|
return m_cpu.base_eip() >= m_libsystem_start && m_cpu.base_eip() < m_libsystem_end;
|
||||||
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE bool Emulator::is_in_malloc_or_free() const
|
ALWAYS_INLINE bool Emulator::is_in_malloc_or_free() const
|
||||||
{
|
{
|
||||||
return (m_cpu.base_eip() >= m_malloc_symbol_start && m_cpu.base_eip() < m_malloc_symbol_end)
|
return (m_cpu.base_eip() >= m_malloc_symbol_start && m_cpu.base_eip() < m_malloc_symbol_end)
|
||||||
|| (m_cpu.base_eip() >= m_free_symbol_start && m_cpu.base_eip() < m_free_symbol_end)
|
|| (m_cpu.base_eip() >= m_free_symbol_start && m_cpu.base_eip() < m_free_symbol_end)
|
||||||
|| (m_cpu.base_eip() >= m_realloc_symbol_start && m_cpu.base_eip() < m_realloc_symbol_end)
|
|| (m_cpu.base_eip() >= m_realloc_symbol_start && m_cpu.base_eip() < m_realloc_symbol_end)
|
||||||
|
|| (m_cpu.base_eip() >= m_calloc_symbol_start && m_cpu.base_eip() < m_calloc_symbol_end)
|
||||||
|| (m_cpu.base_eip() >= m_malloc_size_symbol_start && m_cpu.base_eip() < m_malloc_size_symbol_end);
|
|| (m_cpu.base_eip() >= m_malloc_size_symbol_start && m_cpu.base_eip() < m_malloc_size_symbol_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -214,7 +214,7 @@ void MallocTracer::audit_read(const Region& region, FlatPtr address, size_t size
|
||||||
if (!m_auditing_enabled)
|
if (!m_auditing_enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_emulator.is_in_malloc_or_free()) {
|
if (m_emulator.is_in_malloc_or_free() || m_emulator.is_in_libsystem()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue