Class PerfFuzzGuidance
- All Implemented Interfaces:
Guidance
This class extends AFLGuidance to additionally provide
feedback about performance measures such as branch counts
or allocation sizes.
The type of performance metric used is configured by a system
property: jqf.afl.perfFeedbackType, which must have
one of the values specified in the enum PerfFuzzGuidance.PerfFeedbackType.
This guidance must be used in accordance with the right run
scripts that configure the instrumentation to emit trace events
related to events such as heap-memory loads and allocations.
This guidance class only works with a modified version of AFL that is designed to maximize performance counters. It will not work properly with stock AFL since it attempts to send more data to AFL than it usually expects.
- Author:
- Rohan Padhye
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classstatic enumConfiguration of what feedback to send AFL in second-half of map. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CounterMaps allocation sites to countsprotected CounterMaps branches to countsprotected PerfFuzzGuidance.CallingContextMaintains a dynamic calling context (i.e.protected MapOfCountersMaps acyclic execution contexts to accessed memory locations.protected static final intThe size of the "performance" map that will be sent to AFL.protected intCount of total number of branchesFields inherited from class edu.berkeley.cs.jqf.fuzz.afl.AFLGuidance
COVERAGE_MAP_SIZE, everything_ok, feedback, inputFile, proxyInput, proxyOutput, traceBits -
Constructor Summary
ConstructorsConstructorDescriptionPerfFuzzGuidance(File inputFile, File inPipe, File outPipe) PerfFuzzGuidance(String inputFileName, String inPipeName, String outPipeName) -
Method Summary
Modifier and TypeMethodDescriptionstatic doublecomputeRedundancyScore(org.eclipse.collections.api.list.primitive.IntList accessCounts) Computes a "redundancy score" for memory accesses at some program location or AEC.static intdiscretizeScore(double score) Discretizes a redundancy score to a 32-bit value.protected intgetInput()Returns an input stream containing the bytes that AFL has written to.protected voidRecords branch coverage by snooping on branch events and incrementing the branch-specific counter in the tracebits map.voidhandleResult(Result result, Throwable error) Notifies the AFL proxy that a run has completed and whether it was a success.protected inthashMemorylocation(int objectId, String field) Methods inherited from class edu.berkeley.cs.jqf.fuzz.afl.AFLGuidance
checkForTimeouts, clearFeedbackBuffer, finalize, generateCallBack, hasInput, incrementTraceBits, observeGuidanceMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface edu.berkeley.cs.jqf.fuzz.guidance.Guidance
beforeRun, observeGeneratedArgs
-
Field Details
-
PERF_MAP_SIZE
protected static final int PERF_MAP_SIZEThe size of the "performance" map that will be sent to AFL.- See Also:
-
branchCounts
Maps branches to counts -
totalBranchCount
protected int totalBranchCountCount of total number of branches -
allocCounts
Maps allocation sites to counts -
memoryAccesses
Maps acyclic execution contexts to accessed memory locations. -
callingContext
Maintains a dynamic calling context (i.e. call stack).Note: We assume there is only a single app thread running. For supporting multiple threads, we would have to store a map from threads to calling contexts.
-
-
Constructor Details
-
PerfFuzzGuidance
- Throws:
IOException
-
PerfFuzzGuidance
public PerfFuzzGuidance(String inputFileName, String inPipeName, String outPipeName) throws IOException - Throws:
IOException
-
-
Method Details
-
getInput
Description copied from class:AFLGuidanceReturns an input stream containing the bytes that AFL has written to.- Specified by:
getInputin interfaceGuidance- Overrides:
getInputin classAFLGuidance- Returns:
- a stream of bytes to be used by the input generator(s)
-
handleEvent
Description copied from class:AFLGuidanceRecords branch coverage by snooping on branch events and incrementing the branch-specific counter in the tracebits map.- Overrides:
handleEventin classAFLGuidance- Parameters:
e- the trace event to handle
-
handleResult
Description copied from class:AFLGuidanceNotifies the AFL proxy that a run has completed and whether it was a success. 1This method also sends coverage information back to the AFL proxy, which is responsible for updating the shared memory region used by afl-fuzz.
If the trial resulted in an assumption violation, we do not mark it is a crash, but we also do not send any coverage feedback so that AFL does not consider the last input interesting enough to keep in its queue.
- Specified by:
handleResultin interfaceGuidance- Overrides:
handleResultin classAFLGuidance- Parameters:
result- the result of the fuzzing trialerror- the exception thrown by the test, ornull
-
hashMemorylocation
-
getAyclicExecutionContextForEvent
-
computeRedundancyScore
public static double computeRedundancyScore(org.eclipse.collections.api.list.primitive.IntList accessCounts) Computes a "redundancy score" for memory accesses at some program location or AEC.The redundancy score formula is chosen such that the value is high when many memory locations are accessed many times each. For a total of N^2 accesses, the score is maximized when N items are accessed N times each. The score is zero when either all items are accessed just once or when only one item is accessed always.
- Parameters:
accessCounts- A collection of access counts, one positive integer for each memory access- Returns:
- the redundancy score
-
discretizeScore
public static int discretizeScore(double score) Discretizes a redundancy score to a 32-bit value.- Parameters:
score- a value between 0.0 and 1.0, inclusive- Returns:
- a value between 0 and 2^31-1, inclusive
-