Asan guest fix (#2986)

* Check for initialization of libgasan.so on first_exec

---------

Co-authored-by: Your Name <you@example.com>
This commit is contained in:
WorksButNotTested 2025-02-17 16:06:42 +00:00 committed by GitHub
parent 91c46d1a33
commit f5a01ee20d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 12 deletions

View File

@ -84,6 +84,12 @@ static void __libqasan_map_shadow(void *addr, void *limit) {
addr, limit + 1, errno);
abort();
}
if (madvise(addr, size, MADV_DONTDUMP) != 0) {
QASAN_LOG("Failed to madvise (MADV_DONTDUMP) shadow: %p-%p, errno: %d",
addr, limit + 1, errno);
abort();
}
}
#endif

View File

@ -269,9 +269,21 @@ where
self.asan_lib = Some(asan_lib);
}
fn post_qemu_init<ET>(&mut self, qemu: Qemu, _emulator_modules: &mut EmulatorModules<ET, I, S>)
fn post_qemu_init<ET>(&mut self, _qemu: Qemu, _emulator_modules: &mut EmulatorModules<ET, I, S>)
where
ET: EmulatorModuleTuple<I, S>,
{
}
fn first_exec<ET>(
&mut self,
qemu: Qemu,
emulator_modules: &mut EmulatorModules<ET, I, S>,
_state: &mut S,
) where
ET: EmulatorModuleTuple<I, S>,
I: Unpin,
S: Unpin,
{
for mapping in qemu.mappings() {
println!("mapping: {mapping:#?}");
@ -305,18 +317,7 @@ where
for mapping in &mappings {
println!("asan mapping: {mapping:#?}");
}
}
fn first_exec<ET>(
&mut self,
_qemu: Qemu,
emulator_modules: &mut EmulatorModules<ET, I, S>,
_state: &mut S,
) where
ET: EmulatorModuleTuple<I, S>,
I: Unpin,
S: Unpin,
{
emulator_modules.reads(
Hook::Function(gen_readwrite_guest_asan::<ET, F, I, S>),
Hook::Function(guest_trace_error_asan::<ET, I, S>),