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

Change centralized launcher signature #2094

Merged
merged 42 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
611e010
poc
tokatoka Apr 17, 2024
27e1d43
ai suggestion
tokatoka Apr 17, 2024
67bc09d
fix
tokatoka Apr 17, 2024
cfc712b
rename this
tokatoka Apr 17, 2024
5210862
aaaa
tokatoka Apr 17, 2024
a3b988b
fmt
tokatoka Apr 17, 2024
b6a13a2
simplify
addisoncrump Apr 17, 2024
a320c82
delete blob
tokatoka Apr 17, 2024
e2f639f
ignore
tokatoka Apr 17, 2024
d19bf13
fixup?
addisoncrump Apr 18, 2024
b97ca17
some progress on cow-ification
addisoncrump Apr 18, 2024
fe243d8
Merge branch 'main' into poc
addisoncrump Apr 18, 2024
ab5c866
some more
addisoncrump Apr 18, 2024
d9d5c53
clippy fixes, finalise tests
addisoncrump Apr 18, 2024
c336d75
whoops, missed a spot
addisoncrump Apr 18, 2024
2d92302
no std compat
addisoncrump Apr 18, 2024
9f223bf
api change: Named now requires alloc feature
addisoncrump Apr 18, 2024
b761ddb
doc fix
addisoncrump Apr 18, 2024
31bd263
missed a spot
addisoncrump Apr 18, 2024
7213d83
additional fixes
addisoncrump Apr 18, 2024
56f2b02
libfuzzer fixes
addisoncrump Apr 19, 2024
83a537a
fix tutorial
addisoncrump Apr 19, 2024
6d706f7
fix
tokatoka Apr 23, 2024
eedd5d5
Merge branch 'main' into poc
tokatoka Apr 23, 2024
b3eb0d6
add
tokatoka Apr 23, 2024
0044360
aa
tokatoka Apr 23, 2024
5d53869
fix tutorial
tokatoka Apr 23, 2024
efa9ea2
fix
tokatoka Apr 23, 2024
4d33244
Rename
tokatoka Apr 23, 2024
6df68e5
fix
tokatoka Apr 23, 2024
f2fbaee
aa
tokatoka Apr 23, 2024
ebdd241
fmt
tokatoka Apr 23, 2024
9fd3d26
aa
tokatoka Apr 23, 2024
e1a29df
aa
tokatoka Apr 23, 2024
29b4722
Merge branch 'main' into centralized_sig
tokatoka Apr 23, 2024
35d0088
another closure
tokatoka Apr 24, 2024
1e829f9
Merge branch 'centralized_sig' of github.com:AFLplusplus/LibAFL into …
tokatoka Apr 24, 2024
f84bd55
clp
tokatoka Apr 24, 2024
8d9997c
Merge branch 'main' into centralized_sig
tokatoka Apr 29, 2024
c09d30d
Merge branch 'main' into centralized_sig
tokatoka Apr 30, 2024
d5aeb10
fix stuff
tokatoka Apr 30, 2024
14868b0
Merge branch 'centralized_sig' of github.com:AFLplusplus/LibAFL into …
tokatoka Apr 30, 2024
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
4 changes: 2 additions & 2 deletions fuzzers/libfuzzer_libpng_centralized/Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ windows_alias = "unsupported"
[tasks.run_unix]
script_runner = "@shell"
script='''
./${FUZZER_NAME} --cores 0 --input ./corpus
./${FUZZER_NAME} --cores 0-1 --input ./corpus
'''
dependencies = [ "fuzzer" ]

