-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
infra: add support for non-persistent mode AFL #7343
base: master
Are you sure you want to change the base?
Changes from 1 commit
1ee8bf1
1b3ec2f
fffadd7
5ae7cc5
33fa484
be05f2d
ca1074d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,6 +132,10 @@ if [[ "$FUZZING_ENGINE" = afl ]]; then | |
|
||
CMD_LINE="$OUT/afl-fuzz $AFL_FUZZER_ARGS -i $CORPUS_DIR -o $FUZZER_OUT $(get_dictionary) $* -- $OUT/$FUZZER" | ||
|
||
if [[ "$FUZZER" == *"non_persistent"* ]]; then | ||
CMD_LINE="$CMD_LINE @@" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are all non-persistent targets called like this: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah exactly, I'm going to make an API for doing this in the .options file we already support. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't we always add the @@ here? That way we don't need to scan the binary, oss fuzz doesn't have to care There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a) because otherwise it is not needed, b) I am not sure if the current commit on oss-fuzz of afl++ is one that works fine, or is an older one that has that strong performance decrease otherwise. I want to push an update, but not before next week. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Understood. |
||
fi | ||
|
||
echo afl++ setup: | ||
env|grep AFL_ | ||
cat "$OUT/afl_options.txt" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* Copyright 2022 Google LLC | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
#include "readelf.h" | ||
DavidKorczynski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Hack to satisfy OSS-Fuzz logic that looks for | ||
// LLVMFuzzerTestOneInput in a binary. | ||
char *random_string = "LLVMFuzzerTestOneInput"; | ||
DavidKorczynski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
static char *my_argv[5]; | ||
int main(int argc, char **argv) { | ||
my_argv[0] = argv[0]; | ||
my_argv[1] = "-a"; | ||
my_argv[2] = argv[1]; | ||
my_argv[3] = NULL; | ||
my_argv[4] = random_string; | ||
return old_main(3, my_argv); | ||
} |
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.
Maybe put a TODO here to reference an issue for a long term solution to identifying non-persistent AFL fuzz targets.
@vanhauser-thc Do you have an ideas about how we can identify if a fuzz target uses persistent mode or not?
We can't just look for
__afl_manual_init
can we?Note that LLVMFuzzerTestOneInput will also be in the binary so that the rest of the infra can identify it as a fuzz target.
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.
Thanks, can you change this to
TODO(https://github.com/google/oss-fuzz/issues/7347):...
?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.
the AFL way is to check for the string
##SIG_AFL_PERSISTENT##
in the binary. if that is present, then it is persistent.for deferred forkserver it is
##SIG_AFL_DEFER_FORKSRV##
note that you can have the forkserver (well you should have one, better performance) without persistent mode - and vice versa.
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.
Interesting -- is this by setting N here to 1 https://github.com/AFLplusplus/AFLplusplus/blob/1d4f1e48797c064ee71441ba555b29fc3f467983/utils/aflpp_driver/aflpp_driver.c#L336 using this logic https://github.com/AFLplusplus/AFLplusplus/blob/1d4f1e48797c064ee71441ba555b29fc3f467983/utils/aflpp_driver/aflpp_driver.c#L306 ?
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.
no.
if you use the aflpp driver you automatically have persistent mode. (and a deferred forkserver).
for non-persistent mode you dont need to (and you should not) use aflppdriver
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.
Hey David can you implement a solution based on Marc's feedback.
Basically check if the binary doesn't contain
##SIG_AFL_PERSISTENT##
and then treat it as non-persistent.