diff --git a/libafl_bolts/src/core_affinity.rs b/libafl_bolts/src/core_affinity.rs index c5ad9052cc..dfd734d80f 100644 --- a/libafl_bolts/src/core_affinity.rs +++ b/libafl_bolts/src/core_affinity.rs @@ -346,6 +346,21 @@ mod linux { } } +// Haiku +// FIXME: no sense of cpu granularity (yet ?) + +#[cfg(target_os = "haiku")] +#[inline] +fn get_core_ids_helper() -> Result, Error> { + Ok(Vec::new()) +} + +#[cfg(target_os = "haiku")] +#[inline] +fn set_for_current_helper(_core_id: CoreId) -> Result<(), Error> { + Ok(()) +} + // Windows Section #[cfg(target_os = "windows")] diff --git a/libafl_bolts/src/minibsod.rs b/libafl_bolts/src/minibsod.rs index 1a39888316..15f9f34172 100644 --- a/libafl_bolts/src/minibsod.rs +++ b/libafl_bolts/src/minibsod.rs @@ -393,6 +393,35 @@ pub fn dump_registers( Ok(()) } +/// Write the content of all important registers +#[cfg(all(target_os = "haiku", target_arch = "x86_64"))] +#[allow(clippy::similar_names)] +pub fn dump_registers( + writer: &mut BufWriter, + ucontext: &ucontext_t, +) -> Result<(), std::io::Error> { + let mcontext = &ucontext.uc_mcontext; + + write!(writer, "r8 : {:#016x}, ", mcontext.r8)?; + write!(writer, "r9 : {:#016x}, ", mcontext.r9)?; + write!(writer, "r10 : {:#016x}, ", mcontext.r10)?; + write!(writer, "r11 : {:#016x}, ", mcontext.r11)?; + write!(writer, "r12 : {:#016x}, ", mcontext.r12)?; + write!(writer, "r13 : {:#016x}, ", mcontext.r13)?; + write!(writer, "r14 : {:#016x}, ", mcontext.r14)?; + write!(writer, "r15 : {:#016x}, ", mcontext.r15)?; + write!(writer, "rdi : {:#016x}, ", mcontext.rdi)?; + write!(writer, "rsi : {:#016x}, ", mcontext.rsi)?; + write!(writer, "rbp : {:#016x}, ", mcontext.rbp)?; + write!(writer, "rbx : {:#016x}, ", mcontext.rbx)?; + write!(writer, "rdx : {:#016x}, ", mcontext.rdx)?; + write!(writer, "rax : {:#016x}, ", mcontext.rax)?; + write!(writer, "rcx : {:#016x}, ", mcontext.rcx)?; + write!(writer, "rsp : {:#016x}, ", mcontext.rsp)?; + write!(writer, "rflags : {:#016x}, ", mcontext.rflags)?; + Ok(()) +} + #[allow(clippy::unnecessary_wraps)] #[cfg(not(any( target_vendor = "apple", @@ -402,6 +431,7 @@ pub fn dump_registers( target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd", + target_os = "haiku", any(target_os = "solaris", target_os = "illumos"), )))] fn dump_registers( @@ -816,10 +846,33 @@ fn write_minibsod(writer: &mut BufWriter) -> Result<(), std::io::Er Ok(()) } +#[cfg(target_os = "haiku")] +fn write_minibsod(writer: &mut BufWriter) -> Result<(), std::io::Error> { + let mut info: libc::image_info = unsafe { std::mem::zeroed() }; + let mut c: i32 = 0; + + loop { + if unsafe { libc::get_next_image_info(0, &mut c, &mut info) } == libc::B_OK { + let i = format!( + "{}-{} {:?}\n", + info.text as u64, + info.text as u64 + info.text_size as u64, + info.name + ); + writer.write_all(&i.into_bytes())?; + } else { + break; + } + } + + Ok(()) +} + #[cfg(not(any( target_os = "freebsd", target_os = "openbsd", target_os = "netbsd", + target_os = "haiku", target_env = "apple", any(target_os = "linux", target_os = "android"), any(target_os = "solaris", target_os = "illumos"), diff --git a/libafl_bolts/src/shmem.rs b/libafl_bolts/src/shmem.rs index 87cb6f6f9f..96f1c789ea 100644 --- a/libafl_bolts/src/shmem.rs +++ b/libafl_bolts/src/shmem.rs @@ -16,16 +16,20 @@ use std::io::Read; use std::io::Write; use serde::{Deserialize, Serialize}; -#[cfg(all(feature = "std", unix, not(target_os = "android")))] +#[cfg(all( + feature = "std", + unix, + not(any(target_os = "android", target_os = "haiku")) +))] pub use unix_shmem::{MmapShMem, MmapShMemProvider}; -#[cfg(all(feature = "std", unix))] +#[cfg(all(feature = "std", unix, not(target_os = "haiku")))] pub use unix_shmem::{UnixShMem, UnixShMemProvider}; #[cfg(all(windows, feature = "std"))] pub use win32_shmem::{Win32ShMem, Win32ShMemProvider}; #[cfg(all(unix, feature = "std"))] use crate::os::pipes::Pipe; -#[cfg(all(feature = "std", unix))] +#[cfg(all(feature = "std", unix, not(target_os = "haiku")))] pub use crate::os::unix_shmem_server::{ServedShMemProvider, ShMemService}; use crate::{AsMutSlice, AsSlice, Error}; @@ -49,12 +53,12 @@ pub type StdShMemService = ShMemService; #[cfg(all( feature = "std", unix, - not(any(target_os = "android", target_vendor = "apple")) + not(any(target_os = "android", target_vendor = "apple", target_os = "haiku")) ))] pub type StdShMemProvider = UnixShMemProvider; /// The standard sharedmem service #[cfg(any( - not(any(target_os = "android", target_vendor = "apple")), + not(any(target_os = "android", target_vendor = "apple", target_os = "haiku")), not(feature = "std") ))] pub type StdShMemService = DummyShMemService; @@ -71,7 +75,7 @@ pub type StdServedShMemProvider = RcShMemProvider>; @@ -427,7 +431,7 @@ where //#[cfg(all(unix, feature = "std"))] //unsafe impl Send for RcShMemProvider {} -#[cfg(all(unix, feature = "std"))] +#[cfg(all(unix, feature = "std", not(target_os = "haiku")))] impl ShMemProvider for RcShMemProvider where SP: ShMemProvider + Debug, @@ -563,7 +567,7 @@ where } } -#[cfg(all(unix, feature = "std"))] +#[cfg(all(unix, feature = "std", not(target_os = "haiku")))] impl Default for RcShMemProvider where SP: ShMemProvider + Debug, @@ -573,7 +577,7 @@ where } } -#[cfg(all(unix, feature = "std"))] +#[cfg(all(unix, feature = "std", not(target_os = "haiku")))] impl RcShMemProvider> where SP: ShMemProvider + Debug, @@ -589,7 +593,7 @@ where /// On Android, this is partially reused to wrap [`unix_shmem::ashmem::AshmemShMem`], /// Although for an [`ServedShMemProvider`] using a unix domain socket /// Is needed on top. -#[cfg(all(unix, feature = "std"))] +#[cfg(all(unix, feature = "std", not(target_os = "haiku")))] pub mod unix_shmem { #[cfg(doc)] use crate::shmem::{ShMem, ShMemProvider};