Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

add cooloff period for rapidly exiting libFuzzer targets #1002

Merged
merged 2 commits into from
Jun 18, 2021
Merged
Changes from 1 commit
Commits
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
13 changes: 11 additions & 2 deletions src/agent/onefuzz-agent/src/tasks/fuzz/libfuzzer_fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use tokio::{
select,
sync::{mpsc, Notify},
task,
time::{sleep, Duration},
time::{sleep, Duration, Instant},
};
use uuid::Uuid;

Expand All @@ -37,6 +37,8 @@ const PROC_INFO_PERIOD: Duration = Duration::from_secs(30);
// Period of reporting fuzzer-generated runtime stats.
const RUNTIME_STATS_PERIOD: Duration = Duration::from_secs(60);

const COOLOFF_PERIOD: Duration = Duration::from_secs(5);

/// Maximum number of log message to safe in case of libFuzzer failing,
/// arbitrarily chosen
const LOGS_BUFFER_SIZE: usize = 1024;
Expand Down Expand Up @@ -160,6 +162,7 @@ impl LibFuzzerFuzzTask {
) -> Result<()> {
let local_input_dir = self.create_local_temp_dir().await?;
loop {
let instant = Instant::now();
self.run_fuzzer(&local_input_dir.path(), worker_id, stats_sender)
.await?;

Expand All @@ -181,6 +184,12 @@ impl LibFuzzerFuzzTask {
)
})?;
}

// if libFuzzer is exiting rapidly, give some breathing room to allow the
// handles to be reaped.
if instant.elapsed() < COOLOFF_PERIOD {
sleep(COOLOFF_PERIOD).await;
}
bmc-msft marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -335,7 +344,7 @@ async fn report_fuzzer_sys_info(
) -> Result<()> {
// Allow for sampling CPU usage.
let mut period = tokio::time::interval_at(
tokio::time::Instant::now() + PROC_INFO_COLLECTION_DELAY,
Instant::now() + PROC_INFO_COLLECTION_DELAY,
PROC_INFO_PERIOD,
);
loop {
Expand Down