Print PID when you create a new Llmp Sender. (#1898)

* aaaa

* FMT

* adding std
This commit is contained in:
Dongjia "toka" Zhang 2024-03-05 16:02:47 +01:00 committed by GitHub
parent 95bed5b016
commit 1a0e692f33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 81 additions and 25 deletions

View File

@ -122,7 +122,7 @@ llmp_bind_public = ["libafl_bolts/llmp_bind_public"]
llmp_compression = ["libafl_bolts/llmp_compression"] llmp_compression = ["libafl_bolts/llmp_compression"]
## Enables debug output for LLMP (also needs a `logger` installed) ## 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 ## Reduces the initial map size for llmp
llmp_small_maps = ["libafl_bolts/llmp_small_maps"] # reduces initial map size for llmp llmp_small_maps = ["libafl_bolts/llmp_small_maps"] # reduces initial map size for llmp

View File

@ -76,7 +76,7 @@ llmp_bind_public = ["alloc"]
llmp_compression = ["alloc", "gzip"] llmp_compression = ["alloc", "gzip"]
## Enables debug output for LLMP (also needs a `logger` installed) ## Enables debug output for LLMP (also needs a `logger` installed)
llmp_debug = ["alloc"] llmp_debug = ["alloc", "std"]
## Reduces the initial map size for llmp ## Reduces the initial map size for llmp
llmp_small_maps = ["alloc"] llmp_small_maps = ["alloc"]

View File

@ -882,6 +882,12 @@ where
id: ClientId, id: ClientId,
keep_pages_forever: bool, keep_pages_forever: bool,
) -> Result<Self, Error> { ) -> Result<Self, Error> {
#[cfg(feature = "llmp_debug")]
log::info!(
"PID: {:#?} Initializing LlmpSender {:#?}",
std::process::id(),
id
);
Ok(Self { Ok(Self {
id, id,
last_msg_sent: ptr::null_mut(), last_msg_sent: ptr::null_mut(),
@ -948,6 +954,12 @@ where
msg_sent_offset, msg_sent_offset,
)?; )?;
ret.id = Self::client_id_from_env(env_name)?.unwrap_or_default(); 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) Ok(ret)
} }
@ -1015,8 +1027,15 @@ where
None => ptr::null_mut(), 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 { Ok(Self {
id: unsafe { (*out_shmem.page()).sender_id }, id: client_id,
last_msg_sent, last_msg_sent,
out_shmems: vec![out_shmem], out_shmems: vec![out_shmem],
// drop pages to the broker if it already read them // drop pages to the broker if it already read them

View File

@ -255,7 +255,10 @@ create_wrapper!(backdoor, (pc: GuestAddr));
#[cfg(emulation_mode = "usermode")] #[cfg(emulation_mode = "usermode")]
static mut PRE_SYSCALL_HOOKS: Vec<Pin<Box<(PreSyscallHookId, FatPtr)>>> = vec![]; static mut PRE_SYSCALL_HOOKS: Vec<Pin<Box<(PreSyscallHookId, FatPtr)>>> = vec![];
#[cfg(emulation_mode = "usermode")] #[cfg(emulation_mode = "usermode")]
create_wrapper!(pre_syscall, (sys_num: i32, create_wrapper!(
pre_syscall,
(
sys_num: i32,
a0: GuestAddr, a0: GuestAddr,
a1: GuestAddr, a1: GuestAddr,
a2: GuestAddr, a2: GuestAddr,
@ -263,11 +266,18 @@ create_wrapper!(pre_syscall, (sys_num: i32,
a4: GuestAddr, a4: GuestAddr,
a5: GuestAddr, a5: GuestAddr,
a6: GuestAddr, a6: GuestAddr,
a7: GuestAddr), SyscallHookResult); a7: GuestAddr
),
SyscallHookResult
);
#[cfg(emulation_mode = "usermode")] #[cfg(emulation_mode = "usermode")]
static mut POST_SYSCALL_HOOKS: Vec<Pin<Box<(PostSyscallHookId, FatPtr)>>> = vec![]; static mut POST_SYSCALL_HOOKS: Vec<Pin<Box<(PostSyscallHookId, FatPtr)>>> = vec![];
#[cfg(emulation_mode = "usermode")] #[cfg(emulation_mode = "usermode")]
create_wrapper!(post_syscall, (res: GuestAddr, sys_num: i32, create_wrapper!(
post_syscall,
(
res: GuestAddr,
sys_num: i32,
a0: GuestAddr, a0: GuestAddr,
a1: GuestAddr, a1: GuestAddr,
a2: GuestAddr, a2: GuestAddr,
@ -275,7 +285,10 @@ create_wrapper!(post_syscall, (res: GuestAddr, sys_num: i32,
a4: GuestAddr, a4: GuestAddr,
a5: GuestAddr, a5: GuestAddr,
a6: GuestAddr, a6: GuestAddr,
a7: GuestAddr), GuestAddr); a7: GuestAddr
),
GuestAddr
);
#[cfg(emulation_mode = "usermode")] #[cfg(emulation_mode = "usermode")]
static mut NEW_THREAD_HOOKS: Vec<Pin<Box<(NewThreadHookId, FatPtr)>>> = vec![]; static mut NEW_THREAD_HOOKS: Vec<Pin<Box<(NewThreadHookId, FatPtr)>>> = vec![];
#[cfg(emulation_mode = "usermode")] #[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); create_exec_wrapper!(block, (id: u64), 0, 1, BlockHookId);
static mut READ_HOOKS: Vec<Pin<Box<HookState<5, ReadHookId>>>> = vec![]; static mut READ_HOOKS: Vec<Pin<Box<HookState<5, ReadHookId>>>> = 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), 0, 5, ReadHookId);
create_exec_wrapper!(read, (id: u64, addr: GuestAddr), 1, 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), 2, 5, ReadHookId);
create_exec_wrapper!(read, (id: u64, addr: GuestAddr), 3, 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<Pin<Box<HookState<5, WriteHookId>>>> = vec![]; static mut WRITE_HOOKS: Vec<Pin<Box<HookState<5, WriteHookId>>>> = 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), 0, 5, WriteHookId);
create_exec_wrapper!(write, (id: u64, addr: GuestAddr), 1, 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), 2, 5, WriteHookId);
create_exec_wrapper!(write, (id: u64, addr: GuestAddr), 3, 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<Pin<Box<HookState<4, CmpHookId>>>> = vec![]; static mut CMP_HOOKS: Vec<Pin<Box<HookState<4, CmpHookId>>>> = vec![];
create_gen_wrapper!(cmp, (pc: GuestAddr, size: usize), u64, 4, CmpHookId); create_gen_wrapper!(cmp, (pc: GuestAddr, size: usize), u64, 4, CmpHookId);