diff --git a/fuzzers/forkserver/forkserver_libafl_cc/src/main.rs b/fuzzers/forkserver/forkserver_libafl_cc/src/main.rs index ddcc7229d0..34f97f5b28 100644 --- a/fuzzers/forkserver/forkserver_libafl_cc/src/main.rs +++ b/fuzzers/forkserver/forkserver_libafl_cc/src/main.rs @@ -21,7 +21,7 @@ use libafl::{ use libafl_bolts::{ rands::StdRand, shmem::{ShMem, ShMemProvider, UnixShMemProvider}, - tuples::{tuple_list, Handled, MatchNameRef, Merge}, + tuples::{tuple_list, Handled, Merge}, AsSliceMut, Truncate, }; use libafl_targets::EDGES_MAP_DEFAULT_SIZE; diff --git a/fuzzers/fuzz_anything/baby_no_std/src/main.rs b/fuzzers/fuzz_anything/baby_no_std/src/main.rs index b07ffdea77..6567720ada 100644 --- a/fuzzers/fuzz_anything/baby_no_std/src/main.rs +++ b/fuzzers/fuzz_anything/baby_no_std/src/main.rs @@ -8,7 +8,6 @@ extern crate alloc; use alloc::ffi::CString; #[cfg(not(any(windows)))] use core::panic::PanicInfo; -use core::ptr::write; use libafl::{ corpus::InMemoryCorpus, @@ -20,12 +19,12 @@ use libafl::{ inputs::{BytesInput, HasTargetBytes}, monitors::SimpleMonitor, mutators::{havoc_mutations::havoc_mutations, scheduled::StdScheduledMutator}, - observers::StdMapObserver, + observers::ConstMapObserver, schedulers::QueueScheduler, stages::mutational::StdMutationalStage, state::StdState, }; -use libafl_bolts::{nonzero, rands::StdRand, tuples::tuple_list, AsSlice}; +use libafl_bolts::{nonnull_raw_mut, nonzero, rands::StdRand, tuples::tuple_list, AsSlice}; #[cfg(any(windows, unix))] use libc::{abort, printf}; use static_alloc::Bump; @@ -48,11 +47,10 @@ fn panic(_info: &PanicInfo) -> ! { /// Coverage map with explicit assignments due to the lack of instrumentation static mut SIGNALS: [u8; 16] = [0; 16]; -static mut SIGNALS_PTR: *mut u8 = unsafe { SIGNALS.as_mut_ptr() }; /// Assign a signal to the signals map fn signals_set(idx: usize) { - unsafe { write(SIGNALS_PTR.add(idx), 1) }; + unsafe { SIGNALS[idx] = 1 }; } /// Provide custom time in `no_std` environment @@ -88,8 +86,7 @@ pub extern "C" fn main(_argc: isize, _argv: *const *const u8) -> isize { }; // Create an observation channel using the signals map - let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS_PTR, SIGNALS.len()) }; - + let observer = unsafe { ConstMapObserver::from_mut_ptr("signals", nonnull_raw_mut!(SIGNALS)) }; // Feedback to rate the interestingness of an input let mut feedback = MaxMapFeedback::new(&observer); diff --git a/fuzzers/fuzz_anything/push_harness/src/main.rs b/fuzzers/fuzz_anything/push_harness/src/main.rs index 40b744c819..2dd1d9dfee 100644 --- a/fuzzers/fuzz_anything/push_harness/src/main.rs +++ b/fuzzers/fuzz_anything/push_harness/src/main.rs @@ -39,7 +39,7 @@ fn input_generator() { ExitKind::Ok }; - let signals_ptr = unsafe { &raw mut SIGNALS }; + let signals_ptr = &raw mut SIGNALS; let signals_len = unsafe { *signals_ptr }.len(); // Create an observation channel using the signals map diff --git a/fuzzers/inprocess/libfuzzer_libpng_accounting/src/lib.rs b/fuzzers/inprocess/libfuzzer_libpng_accounting/src/lib.rs index 5b36981da2..474493963d 100644 --- a/fuzzers/inprocess/libfuzzer_libpng_accounting/src/lib.rs +++ b/fuzzers/inprocess/libfuzzer_libpng_accounting/src/lib.rs @@ -2,7 +2,7 @@ //! The example harness is built for libpng. //! In this example, you will see the use of the `launcher` feature. //! The `launcher` will spawn new processes for each cpu core. -use core::time::Duration; +use core::{ptr::addr_of, time::Duration}; use std::{env, net::SocketAddr, path::PathBuf}; use clap::Parser; @@ -200,7 +200,7 @@ pub extern "C" fn libafl_main() { &edges_observer, &mut state, QueueScheduler::new(), - unsafe { &ACCOUNTING_MEMOP_MAP }, + unsafe { &*addr_of!(ACCOUNTING_MEMOP_MAP) }, ); // A fuzzer with feedbacks and a corpus scheduler diff --git a/fuzzers/structure_aware/baby_fuzzer_gramatron/src/main.rs b/fuzzers/structure_aware/baby_fuzzer_gramatron/src/main.rs index b4efb17f55..c07e1b2f16 100644 --- a/fuzzers/structure_aware/baby_fuzzer_gramatron/src/main.rs +++ b/fuzzers/structure_aware/baby_fuzzer_gramatron/src/main.rs @@ -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 = &raw mut SIGNALS as _; /* /// Assign a signal to the signals map fn signals_set(idx: usize) {