diff --git a/libafl/Cargo.toml b/libafl/Cargo.toml index a365de7483..7774f7916f 100644 --- a/libafl/Cargo.toml +++ b/libafl/Cargo.toml @@ -122,7 +122,7 @@ llmp_bind_public = ["libafl_bolts/llmp_bind_public"] llmp_compression = ["libafl_bolts/llmp_compression"] ## Enables debug output for LLMP (also needs a `logger` installed) -llmp_debug = ["libafl_bolts/llmp_debug"] +llmp_debug = ["std", "libafl_bolts/llmp_debug"] ## Reduces the initial map size for llmp llmp_small_maps = ["libafl_bolts/llmp_small_maps"] # reduces initial map size for llmp diff --git a/libafl_bolts/Cargo.toml b/libafl_bolts/Cargo.toml index c716fe30c5..8ff8e5ab6b 100644 --- a/libafl_bolts/Cargo.toml +++ b/libafl_bolts/Cargo.toml @@ -76,7 +76,7 @@ llmp_bind_public = ["alloc"] llmp_compression = ["alloc", "gzip"] ## Enables debug output for LLMP (also needs a `logger` installed) -llmp_debug = ["alloc"] +llmp_debug = ["alloc", "std"] ## Reduces the initial map size for llmp llmp_small_maps = ["alloc"] diff --git a/libafl_bolts/src/llmp.rs b/libafl_bolts/src/llmp.rs index cfa56e32c1..1de6fa01dd 100644 --- a/libafl_bolts/src/llmp.rs +++ b/libafl_bolts/src/llmp.rs @@ -882,6 +882,12 @@ where id: ClientId, keep_pages_forever: bool, ) -> Result { + #[cfg(feature = "llmp_debug")] + log::info!( + "PID: {:#?} Initializing LlmpSender {:#?}", + std::process::id(), + id + ); Ok(Self { id, last_msg_sent: ptr::null_mut(), @@ -948,6 +954,12 @@ where msg_sent_offset, )?; ret.id = Self::client_id_from_env(env_name)?.unwrap_or_default(); + #[cfg(feature = "llmp_debug")] + log::info!( + "PID: {:#?} Initializing LlmpSender from on_existing_from_env {:#?}", + std::process::id(), + &ret.id + ); Ok(ret) } @@ -1015,8 +1027,15 @@ where None => ptr::null_mut(), }; + let client_id = unsafe { (*out_shmem.page()).sender_id }; + #[cfg(feature = "llmp_debug")] + log::info!( + "PID: {:#?} Initializing LlmpSender from on_existing_shmem {:#?}", + std::process::id(), + &client_id + ); Ok(Self { - id: unsafe { (*out_shmem.page()).sender_id }, + id: client_id, last_msg_sent, out_shmems: vec![out_shmem], // drop pages to the broker if it already read them diff --git a/libafl_qemu/src/hooks.rs b/libafl_qemu/src/hooks.rs index 2e73153578..f3d63c85e3 100644 --- a/libafl_qemu/src/hooks.rs +++ b/libafl_qemu/src/hooks.rs @@ -255,27 +255,40 @@ create_wrapper!(backdoor, (pc: GuestAddr)); #[cfg(emulation_mode = "usermode")] static mut PRE_SYSCALL_HOOKS: Vec>> = vec![]; #[cfg(emulation_mode = "usermode")] -create_wrapper!(pre_syscall, (sys_num: i32, - a0: GuestAddr, - a1: GuestAddr, - a2: GuestAddr, - a3: GuestAddr, - a4: GuestAddr, - a5: GuestAddr, - a6: GuestAddr, - a7: GuestAddr), SyscallHookResult); +create_wrapper!( + pre_syscall, + ( + sys_num: i32, + a0: GuestAddr, + a1: GuestAddr, + a2: GuestAddr, + a3: GuestAddr, + a4: GuestAddr, + a5: GuestAddr, + a6: GuestAddr, + a7: GuestAddr + ), + SyscallHookResult +); #[cfg(emulation_mode = "usermode")] static mut POST_SYSCALL_HOOKS: Vec>> = vec![]; #[cfg(emulation_mode = "usermode")] -create_wrapper!(post_syscall, (res: GuestAddr, sys_num: i32, - a0: GuestAddr, - a1: GuestAddr, - a2: GuestAddr, - a3: GuestAddr, - a4: GuestAddr, - a5: GuestAddr, - a6: GuestAddr, - a7: GuestAddr), GuestAddr); +create_wrapper!( + post_syscall, + ( + res: GuestAddr, + sys_num: i32, + a0: GuestAddr, + a1: GuestAddr, + a2: GuestAddr, + a3: GuestAddr, + a4: GuestAddr, + a5: GuestAddr, + a6: GuestAddr, + a7: GuestAddr + ), + GuestAddr +); #[cfg(emulation_mode = "usermode")] static mut NEW_THREAD_HOOKS: Vec>> = vec![]; #[cfg(emulation_mode = "usermode")] @@ -291,20 +304,44 @@ create_post_gen_wrapper!(block, (addr: GuestAddr, len: GuestUsize), 1, BlockHook create_exec_wrapper!(block, (id: u64), 0, 1, BlockHookId); static mut READ_HOOKS: Vec>>> = vec![]; -create_gen_wrapper!(read, (pc: GuestAddr, info: MemAccessInfo), u64, 5, ReadHookId); +create_gen_wrapper!( + read, + (pc: GuestAddr, info: MemAccessInfo), + u64, + 5, + ReadHookId +); create_exec_wrapper!(read, (id: u64, addr: GuestAddr), 0, 5, ReadHookId); create_exec_wrapper!(read, (id: u64, addr: GuestAddr), 1, 5, ReadHookId); create_exec_wrapper!(read, (id: u64, addr: GuestAddr), 2, 5, ReadHookId); create_exec_wrapper!(read, (id: u64, addr: GuestAddr), 3, 5, ReadHookId); -create_exec_wrapper!(read, (id: u64, addr: GuestAddr, size: usize), 4, 5, ReadHookId); +create_exec_wrapper!( + read, + (id: u64, addr: GuestAddr, size: usize), + 4, + 5, + ReadHookId +); static mut WRITE_HOOKS: Vec>>> = vec![]; -create_gen_wrapper!(write, (pc: GuestAddr, info: MemAccessInfo), u64, 5, WriteHookId); +create_gen_wrapper!( + write, + (pc: GuestAddr, info: MemAccessInfo), + u64, + 5, + WriteHookId +); create_exec_wrapper!(write, (id: u64, addr: GuestAddr), 0, 5, WriteHookId); create_exec_wrapper!(write, (id: u64, addr: GuestAddr), 1, 5, WriteHookId); create_exec_wrapper!(write, (id: u64, addr: GuestAddr), 2, 5, WriteHookId); create_exec_wrapper!(write, (id: u64, addr: GuestAddr), 3, 5, WriteHookId); -create_exec_wrapper!(write, (id: u64, addr: GuestAddr, size: usize), 4, 5, WriteHookId); +create_exec_wrapper!( + write, + (id: u64, addr: GuestAddr, size: usize), + 4, + 5, + WriteHookId +); static mut CMP_HOOKS: Vec>>> = vec![]; create_gen_wrapper!(cmp, (pc: GuestAddr, size: usize), u64, 4, CmpHookId);