Merge pull request #2229 from g0ku704/feat/disable_gcc_version_check

Introduce `AFL_GCC_DISABLE_VERSION_CHECK` to disable GCC version check
This commit is contained in:
van Hauser
2024-10-20 09:23:56 +02:00
committed by GitHub
7 changed files with 20 additions and 7 deletions

View File

@ -326,6 +326,11 @@ mode.
[instrumentation/README.instrument_list.md](../instrumentation/README.instrument_list.md) [instrumentation/README.instrument_list.md](../instrumentation/README.instrument_list.md)
for more information. for more information.
Setting `AFL_GCC_DISABLE_VERSION_CHECK=1` will disable the GCC plugin
version check if the target GCC plugin differs from the system-installed
version, resolving issues caused by version mismatches between GCC and
the plugin.
Setting `AFL_GCC_OUT_OF_LINE=1` will instruct afl-gcc-fast to instrument the Setting `AFL_GCC_OUT_OF_LINE=1` will instruct afl-gcc-fast to instrument the
code with calls to an injected subroutine instead of the much more efficient code with calls to an injected subroutine instead of the much more efficient
inline instrumentation. inline instrumentation.

View File

@ -52,9 +52,9 @@ static char *afl_environment_variables[] = {
"AFL_FRIDA_VERBOSE", "AFL_OLD_FORKSERVER", "AFL_OPT_LEVEL", "AFL_FRIDA_VERBOSE", "AFL_OLD_FORKSERVER", "AFL_OPT_LEVEL",
"AFL_FUZZER_ARGS", // oss-fuzz "AFL_FUZZER_ARGS", // oss-fuzz
"AFL_FUZZER_STATS_UPDATE_INTERVAL", "AFL_GDB", "AFL_GCC_ALLOWLIST", "AFL_FUZZER_STATS_UPDATE_INTERVAL", "AFL_GDB", "AFL_GCC_ALLOWLIST",
"AFL_GCC_DENYLIST", "AFL_GCC_BLOCKLIST", "AFL_GCC_INSTRUMENT_FILE", "AFL_GCC_DENYLIST", "AFL_GCC_BLOCKLIST", "AFL_GCC_DISABLE_VERSION_CHECK",
"AFL_GCC_OUT_OF_LINE", "AFL_GCC_SKIP_NEVERZERO", "AFL_GCJ", "AFL_GCC_INSTRUMENT_FILE", "AFL_GCC_OUT_OF_LINE", "AFL_GCC_SKIP_NEVERZERO",
"AFL_HANG_TMOUT", "AFL_FORKSRV_INIT_TMOUT", "AFL_HARDEN", "AFL_GCJ", "AFL_HANG_TMOUT", "AFL_FORKSRV_INIT_TMOUT", "AFL_HARDEN",
"AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES", "AFL_IGNORE_PROBLEMS", "AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES", "AFL_IGNORE_PROBLEMS",
"AFL_IGNORE_PROBLEMS_COVERAGE", "AFL_IGNORE_SEED_PROBLEMS", "AFL_IGNORE_PROBLEMS_COVERAGE", "AFL_IGNORE_SEED_PROBLEMS",
"AFL_IGNORE_TIMEOUTS", "AFL_IGNORE_UNKNOWN_ENVS", "AFL_IMPORT_FIRST", "AFL_IGNORE_TIMEOUTS", "AFL_IGNORE_UNKNOWN_ENVS", "AFL_IMPORT_FIRST",

View File

@ -51,7 +51,10 @@ The idea and much of the implementation comes from Laszlo Szekeres.
In order to leverage this mechanism, you need to have modern enough GCC (>= In order to leverage this mechanism, you need to have modern enough GCC (>=
version 4.5.0) and the plugin development headers installed on your system. That version 4.5.0) and the plugin development headers installed on your system. That
should be all you need. On Debian machines, these headers can be acquired by should be all you need. On Debian machines, these headers can be acquired by
installing the `gcc-VERSION-plugin-dev` packages. installing the `gcc-VERSION-plugin-dev` packages. If you're compiling a GCC
plugin that differs from the system-installed version and encounter issues
with version checks, you can use the `AFL_GCC_DISABLE_VERSION_CHECK` environment
variable.
To build the instrumentation itself, type `make`. This will generate binaries To build the instrumentation itself, type `make`. This will generate binaries
called `afl-gcc-fast` and `afl-g++-fast` in the parent directory. called `afl-gcc-fast` and `afl-g++-fast` in the parent directory.

View File

@ -370,7 +370,8 @@ Set AFL_QUIET in the environment to silence it.\n\
int plugin_init(struct plugin_name_args *info, int plugin_init(struct plugin_name_args *info,
struct plugin_gcc_version *version) { struct plugin_gcc_version *version) {
if (!plugin_default_version_check(version, &gcc_version)) if (!plugin_default_version_check(version, &gcc_version) &&
!getenv("AFL_GCC_DISABLE_VERSION_CHECK"))
FATAL(G_("GCC and plugin have incompatible versions, expected GCC %s, " FATAL(G_("GCC and plugin have incompatible versions, expected GCC %s, "
"is %s"), "is %s"),
gcc_version.basever, version->basever); gcc_version.basever, version->basever);

View File

@ -338,7 +338,8 @@ Set AFL_QUIET in the environment to silence it.\n\
int plugin_init(struct plugin_name_args *info, int plugin_init(struct plugin_name_args *info,
struct plugin_gcc_version *version) { struct plugin_gcc_version *version) {
if (!plugin_default_version_check(version, &gcc_version)) if (!plugin_default_version_check(version, &gcc_version) &&
!getenv("AFL_GCC_DISABLE_VERSION_CHECK"))
FATAL(G_("GCC and plugin have incompatible versions, expected GCC %s, " FATAL(G_("GCC and plugin have incompatible versions, expected GCC %s, "
"is %s"), "is %s"),
gcc_version.basever, version->basever); gcc_version.basever, version->basever);

View File

@ -478,7 +478,8 @@ Specify -frandom-seed for reproducible instrumentation.\n\
int plugin_init(struct plugin_name_args *info, int plugin_init(struct plugin_name_args *info,
struct plugin_gcc_version *version) { struct plugin_gcc_version *version) {
if (!plugin_default_version_check(version, &gcc_version)) if (!plugin_default_version_check(version, &gcc_version) &&
!getenv("AFL_GCC_DISABLE_VERSION_CHECK"))
FATAL(G_("GCC and plugin have incompatible versions, expected GCC %s, " FATAL(G_("GCC and plugin have incompatible versions, expected GCC %s, "
"is %s"), "is %s"),
gcc_version.basever, version->basever); gcc_version.basever, version->basever);

View File

@ -2958,6 +2958,8 @@ static void maybe_usage(aflcc_state_t *aflcc, int argc, char **argv) {
SAYF( SAYF(
"\nGCC Plugin-specific environment variables:\n" "\nGCC Plugin-specific environment variables:\n"
" AFL_GCC_CMPLOG: log operands of comparisons (RedQueen mutator)\n" " AFL_GCC_CMPLOG: log operands of comparisons (RedQueen mutator)\n"
" AFL_GCC_DISABLE_VERSION_CHECK: disable GCC plugin version "
"control\n"
" AFL_GCC_OUT_OF_LINE: disable inlined instrumentation\n" " AFL_GCC_OUT_OF_LINE: disable inlined instrumentation\n"
" AFL_GCC_SKIP_NEVERZERO: do not skip zero on trace counters\n" " AFL_GCC_SKIP_NEVERZERO: do not skip zero on trace counters\n"
" AFL_GCC_INSTRUMENT_FILE: enable selective instrumentation by " " AFL_GCC_INSTRUMENT_FILE: enable selective instrumentation by "