When execution time of fork run is much longer than one persistent iteration, all fork execuions will timeout. #1545
Labels
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
Describe the bug
In persistent mode, there are 2 ways to execute a test case:
fork
to create a process to execute the test case.__afl_persistent_loop
, fork server will send aSIGCONT
signal to resume the process to execute the test case.In general, forking a process should be slower than resuming the loop, and this is the reason why persistent mode is designed. For example, in
aflpp_driver.c
, before entering the persistent loop, 2 functions,LLVMFuzzerTestOneInput
and__asan_poison_memory_region
, are called, plus the overhead offork
:However, if fork execution is so slow such that its execution time is longer than timeout limit (which is calculated from initial seed corpus), all following execution will timeout. The reason is that as long as one timeout occurs, the process executing the test case will be killed so the next execution must fork a new process, which results in timeout again and forever. This is not desirable.
To Reproduce
The following code can trigger the problem. Although this case seems to be very handcrafted, this problem do occur in real world fuzzing, which is the reason why I found this issue.
My Solution
The reason why timeout limit can be lower than time required to execute fork run is that when calculating
exec_us
of a seed in calibration, average time of all calibration executions is calculated. If only one of the execution usesfork
and others are just resuming persistent loop, the average value will be much lower than time offork
execution, so when calculatingmax_us
, it can be lower than time offork
execution. Therefore, instead of using average time, we get a max time for each seed and there must be one of them being the time offork
execution.#1544
The text was updated successfully, but these errors were encountered: