Skip to content

Commit f14eb8e

Browse files
committedJun 28, 2017
2.44b
1 parent feef3d4 commit f14eb8e

File tree

6 files changed

+60
-12
lines changed

6 files changed

+60
-12
lines changed
 

Diff for: ‎afl-as.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ static u8* modified_file; /* Instrumented file for the real 'as' */
5656
static u8 be_quiet, /* Quiet mode (no stderr output) */
5757
clang_mode, /* Running in clang mode? */
5858
pass_thru, /* Just pass data through? */
59-
just_version; /* Just show version? */
59+
just_version, /* Just show version? */
60+
sanitizer; /* Using ASAN / MSAN */
6061

6162
static u32 inst_ratio = 100, /* Instrumentation probability (%) */
6263
as_par_cnt = 1; /* Number of params to 'as' */
@@ -454,7 +455,8 @@ static void add_instrumentation(void) {
454455
pass_thru ? " (pass-thru mode)" : "");
455456
else OKF("Instrumented %u locations (%s-bit, %s mode, ratio %u%%).",
456457
ins_lines, use_64bit ? "64" : "32",
457-
getenv("AFL_HARDEN") ? "hardened" : "non-hardened",
458+
getenv("AFL_HARDEN") ? "hardened" :
459+
(sanitizer ? "ASAN/MSAN" : "non-hardened"),
458460
inst_ratio);
459461

460462
}
@@ -521,7 +523,10 @@ int main(int argc, char** argv) {
521523
ASAN-specific branches. But we can probabilistically compensate for
522524
that... */
523525

524-
if (getenv("AFL_USE_ASAN") || getenv("AFL_USE_MSAN")) inst_ratio /= 3;
526+
if (getenv("AFL_USE_ASAN") || getenv("AFL_USE_MSAN")) {
527+
sanitizer = 1;
528+
inst_ratio /= 3;
529+
}
525530

526531
if (!just_version) add_instrumentation();
527532

Diff for: ‎afl-showmap.c

+16-4
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ static s32 shm_id; /* ID of the SHM region */
6464
static u8 quiet_mode, /* Hide non-essential messages? */
6565
edges_only, /* Ignore hit counts? */
6666
cmin_mode, /* Generate output in afl-cmin mode? */
67-
binary_mode; /* Write output as a binary map */
67+
binary_mode, /* Write output as a binary map */
68+
keep_cores; /* Allow coredumps? */
6869

6970
static volatile u8
7071
stop_soon, /* Ctrl-C pressed? */
@@ -285,9 +286,13 @@ static void run_target(char** argv) {
285286

286287
}
287288

288-
r.rlim_max = r.rlim_cur = 0;
289+
if (keep_cores) r.rlim_max = r.rlim_cur = 0;
290+
else r.rlim_max = r.rlim_cur = RLIM_INFINITY;
291+
289292
setrlimit(RLIMIT_CORE, &r); /* Ignore errors */
290293

294+
if (!getenv("LD_BIND_LAZY")) setenv("LD_BIND_NOW", "1", 0);
295+
291296
execv(target_path, argv);
292297

293298
*(u32*)trace_bits = EXEC_FAIL_SIG;
@@ -479,7 +484,8 @@ static void usage(u8* argv0) {
479484
"Other settings:\n\n"
480485

481486
" -q - sink program's output and don't show messages\n"
482-
" -e - show edge coverage only, ignore hit counts\n\n"
487+
" -e - show edge coverage only, ignore hit counts\n"
488+
" -c - allow core dumps\n\n"
483489

484490
"This tool displays raw tuple data captured by AFL instrumentation.\n"
485491
"For additional help, consult %s/README.\n\n" cRST,
@@ -614,7 +620,7 @@ int main(int argc, char** argv) {
614620

615621
doc_path = access(DOC_PATH, F_OK) ? "docs" : DOC_PATH;
616622

617-
while ((opt = getopt(argc,argv,"+o:m:t:A:eqZQb")) > 0)
623+
while ((opt = getopt(argc,argv,"+o:m:t:A:eqZQbc")) > 0)
618624

619625
switch (opt) {
620626

@@ -719,6 +725,12 @@ int main(int argc, char** argv) {
719725
binary_mode = 1;
720726
break;
721727

728+
case 'c':
729+
730+
if (keep_cores) FATAL("Multiple -c options not supported");
731+
keep_cores = 1;
732+
break;
733+
722734
default:
723735

724736
usage(argv[0]);

Diff for: ‎config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
/* Version string: */
2323

24-
#define VERSION "2.43b"
24+
#define VERSION "2.44b"
2525

2626
/******************************************************
2727
* *

Diff for: ‎docs/ChangeLog

+15
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ Not sure if you should upgrade? The lowest currently recommended version
1616
is 2.41b. If you're stuck on an earlier release, it's strongly advisable
1717
to get on with the times.
1818

19+
--------------
20+
Version 2.44b:
21+
--------------
22+
23+
- Added a visual indicator of ASAN / MSAN mode when compiling. Requested
24+
by Jakub Wilk.
25+
26+
- Added support for afl-showmap coredumps (-c). Suggested by Jakub Wilk.
27+
28+
- Added LD_BIND_NOW=1 for afl-showmap by default. Although not really useful,
29+
it reportedly helps reproduce some crashes. Suggested by Jakub Wilk.
30+
31+
- Added a note about allocator_may_return_null=1 not always working with
32+
ASAN. Spotted by Jakub Wilk.
33+
1934
--------------
2035
Version 2.43b:
2136
--------------

Diff for: ‎docs/notes_for_asan.txt

+17-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,23 @@ emulation, so please do not try to use them with the -Q option; QEMU doesn't
113113
seem to appreciate the shadow VM trick used by these tools, and will likely
114114
just allocate all your physical memory, then crash.
115115

116-
4) What about UBSAN?
116+
4) ASAN and OOM crashes
117+
-----------------------
118+
119+
By default, ASAN treats memory allocation failures as fatal errors, immediately
120+
causing the program to crash. Since this is a departure from normal POSIX
121+
semantics (and creates the appearance of security issues in otherwise
122+
properly-behaving programs), we try to disable this by specifying
123+
allocator_may_return_null=1 in ASAN_OPTIONS.
124+
125+
Unfortunately, it's been reported that this setting still causes ASAN to
126+
trigger phantom crashes in situations where the standard allocator would
127+
simply return NULL. If this is interfering with your fuzzing jobs, you may
128+
want to cc: yourself on this bug:
129+
130+
https://bugs.llvm.org/show_bug.cgi?id=22026
131+
132+
5) What about UBSAN?
117133
--------------------
118134

119135
Some folks expressed interest in fuzzing with UBSAN. This isn't officially

Diff for: ‎llvm_mode/afl-llvm-pass.so.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ bool AFLCoverage::runOnModule(Module &M) {
159159

160160
if (!inst_blocks) WARNF("No instrumentation targets found.");
161161
else OKF("Instrumented %u locations (%s mode, ratio %u%%).",
162-
inst_blocks,
163-
getenv("AFL_HARDEN") ? "hardened" : "non-hardened",
164-
inst_ratio);
162+
inst_blocks, getenv("AFL_HARDEN") ? "hardened" :
163+
((getenv("AFL_USE_ASAN") || getenv("AFL_USE_MSAN")) ?
164+
"ASAN/MSAN" : "non-hardened"), inst_ratio);
165165

166166
}
167167

0 commit comments

Comments
 (0)
Please sign in to comment.