-
-
Notifications
You must be signed in to change notification settings - Fork 330
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
Fix file sync timing and prevent crash on missing SyncFromDiskMetadata #2595
Conversation
libafl/src/stages/sync.rs
Outdated
last_time: new_max_time, | ||
left_to_sync: new_files, | ||
}; | ||
match state.metadata_map_mut().get_mut::<SyncFromDiskMetadata>() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use state.metadata_or_insert_with
here, should be shorter
Ah now we have one extra allocation :D |
But actually, just set them to default values, you set them one step below anyway? |
can you define "default values"? UNIX_EPOCH for max_time and empty vector for |
just 0 and Vec::new() |
We can even remove the parameters from |
I'd proceed like this then |
AFLplusplus#2595) * max_time is the current_time(); SyncFromDiskMetadata might not be in state * using metadata_or_insert_with
I (think I) fixed the following two issues in the SyncFromDisk stage:
last_time
used to determine when to sync files was being updated by adding a fixed interval to the previous check time. This caused newly created files to be re-synced multiple times until the sync interval caught up with their timestamp. Let's say we start the fuzzer at 10:00:00 and begin debugging. After the first sync, thelast_time
is updated to 10:00:05. Now, after 8 minutes of debugging, it’s 10:08:00, and we’re still debugging. During this time, we created two files (A and B) in the sync directory at 10:03:00. At the next sync iteration, thelast_time
is still 10:00:05, so the fuzzer syncs the files A and B. However, because thelast_time
is behind the actual creation time of the files (10:03:00), A and B continue to be re-synced repeatedly until thelast_time
catches up to their timestamps.Solution: we better store the
current_time()
aslast_time
and check the files creation time against the previouslast_time
.SyncFromDiskMetadata
we were doing:state.metadata_mut::<SyncFromDiskMetadata>().unwrap()
, which could cause a crash if the metadata was not present in state (first sync)