Skip to content

Commit 31c8a05

Browse files
Merge pull request AFLplusplus#2252 from StepanGulyaev/dev
Added CFISAN option for verbose output on crash
2 parents 701e89b + 46b87a6 commit 31c8a05

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

docs/env_variables.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ fairly broad use of environment variables instead:
104104
detection)
105105
- `AFL_USE_CFISAN=1` - activates the Control Flow Integrity sanitizer (e.g.
106106
type confusion vulnerabilities)
107+
- `AFL_CFISAN_VERBOSE=1` - outputs detailed information when control flow integrity violations occur, instead of simply terminating with "Illegal Instruction"
107108
- `AFL_USE_LSAN` - activates the leak sanitizer. To perform a leak check
108109
within your program at a certain point (such as at the end of an
109110
`__AFL_LOOP()`), you can run the macro `__AFL_LEAK_CHECK();` which will
@@ -114,6 +115,9 @@ fairly broad use of environment variables instead:
114115
- `AFL_USE_TSAN=1` - activates the thread sanitizer to find thread race
115116
conditions
116117
- `AFL_USE_UBSAN=1` - activates the undefined behavior sanitizer
118+
- `AFL_UBSAN_VERBOSE=1` - outputs detailed diagnostic information when undefined behavior is detected, instead of simply terminating with "Illegal Instruction"
119+
120+
- Note: both `AFL_CFISAN_VERBOSE=1` and `AFL_UBSAN_VERBOSE=1` are disabled by default as verbose output can significantly slow down fuzzing performance. Use these options only during debugging or when additional crash diagnostics are required
117121
118122
- `TMPDIR` is used by afl-as for temporary files; if this variable is not set,
119123
the tool defaults to /tmp.

include/envs.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ static char *afl_environment_variables[] = {
114114
"AFL_STATSD_TAGS_FLAVOR", "AFL_SYNC_TIME", "AFL_TESTCACHE_SIZE",
115115
"AFL_TESTCACHE_ENTRIES", "AFL_TMIN_EXACT", "AFL_TMPDIR", "AFL_TOKEN_FILE",
116116
"AFL_TRACE_PC", "AFL_USE_ASAN", "AFL_USE_MSAN", "AFL_USE_TRACE_PC",
117-
"AFL_USE_UBSAN", "AFL_USE_TSAN", "AFL_USE_CFISAN", "AFL_USE_LSAN",
118-
"AFL_WINE_PATH", "AFL_NO_SNAPSHOT", "AFL_EXPAND_HAVOC_NOW", "AFL_USE_FASAN",
119-
"AFL_USE_QASAN", "AFL_PRINT_FILENAMES", "AFL_PIZZA_MODE",
120-
"AFL_NO_FASTRESUME", NULL
117+
"AFL_USE_UBSAN", "AFL_UBSAN_VERBOSE", "AFL_USE_TSAN", "AFL_USE_CFISAN",
118+
"AFL_CFISAN_VERBOSE", "AFL_USE_LSAN", "AFL_WINE_PATH", "AFL_NO_SNAPSHOT",
119+
"AFL_EXPAND_HAVOC_NOW", "AFL_USE_FASAN", "AFL_USE_QASAN",
120+
"AFL_PRINT_FILENAMES", "AFL_PIZZA_MODE", "AFL_NO_FASTRESUME", NULL
121121

122122
};
123123

src/afl-cc.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,10 +1945,15 @@ void add_sanitizers(aflcc_state_t *aflcc, char **envp) {
19451945

19461946
if (getenv("AFL_USE_UBSAN") || aflcc->have_ubsan) {
19471947

1948-
if (!aflcc->have_ubsan) {
1948+
if (!aflcc->have_ubsan) { insert_param(aflcc, "-fsanitize=undefined"); }
19491949

1950-
insert_param(aflcc, "-fsanitize=undefined");
1951-
insert_param(aflcc, "-fno-sanitize-recover=all");
1950+
if (getenv("AFL_UBSAN_VERBOSE")) {
1951+
1952+
insert_param(aflcc, "-fno-sanitize-recover=undefined");
1953+
1954+
} else {
1955+
1956+
insert_param(aflcc, "-fsanitize-trap=undefined");
19521957

19531958
}
19541959

@@ -2009,6 +2014,12 @@ void add_sanitizers(aflcc_state_t *aflcc, char **envp) {
20092014

20102015
if (!aflcc->have_cfisan) { insert_param(aflcc, "-fsanitize=cfi"); }
20112016

2017+
if (getenv("AFL_CFISAN_VERBOSE")) {
2018+
2019+
insert_param(aflcc, "-fno-sanitize-trap=cfi");
2020+
2021+
}
2022+
20122023
if (!aflcc->have_hidden) {
20132024

20142025
insert_param(aflcc, "-fvisibility=hidden");

0 commit comments

Comments
 (0)