Expand All @@ -98,7 +98,7 @@ windows_alias = "unsupported"
script_runner = "@shell"
script='''
rm -rf libafl_unix_shmem_server || true
timeout 31s ./${FUZZER_NAME} --cores 0 --input ./corpus 2>/dev/null | tee fuzz_stdout.log || true
timeout 31s ./${FUZZER_NAME} --cores 0-1 --input ./corpus 2>/dev/null | tee fuzz_stdout.log || true
if grep -qa "corpus: 30" fuzz_stdout.log; then
echo "Fuzzer is working"
else
Expand Down
17 changes: 13 additions & 4 deletions fuzzers/libfuzzer_libpng_centralized/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{env, net::SocketAddr, path::PathBuf};
use clap::{self, Parser};
use libafl::{
corpus::{Corpus, InMemoryCorpus, OnDiskCorpus},
events::{launcher::CentralizedLauncher, EventConfig},
events::{centralized::CentralizedEventManager, launcher::CentralizedLauncher, EventConfig},
executors::{inprocess::InProcessExecutor, ExitKind},
feedback_or, feedback_or_fast,
feedbacks::{CrashFeedback, MaxMapFeedback, TimeFeedback, TimeoutFeedback},
Expand Down Expand Up @@ -135,7 +135,9 @@ pub extern "C" fn libafl_main() {

let monitor = MultiMonitor::new(|s| println!("{s}"));

let mut run_client = |state: Option<_>, mut mgr, _core_id: CoreId| {
let mut run_client = |state: Option<_>,
mut mgr: CentralizedEventManager<_, _>,
_core_id: CoreId| {
// Create an observation channel using the coverage map
let edges_observer =
HitcountsMapObserver::new(unsafe { std_edges_map_observer("edges") }).track_indices();
Expand Down Expand Up @@ -241,16 +243,23 @@ pub extern "C" fn libafl_main() {
.unwrap_or_else(|_| panic!("Failed to load initial corpus at {:?}", &opt.input));
println!("We imported {} inputs from disk.", state.corpus().count());
}

fuzzer.fuzz_loop(&mut stages, &mut executor, &mut state, &mut mgr)?;
if !mgr.is_main() {
fuzzer.fuzz_loop(&mut stages, &mut executor, &mut state, &mut mgr)?;
} else {
let mut empty_stages = tuple_list!();
fuzzer.fuzz_loop(&mut empty_stages, &mut executor, &mut state, &mut mgr)?;
}
Ok(())
};

let mut main_run_client = run_client.clone(); // clone it just for borrow checker

match CentralizedLauncher::builder()
.shmem_provider(shmem_provider)
.configuration(EventConfig::from_name("default"))
.monitor(monitor)
.run_client(&mut run_client)
.main_run_client(&mut main_run_client)
.cores(&cores)
.broker_port(broker_port)
.remote_broker_addr(opt.remote_broker_addr)
Expand Down
28 changes: 25 additions & 3 deletions libafl/src/events/launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,16 +437,22 @@ where
}

/// Provides a Launcher, which can be used to launch a fuzzing run on a specified list of cores with a single main and multiple secondary nodes
/// This is for centralized, the 4th argument of the closure should mean if this is the main node.
#[cfg(all(unix, feature = "std", feature = "fork"))]
#[derive(TypedBuilder)]
#[allow(clippy::type_complexity, missing_debug_implementations)]
pub struct CentralizedLauncher<'a, CF, MT, S, SP>
pub struct CentralizedLauncher<'a, CF, MF, MT, S, SP>
where
CF: FnOnce(
Option<S>,
CentralizedEventManager<LlmpRestartingEventManager<(), S, SP>, SP>, // No hooks for centralized EM
CoreId,
) -> Result<(), Error>,
MF: FnOnce(
Option<S>,
CentralizedEventManager<LlmpRestartingEventManager<(), S, SP>, SP>, // No hooks for centralized EM
CoreId,
) -> Result<(), Error>,
S::Input: 'a,
MT: Monitor,
SP: ShMemProvider + 'static,
Expand All @@ -461,6 +467,9 @@ where
/// The 'main' function to run for each client forked. This probably shouldn't return
#[builder(default, setter(strip_option))]
run_client: Option<CF>,
/// The 'main' function to run for the main evaluator noed
#[builder(default, setter(strip_option))]
main_run_client: Option<MF>,
/// The broker port to use (or to attach to, in case [`Self::spawn_broker`] is `false`)
#[builder(default = 1337_u16)]
broker_port: u16,
Expand Down Expand Up @@ -506,13 +515,18 @@ where
}

#[cfg(all(unix, feature = "std", feature = "fork"))]
impl<CF, MT, S, SP> Debug for CentralizedLauncher<'_, CF, MT, S, SP>
impl<CF, MF, MT, S, SP> Debug for CentralizedLauncher<'_, CF, MF, MT, S, SP>
where
CF: FnOnce(
Option<S>,
CentralizedEventManager<LlmpRestartingEventManager<(), S, SP>, SP>,
CoreId,
) -> Result<(), Error>,
MF: FnOnce(
Option<S>,
CentralizedEventManager<LlmpRestartingEventManager<(), S, SP>, SP>, // No hooks for centralized EM
CoreId,
) -> Result<(), Error>,
MT: Monitor + Clone,
SP: ShMemProvider + 'static,
S: State,
Expand All @@ -531,13 +545,18 @@ where
}

#[cfg(all(unix, feature = "std", feature = "fork"))]
impl<'a, CF, MT, S, SP> CentralizedLauncher<'a, CF, MT, S, SP>
impl<'a, CF, MF, MT, S, SP> CentralizedLauncher<'a, CF, MF, MT, S, SP>
where
CF: FnOnce(
Option<S>,
CentralizedEventManager<LlmpRestartingEventManager<(), S, SP>, SP>,
CoreId,
) -> Result<(), Error>,
MF: FnOnce(
Option<S>,
CentralizedEventManager<LlmpRestartingEventManager<(), S, SP>, SP>, // No hooks for centralized EM
CoreId,
) -> Result<(), Error>,
MT: Monitor + Clone,
S: State + HasExecutions,
SP: ShMemProvider + 'static,
Expand Down Expand Up @@ -659,6 +678,9 @@ where
self.time_obs,
)?;

if index == 1 {
return (self.main_run_client.take().unwrap())(state, c_mgr, *bind_to);
}
return (self.run_client.take().unwrap())(state, c_mgr, *bind_to);
}
};
Expand Down
Loading