Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minibsod::generate_minibsod openbsd's implementation proposal #1420

Merged
merged 1 commit into from
Aug 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions libafl_bolts/src/minibsod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,58 @@ pub fn generate_minibsod<W: Write>(
start = start + sz as usize;
}
}
} else {
return Err(std::io::Error::last_os_error());
}
} else {
return Err(std::io::Error::last_os_error());
}
}

#[cfg(target_os = "openbsd")]
{
let mut pentry = std::mem::MaybeUninit::<libc::kinfo_vmentry>::uninit();
let mut s = std::mem::size_of::<libc::kinfo_vmentry>();
let arr = &[libc::CTL_KERN, libc::KERN_PROC_VMMAP, unsafe {
libc::getpid()
}];
let mib = arr.as_ptr();
let miblen = arr.len() as u32;
unsafe { (*pentry.as_mut_ptr()).kve_start = 0 };
if unsafe {
libc::sysctl(
mib,
miblen,
pentry.as_mut_ptr() as *mut libc::c_void,
&mut s,
std::ptr::null_mut(),
0,
)
} == 0
{
let end: u64 = s as u64;
unsafe {
let mut entry = pentry.assume_init();
while libc::sysctl(
mib,
miblen,
&mut entry as *mut libc::kinfo_vmentry as *mut libc::c_void,
&mut s,
std::ptr::null_mut(),
0,
) == 0
{
if entry.kve_end == end {
break;
}
// OpenBSD's vm mappings have no knowledge of their paths on disk
let i = format!("{}-{}\n", entry.kve_start, entry.kve_end);
writer.write(&i.into_bytes())?;
entry.kve_start = entry.kve_start + 1;
}
}
} else {
return Err(std::io::Error::last_os_error());
}
}
domenukk marked this conversation as resolved.
Show resolved Hide resolved

Expand Down