Fix Clippy (#926)
* Fix clippy * undo comment fmt * add unstracked nyx files to gitignore * fix * windows, no_std * fix * fix * more * macos * remove doctest Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
This commit is contained in:
parent
ee58375ac5
commit
68fbfc8914
3
.gitignore
vendored
3
.gitignore
vendored
@ -51,3 +51,6 @@ __pycache__
|
|||||||
**/libxml2
|
**/libxml2
|
||||||
**/corpus_discovered
|
**/corpus_discovered
|
||||||
**/libxml2-*.tar.gz
|
**/libxml2-*.tar.gz
|
||||||
|
|
||||||
|
libafl_nyx/QEMU-Nyx
|
||||||
|
libafl_nyx/packer
|
@ -48,10 +48,7 @@ fn adder_loop(port: u16) -> ! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if current_result != last_result {
|
if current_result != last_result {
|
||||||
println!(
|
println!("Adder handled {msg_counter} messages, reporting {current_result} to broker");
|
||||||
"Adder handled {} messages, reporting {} to broker",
|
|
||||||
msg_counter, current_result
|
|
||||||
);
|
|
||||||
|
|
||||||
client
|
client
|
||||||
.send_buf(_TAG_MATH_RESULT_V1, ¤t_result.to_le_bytes())
|
.send_buf(_TAG_MATH_RESULT_V1, ¤t_result.to_le_bytes())
|
||||||
|
@ -132,8 +132,7 @@ impl Cores {
|
|||||||
|
|
||||||
if cores.is_empty() {
|
if cores.is_empty() {
|
||||||
return Err(Error::illegal_argument(format!(
|
return Err(Error::illegal_argument(format!(
|
||||||
"No cores specified! parsed: {}",
|
"No cores specified! parsed: {args}"
|
||||||
args
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,8 +590,7 @@ mod apple {
|
|||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(Error::unknown(format!(
|
Err(Error::unknown(format!(
|
||||||
"Failed to set_for_current {:?}",
|
"Failed to set_for_current {result:?}"
|
||||||
result
|
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -615,8 +613,7 @@ mod apple {
|
|||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(Error::unknown(format!(
|
Err(Error::unknown(format!(
|
||||||
"Failed to set_for_current {:?}",
|
"Failed to set_for_current {result:?}"
|
||||||
result
|
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -466,9 +466,7 @@ unsafe fn _llmp_page_init<SHM: ShMem>(shmem: &mut SHM, sender_id: ClientId, allo
|
|||||||
if !allow_reinit {
|
if !allow_reinit {
|
||||||
assert!(
|
assert!(
|
||||||
(*page).magic != PAGE_INITIALIZED_MAGIC,
|
(*page).magic != PAGE_INITIALIZED_MAGIC,
|
||||||
"Tried to initialize page {:?} twice (for shmem {:?})",
|
"Tried to initialize page {page:?} twice (for shmem {shmem:?})"
|
||||||
page,
|
|
||||||
shmem
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,10 +639,7 @@ where
|
|||||||
}
|
}
|
||||||
Err(Error::File(e, _)) if e.kind() == ErrorKind::AddrInUse => {
|
Err(Error::File(e, _)) if e.kind() == ErrorKind::AddrInUse => {
|
||||||
// We are the client :)
|
// We are the client :)
|
||||||
println!(
|
println!("We're the client (internal port already bound by broker, {e:#?})");
|
||||||
"We're the client (internal port already bound by broker, {:#?})",
|
|
||||||
e
|
|
||||||
);
|
|
||||||
Ok(LlmpConnection::IsClient {
|
Ok(LlmpConnection::IsClient {
|
||||||
client: LlmpClient::create_attach_to_tcp(shmem_provider, port)?,
|
client: LlmpClient::create_attach_to_tcp(shmem_provider, port)?,
|
||||||
})
|
})
|
||||||
@ -1082,8 +1077,7 @@ where
|
|||||||
let page = self.out_shmems.last_mut().unwrap().page_mut();
|
let page = self.out_shmems.last_mut().unwrap().page_mut();
|
||||||
if msg.is_null() || !llmp_msg_in_page(page, msg) {
|
if msg.is_null() || !llmp_msg_in_page(page, msg) {
|
||||||
return Err(Error::unknown(format!(
|
return Err(Error::unknown(format!(
|
||||||
"Llmp Message {:?} is null or not in current page",
|
"Llmp Message {msg:?} is null or not in current page"
|
||||||
msg
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1189,8 +1183,7 @@ where
|
|||||||
match unsafe { self.alloc_next_if_space(buf_len) } {
|
match unsafe { self.alloc_next_if_space(buf_len) } {
|
||||||
Some(msg) => Ok(msg),
|
Some(msg) => Ok(msg),
|
||||||
None => Err(Error::unknown(format!(
|
None => Err(Error::unknown(format!(
|
||||||
"Error allocating {} bytes in shmap",
|
"Error allocating {buf_len} bytes in shmap"
|
||||||
buf_len
|
|
||||||
))),
|
))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1258,8 +1251,7 @@ where
|
|||||||
|| tag == LLMP_TAG_UNSET
|
|| tag == LLMP_TAG_UNSET
|
||||||
{
|
{
|
||||||
return Err(Error::unknown(format!(
|
return Err(Error::unknown(format!(
|
||||||
"Reserved tag supplied to send_buf ({:#X})",
|
"Reserved tag supplied to send_buf ({tag:#X})"
|
||||||
tag
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1282,8 +1274,7 @@ where
|
|||||||
|| tag == LLMP_TAG_UNSET
|
|| tag == LLMP_TAG_UNSET
|
||||||
{
|
{
|
||||||
return Err(Error::unknown(format!(
|
return Err(Error::unknown(format!(
|
||||||
"Reserved tag supplied to send_buf ({:#X})",
|
"Reserved tag supplied to send_buf ({tag:#X})"
|
||||||
tag
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1742,8 +1733,7 @@ where
|
|||||||
let page_size = self.shmem.as_slice().len() - size_of::<LlmpPage>();
|
let page_size = self.shmem.as_slice().len() - size_of::<LlmpPage>();
|
||||||
if offset > page_size {
|
if offset > page_size {
|
||||||
Err(Error::illegal_argument(format!(
|
Err(Error::illegal_argument(format!(
|
||||||
"Msg offset out of bounds (size: {}, requested offset: {})",
|
"Msg offset out of bounds (size: {page_size}, requested offset: {offset})"
|
||||||
page_size, offset
|
|
||||||
)))
|
)))
|
||||||
} else {
|
} else {
|
||||||
unsafe { Ok(((*page).messages.as_mut_ptr() as *mut u8).add(offset) as *mut LlmpMsg) }
|
unsafe { Ok(((*page).messages.as_mut_ptr() as *mut u8).add(offset) as *mut LlmpMsg) }
|
||||||
@ -2048,7 +2038,7 @@ where
|
|||||||
/// This function returns the [`ShMemDescription`] the client uses to place incoming messages.
|
/// This function returns the [`ShMemDescription`] the client uses to place incoming messages.
|
||||||
/// The thread exits, when the remote broker disconnects.
|
/// The thread exits, when the remote broker disconnects.
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
#[allow(clippy::let_and_return)]
|
#[allow(clippy::let_and_return, clippy::too_many_lines)]
|
||||||
fn b2b_thread_on(
|
fn b2b_thread_on(
|
||||||
mut stream: TcpStream,
|
mut stream: TcpStream,
|
||||||
b2b_client_id: ClientId,
|
b2b_client_id: ClientId,
|
||||||
@ -2106,8 +2096,7 @@ where
|
|||||||
Ok(Some((client_id, tag, flags, payload))) => {
|
Ok(Some((client_id, tag, flags, payload))) => {
|
||||||
if client_id == b2b_client_id {
|
if client_id == b2b_client_id {
|
||||||
println!(
|
println!(
|
||||||
"Ignored message we probably sent earlier (same id), TAG: {:x}",
|
"Ignored message we probably sent earlier (same id), TAG: {tag:x}"
|
||||||
tag
|
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -2127,7 +2116,7 @@ where
|
|||||||
payload: payload.to_vec(),
|
payload: payload.to_vec(),
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
println!("Got error {} while trying to forward a message to broker {}, exiting thread", e, peer_address);
|
println!("Got error {e} while trying to forward a message to broker {peer_address}, exiting thread");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2135,7 +2124,7 @@ where
|
|||||||
println!("Local broker is shutting down, exiting thread");
|
println!("Local broker is shutting down, exiting thread");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Err(e) => panic!("Error reading from local page! {}", e),
|
Err(e) => panic!("Error reading from local page! {e}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2171,8 +2160,7 @@ where
|
|||||||
if let Error::File(e, _) = e {
|
if let Error::File(e, _) = e {
|
||||||
if e.kind() == ErrorKind::UnexpectedEof {
|
if e.kind() == ErrorKind::UnexpectedEof {
|
||||||
println!(
|
println!(
|
||||||
"Broker {} seems to have disconnected, exiting",
|
"Broker {peer_address} seems to have disconnected, exiting"
|
||||||
peer_address
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2417,8 +2405,7 @@ where
|
|||||||
println!("Error adding client! Ignoring: {e:?}");
|
println!("Error adding client! Ignoring: {e:?}");
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
return Err(Error::unknown(format!(
|
return Err(Error::unknown(format!(
|
||||||
"Error adding client! PANIC! {:?}",
|
"Error adding client! PANIC! {e:?}"
|
||||||
e
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -391,8 +391,7 @@ pub unsafe fn setup_signal_handler<T: 'static + Handler>(handler: &mut T) -> Res
|
|||||||
// Rust always panics on OOM, so we will, too.
|
// Rust always panics on OOM, so we will, too.
|
||||||
assert!(
|
assert!(
|
||||||
!SIGNAL_STACK_PTR.is_null(),
|
!SIGNAL_STACK_PTR.is_null(),
|
||||||
"Failed to allocate signal stack with {} bytes!",
|
"Failed to allocate signal stack with {SIGNAL_STACK_SIZE} bytes!"
|
||||||
SIGNAL_STACK_SIZE
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let mut ss: stack_t = mem::zeroed();
|
let mut ss: stack_t = mem::zeroed();
|
||||||
|
@ -468,8 +468,7 @@ where
|
|||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(Error::unknown(format!(
|
Err(Error::unknown(format!(
|
||||||
"Wrong result read from pipe! Expected 0, got {:?}",
|
"Wrong result read from pipe! Expected 0, got {ret:?}"
|
||||||
ret
|
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -630,8 +629,7 @@ pub mod unix_shmem {
|
|||||||
if shm_fd == -1 {
|
if shm_fd == -1 {
|
||||||
perror(b"shm_open\0".as_ptr() as *const _);
|
perror(b"shm_open\0".as_ptr() as *const _);
|
||||||
return Err(Error::unknown(format!(
|
return Err(Error::unknown(format!(
|
||||||
"Failed to shm_open map with id {:?}",
|
"Failed to shm_open map with id {shmem_ctr:?}"
|
||||||
shmem_ctr
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -640,8 +638,7 @@ pub mod unix_shmem {
|
|||||||
perror(b"ftruncate\0".as_ptr() as *const _);
|
perror(b"ftruncate\0".as_ptr() as *const _);
|
||||||
shm_unlink(filename_path.as_ptr() as *const _);
|
shm_unlink(filename_path.as_ptr() as *const _);
|
||||||
return Err(Error::unknown(format!(
|
return Err(Error::unknown(format!(
|
||||||
"setup_shm(): ftruncate() failed for map with id {:?}",
|
"setup_shm(): ftruncate() failed for map with id {shmem_ctr:?}"
|
||||||
shmem_ctr
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -659,8 +656,7 @@ pub mod unix_shmem {
|
|||||||
close(shm_fd);
|
close(shm_fd);
|
||||||
shm_unlink(filename_path.as_ptr() as *const _);
|
shm_unlink(filename_path.as_ptr() as *const _);
|
||||||
return Err(Error::unknown(format!(
|
return Err(Error::unknown(format!(
|
||||||
"mmap() failed for map with id {:?}",
|
"mmap() failed for map with id {shmem_ctr:?}"
|
||||||
shmem_ctr
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -691,8 +687,7 @@ pub mod unix_shmem {
|
|||||||
perror(b"mmap\0".as_ptr() as *const _);
|
perror(b"mmap\0".as_ptr() as *const _);
|
||||||
close(shm_fd);
|
close(shm_fd);
|
||||||
return Err(Error::unknown(format!(
|
return Err(Error::unknown(format!(
|
||||||
"mmap() failed for map with fd {:?}",
|
"mmap() failed for map with fd {shm_fd:?}"
|
||||||
shm_fd
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -997,8 +992,7 @@ pub mod unix_shmem {
|
|||||||
let fd = open(device_path.as_ptr(), O_RDWR);
|
let fd = open(device_path.as_ptr(), O_RDWR);
|
||||||
if fd == -1 {
|
if fd == -1 {
|
||||||
return Err(Error::unknown(format!(
|
return Err(Error::unknown(format!(
|
||||||
"Failed to open the ashmem device at {:?}",
|
"Failed to open the ashmem device at {device_path:?}"
|
||||||
device_path
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,10 +398,7 @@ where
|
|||||||
executions: _,
|
executions: _,
|
||||||
} => {
|
} => {
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
println!(
|
println!("Received new Testcase from {_client_id} ({client_config:?})");
|
||||||
"Received new Testcase from {} ({:?})",
|
|
||||||
_client_id, client_config
|
|
||||||
);
|
|
||||||
|
|
||||||
let _res = if client_config.match_with(&self.configuration)
|
let _res = if client_config.match_with(&self.configuration)
|
||||||
&& observers_buf.is_some()
|
&& observers_buf.is_some()
|
||||||
@ -890,8 +887,13 @@ where
|
|||||||
mgr.to_env(_ENV_FUZZER_BROKER_CLIENT_INITIAL);
|
mgr.to_env(_ENV_FUZZER_BROKER_CLIENT_INITIAL);
|
||||||
|
|
||||||
// First, create a channel from the current fuzzer to the next to store state between restarts.
|
// First, create a channel from the current fuzzer to the next to store state between restarts.
|
||||||
|
#[cfg(unix)]
|
||||||
let mut staterestorer: StateRestorer<SP> =
|
let mut staterestorer: StateRestorer<SP> =
|
||||||
StateRestorer::new(self.shmem_provider.new_shmem(256 * 1024 * 1024)?);
|
StateRestorer::new(self.shmem_provider.new_shmem(256 * 1024 * 1024)?);
|
||||||
|
|
||||||
|
#[cfg(not(unix))]
|
||||||
|
let staterestorer: StateRestorer<SP> =
|
||||||
|
StateRestorer::new(self.shmem_provider.new_shmem(256 * 1024 * 1024)?);
|
||||||
// Store the information to a map.
|
// Store the information to a map.
|
||||||
staterestorer.write_to_env(_ENV_FUZZER_SENDER)?;
|
staterestorer.write_to_env(_ENV_FUZZER_SENDER)?;
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ pub static mut SHUTDOWN_SIGHANDLER_DATA: ShutdownSignalData = ShutdownSignalData
|
|||||||
shutdown_handler: core::ptr::null(),
|
shutdown_handler: core::ptr::null(),
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A signal handler for releasing staterestore shmem
|
/// A signal handler for releasing `StateRestore` `ShMem`
|
||||||
/// This struct holds a pointer to StateRestore and clean up the shmem segment used by it.
|
/// This struct holds a pointer to `StateRestore` and clean up the `ShMem` segment used by it.
|
||||||
#[cfg(all(unix, feature = "std"))]
|
#[cfg(all(unix, feature = "std"))]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ShutdownSignalData {
|
pub struct ShutdownSignalData {
|
||||||
@ -58,6 +58,10 @@ pub type ShutdownFuncPtr =
|
|||||||
|
|
||||||
/// Shutdown handler. `SigTerm`, `SigInterrupt`, `SigQuit` call this
|
/// Shutdown handler. `SigTerm`, `SigInterrupt`, `SigQuit` call this
|
||||||
/// We can't handle SIGKILL in the signal handler, this means that you shouldn't kill your fuzzer with `kill -9` because then the shmem segments are never freed
|
/// We can't handle SIGKILL in the signal handler, this means that you shouldn't kill your fuzzer with `kill -9` because then the shmem segments are never freed
|
||||||
|
///
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
|
/// This will acceess `data` and write to the global `data.staterestorer_ptr` if it's not null.
|
||||||
#[cfg(all(unix, feature = "std"))]
|
#[cfg(all(unix, feature = "std"))]
|
||||||
pub unsafe fn shutdown_handler<SP>(
|
pub unsafe fn shutdown_handler<SP>(
|
||||||
signal: Signal,
|
signal: Signal,
|
||||||
|
@ -292,8 +292,7 @@ where
|
|||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(Error::unknown(format!(
|
Err(Error::unknown(format!(
|
||||||
"Received illegal message that message should not have arrived: {:?}.",
|
"Received illegal message that message should not have arrived: {event:?}."
|
||||||
event
|
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -445,8 +444,13 @@ where
|
|||||||
// We start ourself as child process to actually fuzz
|
// We start ourself as child process to actually fuzz
|
||||||
let mut staterestorer = if std::env::var(_ENV_FUZZER_SENDER).is_err() {
|
let mut staterestorer = if std::env::var(_ENV_FUZZER_SENDER).is_err() {
|
||||||
// First, create a place to store state in, for restarts.
|
// First, create a place to store state in, for restarts.
|
||||||
|
#[cfg(unix)]
|
||||||
|
let mut staterestorer: StateRestorer<SP> =
|
||||||
|
StateRestorer::new(shmem_provider.new_shmem(256 * 1024 * 1024)?);
|
||||||
|
#[cfg(not(unix))]
|
||||||
let staterestorer: StateRestorer<SP> =
|
let staterestorer: StateRestorer<SP> =
|
||||||
StateRestorer::new(shmem_provider.new_shmem(256 * 1024 * 1024)?);
|
StateRestorer::new(shmem_provider.new_shmem(256 * 1024 * 1024)?);
|
||||||
|
|
||||||
//let staterestorer = { LlmpSender::new(shmem_provider.clone(), 0, false)? };
|
//let staterestorer = { LlmpSender::new(shmem_provider.clone(), 0, false)? };
|
||||||
staterestorer.write_to_env(_ENV_FUZZER_SENDER)?;
|
staterestorer.write_to_env(_ENV_FUZZER_SENDER)?;
|
||||||
|
|
||||||
|
@ -249,8 +249,7 @@ impl Forkserver {
|
|||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return Err(Error::illegal_state(format!(
|
return Err(Error::illegal_state(format!(
|
||||||
"Could not spawn the forkserver: {:#?}",
|
"Could not spawn the forkserver: {err:#?}"
|
||||||
err
|
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -845,8 +845,7 @@ mod unix_signal_handler {
|
|||||||
let si_addr = { _info.si_addr() as usize };
|
let si_addr = { _info.si_addr() as usize };
|
||||||
|
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"We crashed at addr 0x{:x}, but are not in the target... Bug in the fuzzer? Exiting.",
|
"We crashed at addr 0x{si_addr:x}, but are not in the target... Bug in the fuzzer? Exiting."
|
||||||
si_addr
|
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", unix))]
|
#[cfg(all(feature = "std", unix))]
|
||||||
|
@ -75,8 +75,7 @@ where
|
|||||||
let o2_name = o2.name().to_string();
|
let o2_name = o2.name().to_string();
|
||||||
if o1_name == o2_name {
|
if o1_name == o2_name {
|
||||||
Err(Error::illegal_argument(format!(
|
Err(Error::illegal_argument(format!(
|
||||||
"DiffFeedback: observer names must be different (both were {})",
|
"DiffFeedback: observer names must be different (both were {o1_name})"
|
||||||
o1_name
|
|
||||||
)))
|
)))
|
||||||
} else {
|
} else {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
@ -832,8 +832,7 @@ impl core::fmt::Display for ClientPerfMonitor {
|
|||||||
// Create the formatted string
|
// Create the formatted string
|
||||||
writeln!(
|
writeln!(
|
||||||
f,
|
f,
|
||||||
" {:6.4}: Scheduler\n {:6.4}: Manager",
|
" {scheduler_percent:6.4}: Scheduler\n {manager_percent:6.4}: Manager"
|
||||||
scheduler_percent, manager_percent
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Calculate each stage
|
// Calculate each stage
|
||||||
|
@ -113,8 +113,7 @@ impl Tokens {
|
|||||||
}
|
}
|
||||||
if token_stop < token_start {
|
if token_stop < token_start {
|
||||||
return Err(Error::illegal_argument(format!(
|
return Err(Error::illegal_argument(format!(
|
||||||
"Tried to create tokens from illegal section: stop < start ({:?} < {:?})",
|
"Tried to create tokens from illegal section: stop < start ({token_stop:?} < {token_start:?})"
|
||||||
token_stop, token_start
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
let section_size: usize = token_stop.offset_from(token_start).try_into().unwrap();
|
let section_size: usize = token_stop.offset_from(token_start).try_into().unwrap();
|
||||||
@ -185,8 +184,7 @@ impl Tokens {
|
|||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
return Err(Error::illegal_argument(format!(
|
return Err(Error::illegal_argument(format!(
|
||||||
"Illegal line (hex decoding): {}",
|
"Illegal line (hex decoding): {line}"
|
||||||
line
|
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -19,14 +19,11 @@ pub use stacktrace::*;
|
|||||||
pub mod concolic;
|
pub mod concolic;
|
||||||
|
|
||||||
pub mod value;
|
pub mod value;
|
||||||
pub use value::*;
|
|
||||||
|
|
||||||
// Rust is breaking this with 'error: intrinsic safety mismatch between list of intrinsics within the compiler and core library intrinsics for intrinsic `type_id`' and so we disable this component for the moment
|
// Rust is breaking this with 'error: intrinsic safety mismatch between list of intrinsics within the compiler and core library intrinsics for intrinsic `type_id`' and so we disable this component for the moment
|
||||||
//#[cfg(unstable_feature)]
|
//#[cfg(unstable_feature)]
|
||||||
//pub mod owned;
|
//pub mod owned;
|
||||||
//#[cfg(unstable_feature)]
|
//#[cfg(unstable_feature)]
|
||||||
//pub use owned::*;
|
//pub use owned::*;
|
||||||
|
|
||||||
use alloc::{
|
use alloc::{
|
||||||
string::{String, ToString},
|
string::{String, ToString},
|
||||||
vec::Vec,
|
vec::Vec,
|
||||||
@ -34,6 +31,7 @@ use alloc::{
|
|||||||
use core::{fmt::Debug, time::Duration};
|
use core::{fmt::Debug, time::Duration};
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
pub use value::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
bolts::{
|
bolts::{
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
//! A simple observer with a single value.
|
//! A simple observer with a single value.
|
||||||
|
|
||||||
use alloc::boxed::Box;
|
use alloc::{
|
||||||
use alloc::string::{String, ToString};
|
boxed::Box,
|
||||||
|
string::{String, ToString},
|
||||||
|
};
|
||||||
use core::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use super::Observer;
|
||||||
use crate::{
|
use crate::{
|
||||||
bolts::{ownedref::OwnedRef, tuples::Named},
|
bolts::{ownedref::OwnedRef, tuples::Named},
|
||||||
inputs::UsesInput,
|
inputs::UsesInput,
|
||||||
Error,
|
Error,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::Observer;
|
|
||||||
|
|
||||||
/// A simple observer with a single value.
|
/// A simple observer with a single value.
|
||||||
///
|
///
|
||||||
/// The intent is that the value is something with interior mutability (e.g., a
|
/// The intent is that the value is something with interior mutability (e.g., a
|
||||||
@ -45,36 +46,17 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get a reference to the underlying value.
|
/// Get a reference to the underlying value.
|
||||||
///
|
|
||||||
/// ```
|
|
||||||
/// # use libafl::observers::value::ValueObserver;
|
|
||||||
/// let mut obs = ValueObserver::new("example", &2);
|
|
||||||
/// assert_eq!(&2, obs.get_ref());
|
|
||||||
/// ```
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_ref(&self) -> &T {
|
pub fn get_ref(&self) -> &T {
|
||||||
self.value.as_ref()
|
self.value.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the value.
|
/// Set the value.
|
||||||
///
|
|
||||||
/// ```
|
|
||||||
/// # use libafl::observers::value::ValueObserver;
|
|
||||||
/// let mut obs = ValueObserver::new("example", &2);
|
|
||||||
/// obs.set(3);
|
|
||||||
/// assert_eq!(3, obs.take());
|
|
||||||
/// ```
|
|
||||||
pub fn set(&mut self, new_value: T) {
|
pub fn set(&mut self, new_value: T) {
|
||||||
self.value = OwnedRef::Owned(Box::new(new_value));
|
self.value = OwnedRef::Owned(Box::new(new_value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clone or move the current value out of this object.
|
/// Clone or move the current value out of this object.
|
||||||
///
|
|
||||||
/// ```
|
|
||||||
/// # use libafl::observers::value::ValueObserver;
|
|
||||||
/// let mut obs = ValueObserver::new("example", &2);
|
|
||||||
/// assert_eq!(2, obs.take());
|
|
||||||
/// ```
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn take(self) -> T
|
pub fn take(self) -> T
|
||||||
where
|
where
|
||||||
|
@ -210,8 +210,7 @@ where
|
|||||||
let must_remove = {
|
let must_remove = {
|
||||||
let old_meta = old.metadata_mut().get_mut::<AccountingIndexesMetadata>().ok_or_else(|| {
|
let old_meta = old.metadata_mut().get_mut::<AccountingIndexesMetadata>().ok_or_else(|| {
|
||||||
Error::key_not_found(format!(
|
Error::key_not_found(format!(
|
||||||
"AccountingIndexesMetadata, needed by CoverageAccountingScheduler, not found in testcase #{}",
|
"AccountingIndexesMetadata, needed by CoverageAccountingScheduler, not found in testcase #{old_idx}"
|
||||||
old_idx
|
|
||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
*old_meta.refcnt_mut() -= 1;
|
*old_meta.refcnt_mut() -= 1;
|
||||||
|
@ -209,8 +209,7 @@ where
|
|||||||
let factor = F::compute(&mut *entry, state)?;
|
let factor = F::compute(&mut *entry, state)?;
|
||||||
let meta = entry.metadata_mut().get_mut::<M>().ok_or_else(|| {
|
let meta = entry.metadata_mut().get_mut::<M>().ok_or_else(|| {
|
||||||
Error::key_not_found(format!(
|
Error::key_not_found(format!(
|
||||||
"Metadata needed for MinimizerScheduler not found in testcase #{}",
|
"Metadata needed for MinimizerScheduler not found in testcase #{idx}"
|
||||||
idx
|
|
||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
for elem in meta.as_slice() {
|
for elem in meta.as_slice() {
|
||||||
@ -229,8 +228,7 @@ where
|
|||||||
let must_remove = {
|
let must_remove = {
|
||||||
let old_meta = old.metadata_mut().get_mut::<M>().ok_or_else(|| {
|
let old_meta = old.metadata_mut().get_mut::<M>().ok_or_else(|| {
|
||||||
Error::key_not_found(format!(
|
Error::key_not_found(format!(
|
||||||
"Metadata needed for MinimizerScheduler not found in testcase #{}",
|
"Metadata needed for MinimizerScheduler not found in testcase #{old_idx}"
|
||||||
old_idx
|
|
||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
*old_meta.refcnt_mut() -= 1;
|
*old_meta.refcnt_mut() -= 1;
|
||||||
@ -283,8 +281,7 @@ where
|
|||||||
let mut entry = state.corpus().get(*idx)?.borrow_mut();
|
let mut entry = state.corpus().get(*idx)?.borrow_mut();
|
||||||
let meta = entry.metadata().get::<M>().ok_or_else(|| {
|
let meta = entry.metadata().get::<M>().ok_or_else(|| {
|
||||||
Error::key_not_found(format!(
|
Error::key_not_found(format!(
|
||||||
"Metadata needed for MinimizerScheduler not found in testcase #{}",
|
"Metadata needed for MinimizerScheduler not found in testcase #{idx}"
|
||||||
idx
|
|
||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
for elem in meta.as_slice() {
|
for elem in meta.as_slice() {
|
||||||
|
@ -127,8 +127,7 @@ where
|
|||||||
let original = input.clone();
|
let original = input.clone();
|
||||||
let meta = entry.metadata().get::<MapNoveltiesMetadata>().ok_or_else(|| {
|
let meta = entry.metadata().get::<MapNoveltiesMetadata>().ok_or_else(|| {
|
||||||
Error::key_not_found(format!(
|
Error::key_not_found(format!(
|
||||||
"MapNoveltiesMetadata needed for GeneralizationStage not found in testcase #{} (check the arguments of MapFeedback::new(...))",
|
"MapNoveltiesMetadata needed for GeneralizationStage not found in testcase #{corpus_idx} (check the arguments of MapFeedback::new(...))"
|
||||||
corpus_idx
|
|
||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
(payload, original, meta.as_slice().to_vec())
|
(payload, original, meta.as_slice().to_vec())
|
||||||
|
@ -46,8 +46,7 @@ fn find_llvm_config_brew() -> Result<PathBuf, String> {
|
|||||||
match glob_results.last() {
|
match glob_results.last() {
|
||||||
Some(path) => Ok(path.unwrap()),
|
Some(path) => Ok(path.unwrap()),
|
||||||
None => Err(format!(
|
None => Err(format!(
|
||||||
"No llvm-config found in brew cellar with pattern {}",
|
"No llvm-config found in brew cellar with pattern {cellar_glob}"
|
||||||
cellar_glob
|
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,8 +182,7 @@ fn write_symcc_runtime_bindings_file(out_path: &Path, cpp_bindings: &bindgen::Bi
|
|||||||
let function_name = &captures[1];
|
let function_name = &captures[1];
|
||||||
writeln!(
|
writeln!(
|
||||||
bindings_file,
|
bindings_file,
|
||||||
"#[link_name=\"{}{}\"]",
|
"#[link_name=\"{SYMCC_RUNTIME_FUNCTION_NAME_PREFIX}{function_name}\"]"
|
||||||
SYMCC_RUNTIME_FUNCTION_NAME_PREFIX, function_name
|
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
@ -440,8 +440,7 @@ impl Allocator {
|
|||||||
Some(metadata) => metadata.size,
|
Some(metadata) => metadata.size,
|
||||||
None => {
|
None => {
|
||||||
panic!(
|
panic!(
|
||||||
"Attempted to get_usable_size on a pointer ({:?}) which was not allocated!",
|
"Attempted to get_usable_size on a pointer ({ptr:?}) which was not allocated!"
|
||||||
ptr
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -399,8 +399,7 @@ impl AsanRuntime {
|
|||||||
self.allocator
|
self.allocator
|
||||||
.map_shadow_for_region(tls_start, tls_end, true);
|
.map_shadow_for_region(tls_start, tls_end, true);
|
||||||
println!(
|
println!(
|
||||||
"registering thread with stack {:x}:{:x} and tls {:x}:{:x}",
|
"registering thread with stack {stack_start:x}:{stack_end:x} and tls {tls_start:x}:{tls_end:x}"
|
||||||
stack_start, stack_end, tls_start, tls_end
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1547,7 +1546,8 @@ impl AsanRuntime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
#[allow(clippy::unused_self, clippy::identity_op)] // identity_op appears to be a false positive in ubfx
|
// identity_op appears to be a false positive in ubfx
|
||||||
|
#[allow(clippy::unused_self, clippy::identity_op, clippy::too_many_lines)]
|
||||||
fn generate_shadow_check_function(&mut self) {
|
fn generate_shadow_check_function(&mut self) {
|
||||||
let shadow_bit = self.allocator.shadow_bit();
|
let shadow_bit = self.allocator.shadow_bit();
|
||||||
let mut ops = dynasmrt::VecAssembler::<dynasmrt::aarch64::Aarch64Relocation>::new(0);
|
let mut ops = dynasmrt::VecAssembler::<dynasmrt::aarch64::Aarch64Relocation>::new(0);
|
||||||
@ -1657,8 +1657,9 @@ impl AsanRuntime {
|
|||||||
let mut map_flags = MapFlags::MAP_ANON | MapFlags::MAP_PRIVATE;
|
let mut map_flags = MapFlags::MAP_ANON | MapFlags::MAP_PRIVATE;
|
||||||
|
|
||||||
// apple aarch64 requires MAP_JIT to allocates WX pages
|
// apple aarch64 requires MAP_JIT to allocates WX pages
|
||||||
#[cfg(all(target_vendor = "apple", target_arch = "aarch64"))]
|
if cfg!(all(target_vendor = "apple", target_arch = "aarch64")) {
|
||||||
map_flags |= MapFlags::MAP_JIT;
|
map_flags |= MapFlags::MAP_JIT;
|
||||||
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let mapping = mmap(
|
let mapping = mmap(
|
||||||
@ -2047,9 +2048,9 @@ impl AsanRuntime {
|
|||||||
; .qword addr_of_mut!(self.eh_frame) as i64
|
; .qword addr_of_mut!(self.eh_frame) as i64
|
||||||
);
|
);
|
||||||
self.eh_frame = [
|
self.eh_frame = [
|
||||||
0x14, 0, 0x00527a01, 0x011e7c01, 0x001f0c1b,
|
0x14, 0, 0x00527a01, 0x011e7c01, 0x001f0c1b, //
|
||||||
// eh_frame_fde
|
// eh_frame_fde
|
||||||
0x14, 0x18,
|
0x14, 0x18, //
|
||||||
// fde_address
|
// fde_address
|
||||||
0, // <-- address offset goes here
|
0, // <-- address offset goes here
|
||||||
0x104,
|
0x104,
|
||||||
@ -2057,9 +2058,9 @@ impl AsanRuntime {
|
|||||||
// def_cfa r29 (x29) at offset 16
|
// def_cfa r29 (x29) at offset 16
|
||||||
// offset r30 (x30) at cfa-8
|
// offset r30 (x30) at cfa-8
|
||||||
// offset r29 (x29) at cfa-16
|
// offset r29 (x29) at cfa-16
|
||||||
0x1d0c4c00, 0x9d029e10, 0x4,
|
0x1d0c4c00, 0x9d029e10, 0x4, //
|
||||||
// empty next FDE:
|
// empty next FDE:
|
||||||
0, 0
|
0, 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
self.blob_report = Some(ops_report.finalize().unwrap().into_boxed_slice());
|
self.blob_report = Some(ops_report.finalize().unwrap().into_boxed_slice());
|
||||||
|
@ -312,8 +312,7 @@ impl AsanErrors {
|
|||||||
| AsanError::BadFuncArgWrite((name, _pc, address, size, backtrace)) => {
|
| AsanError::BadFuncArgWrite((name, _pc, address, size, backtrace)) => {
|
||||||
writeln!(
|
writeln!(
|
||||||
output,
|
output,
|
||||||
" in call to {}, argument {:#016x}, size: {:#x}",
|
" in call to {name}, argument {address:#016x}, size: {size:#x}"
|
||||||
name, address, size
|
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
output.reset().unwrap();
|
output.reset().unwrap();
|
||||||
@ -432,12 +431,7 @@ impl AsanErrors {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
} else {
|
} else {
|
||||||
writeln!(
|
writeln!(output, " at 0x{pc:x}, faulting address 0x{fault_address:x}").unwrap();
|
||||||
output,
|
|
||||||
" at 0x{:x}, faulting address 0x{:x}",
|
|
||||||
pc, fault_address
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
output.reset().unwrap();
|
output.reset().unwrap();
|
||||||
|
|
||||||
|
@ -69,10 +69,7 @@ pub fn build(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !qemu_path.is_dir() {
|
if !qemu_path.is_dir() {
|
||||||
println!(
|
println!("cargo:warning=Qemu not found, cloning with git ({QEMU_REVISION})...");
|
||||||
"cargo:warning=Qemu not found, cloning with git ({})...",
|
|
||||||
QEMU_REVISION
|
|
||||||
);
|
|
||||||
fs::create_dir_all(&qemu_path).unwrap();
|
fs::create_dir_all(&qemu_path).unwrap();
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
.current_dir(&qemu_path)
|
.current_dir(&qemu_path)
|
||||||
|
@ -33,17 +33,16 @@ fn main() {
|
|||||||
"// These constants are autogenerated by build.rs
|
"// These constants are autogenerated by build.rs
|
||||||
|
|
||||||
/// The size of the edges map
|
/// The size of the edges map
|
||||||
pub const EDGES_MAP_SIZE: usize = {};
|
pub const EDGES_MAP_SIZE: usize = {edges_map_size};
|
||||||
/// The size of the cmps map
|
/// The size of the cmps map
|
||||||
pub const CMP_MAP_SIZE: usize = {};
|
pub const CMP_MAP_SIZE: usize = {cmp_map_size};
|
||||||
/// The width of the `CmpLog` map
|
/// The width of the `CmpLog` map
|
||||||
pub const CMPLOG_MAP_W: usize = {};
|
pub const CMPLOG_MAP_W: usize = {cmplog_map_w};
|
||||||
/// The height of the `CmpLog` map
|
/// The height of the `CmpLog` map
|
||||||
pub const CMPLOG_MAP_H: usize = {};
|
pub const CMPLOG_MAP_H: usize = {cmplog_map_h};
|
||||||
/// The size of the accounting maps
|
/// The size of the accounting maps
|
||||||
pub const ACCOUNTING_MAP_SIZE: usize = {};
|
pub const ACCOUNTING_MAP_SIZE: usize = {acc_map_size};
|
||||||
",
|
"
|
||||||
edges_map_size, cmp_map_size, cmplog_map_w, cmplog_map_h, acc_map_size
|
|
||||||
)
|
)
|
||||||
.expect("Could not write file");
|
.expect("Could not write file");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user