Skip to content

Commit ba93e9d

Browse files
authored
Add support for AFL_LLVM/GCC_ONLY_FSRV (#3245)
* Add support for AFL_LLVM/GCC_ONLY_FSRV * clippy
1 parent ddd0930 commit ba93e9d

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

fuzzers/forkserver/fuzzbench_forkserver_sand/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ fn fuzz(
388388
.shmem_provider(&mut shmem_provider)
389389
.parse_afl_cmdline(arguments)
390390
.coverage_map_size(MAP_SIZE)
391+
.fsrv_only(true)
391392
.timeout(timeout)
392393
.kill_signal(signal)
393394
.is_persistent(true)

libafl/src/executors/forkserver.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ pub const SHM_CMPLOG_ENV_VAR: &str = "__AFL_CMPLOG_SHM_ID";
159159
/// Environment variable key for a custom AFL coverage map size
160160
pub const AFL_MAP_SIZE_ENV_VAR: &str = "AFL_MAP_SIZE";
161161

162+
/// Environment variable keys to skip instrumentation (LLVM variant).
163+
pub const AFL_LLVM_ONLY_FSRV_VAR: &str = "AFL_LLVM_ONLY_FSRV";
164+
165+
/// Environment variable keys to skip instrumentation (GCC variant).
166+
pub const AFL_GCC_ONLY_FSRV_VAR: &str = "AFL_GCC_ONLY_FSRV";
167+
162168
/// The default signal to use to kill child processes
163169
const KILL_SIGNAL_DEFAULT: Signal = Signal::SIGTERM;
164170

@@ -374,6 +380,7 @@ impl Forkserver {
374380
memlimit: u64,
375381
is_persistent: bool,
376382
is_deferred_frksrv: bool,
383+
is_fsrv_only: bool,
377384
dump_asan_logs: bool,
378385
coverage_map_size: Option<usize>,
379386
debug_output: bool,
@@ -453,6 +460,11 @@ impl Forkserver {
453460
command.env("__AFL_DEFER_FORKSRV", "1");
454461
}
455462

463+
if is_fsrv_only {
464+
command.env(AFL_GCC_ONLY_FSRV_VAR, "1");
465+
command.env(AFL_LLVM_ONLY_FSRV_VAR, "1");
466+
}
467+
456468
#[cfg(feature = "regex")]
457469
{
458470
let asan_options = if dump_asan_logs {
@@ -844,12 +856,14 @@ where
844856

845857
/// The builder for `ForkserverExecutor`
846858
#[derive(Debug)]
859+
#[expect(clippy::struct_excessive_bools)]
847860
pub struct ForkserverExecutorBuilder<'a, SP> {
848861
target_inner: StdTargetArgsInner,
849862
child_env_inner: StdChildArgsInner,
850863
uses_shmem_testcase: bool,
851864
is_persistent: bool,
852865
is_deferred_frksrv: bool,
866+
is_fsrv_only: bool,
853867
autotokens: Option<&'a mut Tokens>,
854868
shmem_provider: Option<&'a mut SP>,
855869
max_input_size: usize,
@@ -1058,6 +1072,7 @@ where
10581072
0,
10591073
self.is_persistent,
10601074
self.is_deferred_frksrv,
1075+
self.is_fsrv_only,
10611076
self.has_asan_obs(),
10621077
self.map_size,
10631078
self.child_env_inner.debug_child,
@@ -1316,6 +1331,14 @@ where
13161331
Ok(actual_map_size as usize)
13171332
}
13181333

1334+
#[must_use]
1335+
/// If set to true, we will only spin up a forkserver without any coverage collected. This is useful for several
1336+
/// scenario like slave executors of SAND or cmplog executors.
1337+
pub fn fsrv_only(mut self, fsrv_only: bool) -> Self {
1338+
self.is_fsrv_only = fsrv_only;
1339+
self
1340+
}
1341+
13191342
/// Use autodict?
13201343
#[must_use]
13211344
pub fn autotokens(mut self, tokens: &'a mut Tokens) -> Self {
@@ -1402,6 +1425,7 @@ impl<'a> ForkserverExecutorBuilder<'a, UnixShMemProvider> {
14021425
uses_shmem_testcase: false,
14031426
is_persistent: false,
14041427
is_deferred_frksrv: false,
1428+
is_fsrv_only: false,
14051429
autotokens: None,
14061430
shmem_provider: None,
14071431
map_size: None,
@@ -1430,6 +1454,7 @@ impl<'a> ForkserverExecutorBuilder<'a, UnixShMemProvider> {
14301454
uses_shmem_testcase: self.uses_shmem_testcase,
14311455
is_persistent: self.is_persistent,
14321456
is_deferred_frksrv: self.is_deferred_frksrv,
1457+
is_fsrv_only: self.is_fsrv_only,
14331458
autotokens: self.autotokens,
14341459
map_size: self.map_size,
14351460
max_input_size: self.max_input_size,

0 commit comments

Comments
 (0)