Skip to content

Commit

Permalink
fix fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
domenukk committed Nov 7, 2024
1 parent f9fff26 commit e3a3ac6
Show file tree
Hide file tree
Showing 46 changed files with 94 additions and 98 deletions.
2 changes: 1 addition & 1 deletion fuzzers/baby/baby_fuzzer_custom_executor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use libafl_bolts::{current_nanos, nonzero, rands::StdRand, tuples::tuple_list, A

/// Coverage map with explicit assignments due to the lack of instrumentation
static mut SIGNALS: [u8; 16] = [0; 16];
static mut SIGNALS_PTR: *mut u8 = &raw mut (SIGNALS) as _;
static mut SIGNALS_PTR: *mut u8 = &raw mut SIGNALS as _;
static SIGNALS_LEN: usize = unsafe { (*&raw const (SIGNALS)).len() };

/// Assign a signal to the signals map
Expand Down
2 changes: 1 addition & 1 deletion fuzzers/baby/baby_fuzzer_unicode/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice};

/// Coverage map with explicit assignments due to the lack of instrumentation
static mut SIGNALS: [u8; 64] = [0; 64];
static mut SIGNALS_PTR: *mut u8 = &raw mut (SIGNALS).cast();
static mut SIGNALS_PTR: *mut u8 = &raw mut SIGNALS.cast();
static mut SIGNALS_LEN: usize = unsafe { (*&raw const (SIGNALS)).len() };

/// Assign a signal to the signals map
Expand Down
2 changes: 1 addition & 1 deletion fuzzers/binary_only/fuzzbench_qemu/src/fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ fn fuzz(
HitcountsMapObserver::new(VariableMapObserver::from_mut_slice(
"edges",
OwnedMutSlice::from_raw_parts_mut(edges_map_mut_ptr(), EDGES_MAP_ALLOCATED_SIZE),
&raw mut (MAX_EDGES_FOUND),
&raw mut MAX_EDGES_FOUND,
))
.track_indices()
};
Expand Down
2 changes: 1 addition & 1 deletion fuzzers/binary_only/qemu_launcher/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl<M: Monitor> Instance<'_, M> {
HitcountsMapObserver::new(VariableMapObserver::from_mut_slice(
"edges",
OwnedMutSlice::from_raw_parts_mut(edges_map_mut_ptr(), EDGES_MAP_DEFAULT_SIZE),
&raw mut (MAX_EDGES_FOUND),
&raw mut MAX_EDGES_FOUND,
))
.track_indices()
};
Expand Down
4 changes: 2 additions & 2 deletions fuzzers/binary_only/tinyinst_simple/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn main() {
// use file to pass testcases
// let args = vec!["test.exe".to_string(), "-f".to_string(), "@@".to_string()];

let coverage = OwnedMutPtr::Ptr(&raw mut (COVERAGE));
let coverage = OwnedMutPtr::Ptr(&raw mut COVERAGE);
let observer = ListObserver::new("cov", coverage);
let mut feedback = ListFeedback::new(&observer);
#[cfg(windows)]
Expand Down Expand Up @@ -69,7 +69,7 @@ fn main() {
.persistent("test.exe".to_string(), "fuzz".to_string(), 1, 10000)
.timeout(Duration::new(5, 0))
.shmem_provider(&mut shmem_provider)
.coverage_ptr(&raw mut (COVERAGE))
.coverage_ptr(&raw mut COVERAGE)
.build(tuple_list!(observer))
.unwrap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub fn fuzz() {
HitcountsMapObserver::new(VariableMapObserver::from_mut_slice(
"edges",
OwnedMutSlice::from_raw_parts_mut(edges_map_mut_ptr(), EDGES_MAP_DEFAULT_SIZE),
&raw mut (MAX_EDGES_FOUND),
&raw mut MAX_EDGES_FOUND,
))
.track_indices()
};
Expand Down
2 changes: 1 addition & 1 deletion fuzzers/full_system/qemu_baremetal/src/fuzzer_low_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn fuzz() {
HitcountsMapObserver::new(VariableMapObserver::from_mut_slice(
"edges",
OwnedMutSlice::from_raw_parts_mut(edges_map_mut_ptr(), EDGES_MAP_DEFAULT_SIZE),
&raw mut (MAX_EDGES_FOUND),
&raw mut MAX_EDGES_FOUND,
))
.track_indices()
};
Expand Down
2 changes: 1 addition & 1 deletion fuzzers/full_system/qemu_baremetal/src/fuzzer_sync_exit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn fuzz() {
HitcountsMapObserver::new(VariableMapObserver::from_mut_slice(
"edges",
OwnedMutSlice::from_raw_parts_mut(edges_map_mut_ptr(), EDGES_MAP_DEFAULT_SIZE),
&raw mut (MAX_EDGES_FOUND),
&raw mut MAX_EDGES_FOUND,
))
.track_indices()
};
Expand Down
2 changes: 1 addition & 1 deletion fuzzers/full_system/qemu_linux_kernel/src/fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub fn fuzz() {
HitcountsMapObserver::new(VariableMapObserver::from_mut_slice(
"edges",
OwnedMutSlice::from_raw_parts_mut(edges_map_mut_ptr(), EDGES_MAP_ALLOCATED_SIZE),
&raw mut (MAX_EDGES_FOUND),
&raw mut MAX_EDGES_FOUND,
))
.track_indices()
};
Expand Down
2 changes: 1 addition & 1 deletion fuzzers/full_system/qemu_linux_process/src/fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn fuzz() {
HitcountsMapObserver::new(VariableMapObserver::from_mut_slice(
"edges",
OwnedMutSlice::from_raw_parts_mut(edges_map_mut_ptr(), EDGES_MAP_DEFAULT_SIZE),
&raw mut (MAX_EDGES_FOUND),
&raw mut MAX_EDGES_FOUND,
))
.track_indices()
};
Expand Down
4 changes: 2 additions & 2 deletions fuzzers/fuzz_anything/push_harness/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ fn input_generator() {
ExitKind::Ok
};

let signals_ptr = unsafe { &raw mut (SIGNALS) };
let signals_ptr = unsafe { &raw mut SIGNALS };
let signals_len = unsafe { *signals_ptr }.len();

// Create an observation channel using the signals map
let observer =
unsafe { StdMapObserver::from_mut_ptr("signals", &raw mut (SIGNALS) as _, signals_len) };
unsafe { StdMapObserver::from_mut_ptr("signals", &raw mut SIGNALS as _, signals_len) };

// Feedback to rate the interestingness of an input
let mut feedback = MaxMapFeedback::new(&observer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use {
/// Coverage map with explicit assignments due to the lack of instrumentation
const SIGNALS_LEN: usize = 16;
static mut SIGNALS: [u8; SIGNALS_LEN] = [0; 16];
static mut SIGNALS_PTR: *mut u8 = &raw mut (SIGNALS) as _;
static mut SIGNALS_PTR: *mut u8 = &raw mut SIGNALS as _;

/// Assign a signal to the signals map
fn signals_set(idx: usize) {
Expand Down
2 changes: 1 addition & 1 deletion fuzzers/structure_aware/baby_fuzzer_gramatron/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use libafl_bolts::{rands::StdRand, tuples::tuple_list};
/// Coverage map with explicit assignments due to the lack of instrumentation
const SIGNALS_LEN: usize = 16;
static mut SIGNALS: [u8; SIGNALS_LEN] = [0; SIGNALS_LEN];
static mut SIGNALS_PTR: *mut u8 = unsafe { &raw mut (SIGNALS) as _ };
static mut SIGNALS_PTR: *mut u8 = unsafe { &raw mut SIGNALS as _ };
/*
/// Assign a signal to the signals map
fn signals_set(idx: usize) {
Expand Down
2 changes: 1 addition & 1 deletion libafl/src/events/llmp/restarting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ where
// At this point we are the fuzzer *NOT* the restarter.
// We setup signal handlers to clean up shmem segments used by state restorer
#[cfg(all(unix, not(miri)))]
if let Err(_e) = unsafe { setup_signal_handler(&raw mut (EVENTMGR_SIGHANDLER_STATE)) } {
if let Err(_e) = unsafe { setup_signal_handler(&raw mut EVENTMGR_SIGHANDLER_STATE) } {
// We can live without a proper ctrl+c signal handler. Print and ignore.
log::error!("Failed to setup signal handlers: {_e}");
}
Expand Down
2 changes: 1 addition & 1 deletion libafl/src/events/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ where
// At this point we are the fuzzer *NOT* the restarter.
// We setup signal handlers to clean up shmem segments used by state restorer
#[cfg(all(unix, not(miri)))]
if let Err(_e) = unsafe { setup_signal_handler(&raw mut (EVENTMGR_SIGHANDLER_STATE)) } {
if let Err(_e) = unsafe { setup_signal_handler(&raw mut EVENTMGR_SIGHANDLER_STATE) } {
// We can live without a proper ctrl+c signal handler. Print and ignore.
log::error!("Failed to setup signal handlers: {_e}");
}
Expand Down
2 changes: 1 addition & 1 deletion libafl/src/events/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ where
// At this point we are the fuzzer *NOT* the restarter.
// We setup signal handlers to clean up shmem segments used by state restorer
#[cfg(all(unix, not(miri)))]
if let Err(_e) = unsafe { setup_signal_handler(&raw mut (EVENTMGR_SIGHANDLER_STATE)) } {
if let Err(_e) = unsafe { setup_signal_handler(&raw mut EVENTMGR_SIGHANDLER_STATE) } {
// We can live without a proper ctrl+c signal handler. Print and ignore.
log::error!("Failed to setup signal handlers: {_e}");
}
Expand Down
6 changes: 3 additions & 3 deletions libafl/src/executors/hooks/inprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ where
fn pre_exec(&mut self, state: &mut S, input: &S::Input) {
#[cfg(feature = "std")]
unsafe {
let data = &raw mut (GLOBAL_STATE);
let data = &raw mut GLOBAL_STATE;
(*data).crash_handler = self.crash_handler;
(*data).timeout_handler = self.timeout_handler;
}
Expand Down Expand Up @@ -245,7 +245,7 @@ where
// We get a pointer to `GLOBAL_STATE` that will be initialized at this point in time.
// This unsafe is needed in stable but not in nightly. Remove in the future(?)
#[allow(unused_unsafe)]
let data = unsafe { &raw mut (GLOBAL_STATE) };
let data = unsafe { &raw mut GLOBAL_STATE };
#[cfg(feature = "std")]
unix_signal_handler::setup_panic_hook::<E, EM, OF, Z>();
// # Safety
Expand Down Expand Up @@ -287,7 +287,7 @@ where
let ret;
#[cfg(feature = "std")]
unsafe {
let data = &raw mut (GLOBAL_STATE);
let data = &raw mut GLOBAL_STATE;
crate::executors::hooks::windows::windows_exception_handler::setup_panic_hook::<
E,
EM,
Expand Down
8 changes: 4 additions & 4 deletions libafl/src/executors/hooks/inprocess_fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ where
/// Call before running a target.
fn pre_exec(&mut self, _state: &mut S, _input: &S::Input) {
unsafe {
let data = &raw mut (FORK_EXECUTOR_GLOBAL_DATA);
let data = &raw mut FORK_EXECUTOR_GLOBAL_DATA;
(*data).crash_handler = self.crash_handler;
(*data).timeout_handler = self.timeout_handler;
compiler_fence(Ordering::SeqCst);
Expand All @@ -65,7 +65,7 @@ impl<S> InChildProcessHooks<S> {
{
#[cfg_attr(miri, allow(unused_variables, unused_unsafe))]
unsafe {
let data = &raw mut (FORK_EXECUTOR_GLOBAL_DATA);
let data = &raw mut FORK_EXECUTOR_GLOBAL_DATA;
// child_signal_handlers::setup_child_panic_hook::<E, I, OT, S>();
#[cfg(not(miri))]
setup_signal_handler(data)?;
Expand Down Expand Up @@ -157,14 +157,14 @@ impl SignalHandler for InProcessForkExecutorGlobalData {
if !FORK_EXECUTOR_GLOBAL_DATA.timeout_handler.is_null() {
let func: ForkHandlerFuncPtr =
transmute(FORK_EXECUTOR_GLOBAL_DATA.timeout_handler);
(func)(signal, info, context, &raw mut (FORK_EXECUTOR_GLOBAL_DATA));
(func)(signal, info, context, &raw mut FORK_EXECUTOR_GLOBAL_DATA);
}
},
_ => unsafe {
if !FORK_EXECUTOR_GLOBAL_DATA.crash_handler.is_null() {
let func: ForkHandlerFuncPtr =
transmute(FORK_EXECUTOR_GLOBAL_DATA.crash_handler);
(func)(signal, info, context, &raw mut (FORK_EXECUTOR_GLOBAL_DATA));
(func)(signal, info, context, &raw mut FORK_EXECUTOR_GLOBAL_DATA);
}
},
}
Expand Down
17 changes: 8 additions & 9 deletions libafl/src/executors/hooks/timer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! The struct `TimerStruct` will absorb all the difference in timeout implementation in various system.
use core::time::Duration;
#[cfg(any(windows, target_os = "linux"))]
#[cfg(any(windows, target_os = "linux", unix))]
use core::time::Duration;
#[cfg(target_os = "linux")]
use core::{mem::zeroed, ptr::null_mut};
Expand Down Expand Up @@ -184,7 +183,7 @@ impl TimerStruct {
let ptp_timer = unsafe {
CreateThreadpoolTimer(
Some(timeout_handler),
Some(&raw mut (GLOBAL_STATE) as *mut c_void),
Some(&raw mut GLOBAL_STATE as *mut c_void),
Some(&TP_CALLBACK_ENVIRON_V3::default()),
)
}
Expand Down Expand Up @@ -224,7 +223,7 @@ impl TimerStruct {
unsafe {
#[cfg(not(miri))]
// creates a new per-process interval timer
libc::timer_create(libc::CLOCK_MONOTONIC, null_mut(), &raw mut (timerid));
libc::timer_create(libc::CLOCK_MONOTONIC, null_mut(), &raw mut timerid);
}

Self {
Expand Down Expand Up @@ -265,11 +264,11 @@ impl TimerStruct {
/// Set timer
pub fn set_timer(&mut self) {
unsafe {
let data = &raw mut (GLOBAL_STATE);
let data = &raw mut GLOBAL_STATE;

write_volatile(&raw mut ((*data).ptp_timer), Some(*self.ptp_timer()));
write_volatile(
&raw mut ((*data).critical),
&raw mut (*data).critical,
&raw mut (*self.critical_mut()) as *mut c_void,
);
let tm: i64 = -self.milli_sec() * 10 * 1000;
Expand Down Expand Up @@ -297,13 +296,13 @@ impl TimerStruct {
unsafe {
if self.batch_mode {
if self.executions == 0 {
libc::timer_settime(self.timerid, 0, &raw mut (self.itimerspec), null_mut());
libc::timer_settime(self.timerid, 0, &raw mut self.itimerspec, null_mut());
self.tmout_start_time = current_time();
}
self.start_time = current_time();
} else {
#[cfg(not(miri))]
libc::timer_settime(self.timerid, 0, &raw mut (self.itimerspec), null_mut());
libc::timer_settime(self.timerid, 0, &raw mut self.itimerspec, null_mut());
}
}
}
Expand Down Expand Up @@ -362,7 +361,7 @@ impl TimerStruct {
// # Safety
// The value accesses are guarded by a critical section.
unsafe {
let data = &raw mut (GLOBAL_STATE);
let data = &raw mut GLOBAL_STATE;

compiler_fence(Ordering::SeqCst);
EnterCriticalSection(self.critical_mut());
Expand Down
4 changes: 2 additions & 2 deletions libafl/src/executors/hooks/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub mod unix_signal_handler {
context: Option<&mut ucontext_t>,
) {
unsafe {
let data = &raw mut (GLOBAL_STATE);
let data = &raw mut GLOBAL_STATE;
let in_handler = (*data).set_in_handler(true);
match signal {
Signal::SigUser2 | Signal::SigAlarm => {
Expand Down Expand Up @@ -91,7 +91,7 @@ pub mod unix_signal_handler {
let old_hook = panic::take_hook();
panic::set_hook(Box::new(move |panic_info| unsafe {
old_hook(panic_info);
let data = &raw mut (GLOBAL_STATE);
let data = &raw mut GLOBAL_STATE;
let in_handler = (*data).set_in_handler(true);
if (*data).is_valid() {
// We are fuzzing!
Expand Down
6 changes: 3 additions & 3 deletions libafl/src/executors/hooks/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub mod windows_asan_handler {
<<E as UsesState>::State as HasSolutions>::Solutions: Corpus<Input = E::Input>, //delete me
<<<E as UsesState>::State as HasCorpus>::Corpus as Corpus>::Input: Clone, //delete me
{
let data = &raw mut (GLOBAL_STATE);
let data = &raw mut GLOBAL_STATE;
(*data).set_in_handler(true);
// Have we set a timer_before?
if (*data).ptp_timer.is_some() {
Expand Down Expand Up @@ -161,7 +161,7 @@ pub mod windows_exception_handler {
exception_pointers: *mut EXCEPTION_POINTERS,
) {
unsafe {
let data = &raw mut (GLOBAL_STATE);
let data = &raw mut GLOBAL_STATE;
let in_handler = (*data).set_in_handler(true);
if !(*data).crash_handler.is_null() {
let func: HandlerFuncPtr = transmute((*data).crash_handler);
Expand Down Expand Up @@ -196,7 +196,7 @@ pub mod windows_exception_handler {
{
let old_hook = panic::take_hook();
panic::set_hook(Box::new(move |panic_info| unsafe {
let data = &raw mut (GLOBAL_STATE);
let data = &raw mut GLOBAL_STATE;
let in_handler = (*data).set_in_handler(true);
// Have we set a timer_before?
if (*data).ptp_timer.is_some() {
Expand Down
4 changes: 2 additions & 2 deletions libafl/src/executors/inprocess/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ where
executor_ptr: *const c_void,
) {
unsafe {
let data = &raw mut (GLOBAL_STATE);
let data = &raw mut GLOBAL_STATE;
write_volatile(
&raw mut ((*data).current_input_ptr),
ptr::from_ref(input) as *const c_void,
Expand Down Expand Up @@ -133,7 +133,7 @@ where
_input: &<Self as UsesInput>::Input,
) {
unsafe {
let data = &raw mut (GLOBAL_STATE);
let data = &raw mut GLOBAL_STATE;

write_volatile(&raw mut ((*data).current_input_ptr), null());
compiler_fence(Ordering::SeqCst);
Expand Down
2 changes: 1 addition & 1 deletion libafl/src/executors/inprocess/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ where
+ ExecutionProcessor<EM, E::Observers>,
<<E as UsesState>::State as HasSolutions>::Solutions: Corpus<Input = E::Input>, //delete me
{
let data = &raw mut (GLOBAL_STATE);
let data = &raw mut GLOBAL_STATE;
let in_handler = (*data).set_in_handler(true);

if (*data).is_valid() {
Expand Down
6 changes: 3 additions & 3 deletions libafl/src/executors/inprocess_fork/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ where
let mut timerid: libc::timer_t = null_mut();
// creates a new per-process interval timer
// we can't do this from the parent, timerid is unique to each process.
libc::timer_create(libc::CLOCK_MONOTONIC, null_mut(), &raw mut (timerid));
libc::timer_create(libc::CLOCK_MONOTONIC, null_mut(), &raw mut timerid);

// log::info!("Set timer! {:#?} {timerid:#?}", self.itimerspec);
let _: i32 = libc::timer_settime(timerid, 0, &raw mut (self.itimerspec), null_mut());
let _: i32 = libc::timer_settime(timerid, 0, &raw mut self.itimerspec, null_mut());
}
#[cfg(not(target_os = "linux"))]
{
Expand Down Expand Up @@ -224,7 +224,7 @@ where
input: &<Self as UsesInput>::Input,
) {
unsafe {
let data = &raw mut (FORK_EXECUTOR_GLOBAL_DATA);
let data = &raw mut FORK_EXECUTOR_GLOBAL_DATA;
write_volatile(
&raw mut ((*data).executor_ptr),
ptr::from_ref(self) as *const c_void,
Expand Down
2 changes: 1 addition & 1 deletion libafl/src/executors/inprocess_fork/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ pub mod child_signal_handlers {
let old_hook = panic::take_hook();
panic::set_hook(Box::new(move |panic_info| unsafe {
old_hook(panic_info);
let data = &raw mut (FORK_EXECUTOR_GLOBAL_DATA);
let data = &raw mut FORK_EXECUTOR_GLOBAL_DATA;
if !data.is_null() && (*data).is_valid() {
let executor = (*data).executor_mut::<E>();
let mut observers = executor.observers_mut();
Expand Down
Loading

0 comments on commit e3a3ac6

Please sign in to comment.